diff options
author | ExMix <rahuba.youri@mapswithme.com> | 2014-12-30 16:06:16 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:35:48 +0300 |
commit | 5d3977bebd9fb7e68c7eec158e5ca06385372a5e (patch) | |
tree | 6990c3dc548a11c9f6ebb1faae04cc0ce1d670a0 /drape/texture_manager.hpp | |
parent | 8649b4e94cd701f124cb23b72dde6c8802fb7bb2 (diff) |
[drape] from now in drape we will use strong texturing model without texture sets.
- remove texture sets (controller and sets), applying and managing
- improve memory allocations for resources
- rewrite font texture for dynamic glyph mapping
- fragmentation unicode block on textures
- some minor stuff
Diffstat (limited to 'drape/texture_manager.hpp')
-rw-r--r-- | drape/texture_manager.hpp | 111 |
1 files changed, 84 insertions, 27 deletions
diff --git a/drape/texture_manager.hpp b/drape/texture_manager.hpp index 7cf1227168..8a5ca4bbac 100644 --- a/drape/texture_manager.hpp +++ b/drape/texture_manager.hpp @@ -2,48 +2,105 @@ #include "../base/string_utils.hpp" +#include "color.hpp" #include "pointers.hpp" -#include "texture_set_holder.hpp" -#include "texture_set_controller.hpp" +#include "texture.hpp" +#include "glyph_manager.hpp" namespace dp { -class TextureManager : public TextureSetHolder +class TextureManager { public: - void Init(string const & resourcePrefix); - void Release(); - virtual void GetSymbolRegion(string const & symbolName, SymbolRegion & region) const; - virtual bool GetGlyphRegion(strings::UniChar charCode, GlyphRegion & region) const; - virtual void GetStippleRegion(StipplePenKey const & pen, StippleRegion & region) const; - virtual void GetColorRegion(ColorKey const & pen, TextureSetHolder::ColorRegion & region) const; - virtual int GetMaxTextureSet() const; + class BaseRegion + { + public: + void SetResourceInfo(RefPointer<Texture::ResourceInfo> info); + void SetTexture(RefPointer<Texture> texture); + RefPointer<Texture> GetTexture() const { return m_texture; } + bool IsValid() const; - virtual void UpdateDynamicTextures(); + void GetPixelSize(m2::PointU & size) const; + uint32_t GetPixelHeight() const; + m2::RectF const & GetTexRect() const; - void BindTextureSet(uint32_t textureSet) const; - uint32_t GetTextureCount(uint32_t textureSet) const; + protected: + RefPointer<Texture::ResourceInfo> m_info; + RefPointer<Texture> m_texture; + }; -private: - template <typename TKey, typename TRegion> - bool FindResource(TKey const & key, TRegion & region) const; + class SymbolRegion : public BaseRegion {}; + + class GlyphRegion : public BaseRegion + { + public: + GlyphRegion(); + + float GetOffsetX() const; + float GetOffsetY() const; + float GetAdvanceX() const; + float GetAdvanceY() const; + }; + + class StippleRegion : public BaseRegion + { + public: + StippleRegion() : BaseRegion() {} + + uint32_t GetMaskPixelLength() const; + uint32_t GetPatternPixelLength() const; + }; + + class ColorRegion : public BaseRegion + { + public: + ColorRegion() : BaseRegion() {} + }; + + struct Params + { + string m_resPrefix; + GlyphManager::Params m_glyphMngParams; + }; + + void Init(Params const & params); + void Release(); + void GetSymbolRegion(string const & symbolName, SymbolRegion & region) const; + typedef buffer_vector<uint8_t, 8> TStipplePattern; + void GetStippleRegion(TStipplePattern const & pen, StippleRegion & region) const; + void GetColorRegion(Color const & color, ColorRegion & region) const; + + typedef buffer_vector<GlyphRegion, 32> TGlyphsBuffer; + void GetGlyphRegions(strings::UniString const & text, TGlyphsBuffer & regions) const; + void UpdateDynamicTextures(); private: - class TextureSet; - vector<MasterPointer<TextureSet> > m_textures; - uint32_t m_maxTextureBlocks; -}; + struct GlyphGroup + { + GlyphGroup() = default; + GlyphGroup(strings::UniChar const & start, strings::UniChar const & end) + : m_startChar(start), m_endChar(end) {} -class TextureSetBinder : public TextureSetController -{ -public: - TextureSetBinder(RefPointer<TextureManager> manager); - void BindTextureSet(uint32_t textureSet) const; - uint32_t GetTextureCount(uint32_t textureSet) const; + strings::UniChar m_startChar = 0; + strings::UniChar m_endChar = 0; + + MasterPointer<Texture> m_texture; + }; + + uint32_t m_maxTextureSize; + + void AllocateGlyphTexture(TextureManager::GlyphGroup & group) const; private: - RefPointer<TextureManager> m_manager; + MasterPointer<Texture> m_symbolTexture; + MasterPointer<Texture> m_stipplePenTexture; + MasterPointer<Texture> m_colorTexture; + + MasterPointer<GlyphManager> m_glyphManager; + + mutable buffer_vector<GlyphGroup, 64> m_glyphGroups; + mutable buffer_vector<MasterPointer<Texture>, 4> m_hybridGlyphGroups; }; } // namespace dp |