diff --git a/drape/texture_manager.cpp b/drape/texture_manager.cpp index e6642e1765..1ecc377eb9 100644 --- a/drape/texture_manager.cpp +++ b/drape/texture_manager.cpp @@ -133,13 +133,8 @@ void TextureManager::UpdateDynamicTextures() m_colorTexture->UpdateState(); m_stipplePenTexture->UpdateState(); - for (GlyphGroup & g : m_glyphGroups) - if (!g.m_texture.IsNull()) - g.m_texture->UpdateState(); - - for (HybridGlyphGroup & g : m_hybridGlyphGroups) - if (!g.m_texture.IsNull()) - g.m_texture->UpdateState(); + UpdateGlyphTextures(m_glyphGroups); + UpdateGlyphTextures(m_hybridGlyphGroups); } MasterPointer TextureManager::AllocateGlyphTexture() const @@ -339,47 +334,12 @@ void TextureManager::GetColorRegion(Color const & color, ColorRegion & region) void TextureManager::GetGlyphRegions(TMultilineText const & text, TMultilineGlyphsBuffer & buffers) { - auto cb = [this](TMultilineText const & text, TMultilineGlyphsBuffer & buffers, GlyphGroup & group) - { - buffers.resize(text.size()); - for (size_t i = 0; i < text.size(); ++i) - { - strings::UniString const & str = text[i]; - TGlyphsBuffer & buffer = buffers[i]; - FillResultBuffer(str, group, buffer); - } - }; - - auto hypridCb = [this](TMultilineText const & text, TMultilineGlyphsBuffer & buffers, HybridGlyphGroup & group) - { - buffers.resize(text.size()); - for (size_t i = 0; i < text.size(); ++i) - { - strings::UniString const & str = text[i]; - TGlyphsBuffer & buffer = buffers[i]; - - MarkCharactersUsage(str, group); - FillResultBuffer(str, group, buffer); - } - }; - - CalcGlyphRegions(text, buffers, cb, hypridCb); + CalcGlyphRegions(text, buffers); } void TextureManager::GetGlyphRegions(strings::UniString const & text, TGlyphsBuffer & regions) { - auto cb = [this](strings::UniString const & text, TGlyphsBuffer & regions, GlyphGroup & group) - { - FillResultBuffer(text, group, regions); - }; - - auto hypridCb = [this](strings::UniString const & text, TGlyphsBuffer & regions, HybridGlyphGroup & group) - { - MarkCharactersUsage(text, group); - FillResultBuffer(text, group, regions); - }; - - CalcGlyphRegions(text, regions, cb, hypridCb); + CalcGlyphRegions(text, regions); } constexpr size_t TextureManager::GetInvalidGlyphGroup() diff --git a/drape/texture_manager.hpp b/drape/texture_manager.hpp index 369b758e7a..e49ca419e9 100644 --- a/drape/texture_manager.hpp +++ b/drape/texture_manager.hpp @@ -125,6 +125,8 @@ private: size_t GetNumberOfUnfoundCharacters(strings::UniString const & text, HybridGlyphGroup const & group) const; void MarkCharactersUsage(strings::UniString const & text, HybridGlyphGroup & group); + /// it's a dummy method to support generic code + void MarkCharactersUsage(strings::UniString const & text, GlyphGroup & group) {} template void FillResultBuffer(strings::UniString const & text, TGlyphGroup & group, TGlyphsBuffer & regions) @@ -142,30 +144,53 @@ private: } } - static constexpr size_t GetInvalidGlyphGroup(); + template + void FillResults(strings::UniString const & text, TGlyphsBuffer & buffers, TGlyphGroup & group) + { + MarkCharactersUsage(text, group); + FillResultBuffer(text, group, buffers); + } + + template + void FillResults(TMultilineText const & text, TMultilineGlyphsBuffer & buffers, TGlyphGroup & group) + { + buffers.resize(text.size()); + for (size_t i = 0; i < text.size(); ++i) + { + strings::UniString const & str = text[i]; + TGlyphsBuffer & buffer = buffers[i]; + FillResults(str, buffer, group); + } + } template - void CalcGlyphRegions(TText const & text, TBuffer & buffers, - function callback, - function hybridCallback) + void CalcGlyphRegions(TText const & text, TBuffer & buffers) { size_t const groupIndex = FindGlyphsGroup(text); if (groupIndex != GetInvalidGlyphGroup()) { GlyphGroup & group = m_glyphGroups[groupIndex]; - if (callback != nullptr) - callback(text, buffers, group); + FillResults(text, buffers, group); } else { size_t const hybridGroupIndex = FindHybridGlyphsGroup(text); ASSERT(hybridGroupIndex != GetInvalidGlyphGroup(), ()); HybridGlyphGroup & group = m_hybridGlyphGroups[hybridGroupIndex]; - if (hybridCallback != nullptr) - hybridCallback(text, buffers, group); + FillResults(text, buffers, group); } } + template + void UpdateGlyphTextures(TGlyphGroups & groups) + { + for (auto & g : groups) + if (!g.m_texture.IsNull()) + g.m_texture->UpdateState(); + } + + static constexpr size_t GetInvalidGlyphGroup(); + private: MasterPointer m_symbolTexture; MasterPointer m_stipplePenTexture;