#pragma once #include "base/string_utils.hpp" #include "drape/color.hpp" #include "drape/pointers.hpp" #include "drape/texture.hpp" #include "drape/glyph_manager.hpp" namespace dp { class TextureManager { public: class BaseRegion { public: void SetResourceInfo(RefPointer info); void SetTexture(RefPointer texture); RefPointer GetTexture() const { return m_texture; } bool IsValid() const; m2::PointU GetPixelSize() const; uint32_t GetPixelHeight() const; m2::RectF const & GetTexRect() const; protected: RefPointer m_info; RefPointer m_texture; }; 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 TStipplePattern; void GetStippleRegion(TStipplePattern const & pen, StippleRegion & region) const; void GetColorRegion(Color const & color, ColorRegion & region) const; typedef buffer_vector TGlyphsBuffer; void GetGlyphRegions(strings::UniString const & text, TGlyphsBuffer & regions) const; void UpdateDynamicTextures(); private: struct GlyphGroup { GlyphGroup() = default; GlyphGroup(strings::UniChar const & start, strings::UniChar const & end) : m_startChar(start), m_endChar(end) {} strings::UniChar m_startChar = 0; strings::UniChar m_endChar = 0; MasterPointer m_texture; }; uint32_t m_maxTextureSize; void AllocateGlyphTexture(TextureManager::GlyphGroup & group) const; private: MasterPointer m_symbolTexture; MasterPointer m_stipplePenTexture; MasterPointer m_colorTexture; MasterPointer m_glyphManager; mutable buffer_vector m_glyphGroups; mutable buffer_vector, 4> m_hybridGlyphGroups; }; } // namespace dp