diff --git a/gui/display_list_cache.cpp b/gui/display_list_cache.cpp index c3da094cc0..5174a11f36 100644 --- a/gui/display_list_cache.cpp +++ b/gui/display_list_cache.cpp @@ -48,4 +48,39 @@ namespace gui { return m_Glyphs.find(key) != m_Glyphs.end(); } + + void DisplayListCache::TouchSymbol(char const * name) + { + FindSymbol(name); + } + + bool DisplayListCache::HasSymbol(char const * name) + { + return m_Symbols.find(name) != m_Symbols.end(); + } + + shared_ptr const & DisplayListCache::FindSymbol(char const * name) + { + string s(name); + TSymbols::const_iterator it = m_Symbols.find(s); + + if (it != m_Symbols.end()) + return it->second; + + shared_ptr & dl = m_Symbols[s]; + + dl.reset(m_CacheScreen->createDisplayList()); + + m_CacheScreen->beginFrame(); + m_CacheScreen->setDisplayList(dl.get()); + + /// @todo do not cache depth in display list. use separate vertex shader and uniform constant + /// to specify it while rendering display list. + m_CacheScreen->drawSymbol(m2::PointD(0, 0), name, graphics::EPosAbove, graphics::maxDepth - 4); + + m_CacheScreen->setDisplayList(0); + m_CacheScreen->endFrame(); + + return dl; + } } diff --git a/gui/display_list_cache.hpp b/gui/display_list_cache.hpp index c48f5b3868..1d25339a47 100644 --- a/gui/display_list_cache.hpp +++ b/gui/display_list_cache.hpp @@ -16,9 +16,11 @@ namespace gui graphics::GlyphCache * m_GlyphCache; /// Actual cache of glyphs as a display lists typedef map > TGlyphs; - TGlyphs m_Glyphs; + typedef map > TSymbols; + TSymbols m_Symbols; + public: DisplayListCache(graphics::Screen * CacheScreen, @@ -30,5 +32,15 @@ namespace gui shared_ptr const & FindGlyph(graphics::GlyphKey const & key); /// Check, whether the glyph is present in cache. bool HasGlyph(graphics::GlyphKey const & key); + + /// @todo refactor to have common functions TouchInfo, FindInfo, HasInfo + /// taking as example ResourceCache mapInfo, findInfo, hasInfo functions + + /// Add symbol to cache if needed + void TouchSymbol(char const * name); + /// Find symbol in cache, caching if needed + shared_ptr const & FindSymbol(char const * name); + /// Check, whether the display list for specified symbol is present in cache + bool HasSymbol(char const * name); }; } diff --git a/map/information_display.cpp b/map/information_display.cpp index 5eea2f8f49..4c031296c2 100644 --- a/map/information_display.cpp +++ b/map/information_display.cpp @@ -297,7 +297,8 @@ void InformationDisplay::drawMemoryWarning(Drawer * drawer) void InformationDisplay::drawPlacemark(Drawer * pDrawer, string const & symbol, m2::PointD const & pt) { - pDrawer->drawSymbol(pt, symbol, graphics::EPosAbove, graphics::maxDepth - 4); + pDrawer->screen()->drawDisplayList(m_controller->GetDisplayListCache()->FindSymbol(symbol.c_str()).get(), + math::Shift(math::Identity(), pt)); } /*