added ability to cache symbols in display lists and refactored InformationDisplay::drawPlacemark

This commit is contained in:
rachytski 2013-03-31 09:12:18 +03:00 committed by Alex Zolotarev
parent 32ed2c22e3
commit 7f2e412d35
3 changed files with 50 additions and 2 deletions

View file

@ -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<graphics::DisplayList> 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<graphics::DisplayList> & 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;
}
}

View file

@ -16,9 +16,11 @@ namespace gui
graphics::GlyphCache * m_GlyphCache;
/// Actual cache of glyphs as a display lists
typedef map<graphics::GlyphKey, shared_ptr<graphics::DisplayList> > TGlyphs;
TGlyphs m_Glyphs;
typedef map<string, shared_ptr<graphics::DisplayList> > TSymbols;
TSymbols m_Symbols;
public:
DisplayListCache(graphics::Screen * CacheScreen,
@ -30,5 +32,15 @@ namespace gui
shared_ptr<graphics::DisplayList> 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<graphics::DisplayList> const & FindSymbol(char const * name);
/// Check, whether the display list for specified symbol is present in cache
bool HasSymbol(char const * name);
};
}

View file

@ -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<double, 3>(), pt));
}
/*