forked from organicmaps/organicmaps
using ResourceStyleCacheContext to avoid caching some resources twice.
This commit is contained in:
parent
ba1fbcd59f
commit
10e1d1ddac
16 changed files with 65 additions and 23 deletions
|
@ -313,7 +313,9 @@ bool Ruler::find(yg::ResourceStyleCache * stylesCache) const
|
|||
return true;
|
||||
}
|
||||
|
||||
void Ruler::getNonPackedRects(yg::ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const
|
||||
void Ruler::getNonPackedRects(yg::ResourceStyleCache * stylesCache,
|
||||
yg::ResourceStyleCacheContext * cacheContext,
|
||||
vector<m2::PointU> & v) const
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
namespace yg
|
||||
{
|
||||
class ResourceStyleCache;
|
||||
class ResourceStyleCacheContext;
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
@ -75,7 +76,7 @@ public:
|
|||
|
||||
void map(yg::ResourceStyleCache * stylesCache) const;
|
||||
bool find(yg::ResourceStyleCache * stylesCache) const;
|
||||
void getNonPackedRects(yg::ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const;
|
||||
void getNonPackedRects(yg::ResourceStyleCache * stylesCache, yg::ResourceStyleCacheContext * context, vector<m2::PointU> & v) const;
|
||||
|
||||
int visualRank() const;
|
||||
yg::OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const;
|
||||
|
|
|
@ -85,12 +85,22 @@ namespace yg
|
|||
return skinPage->findCircleInfo(m_ci) != 0x00FFFFFF;
|
||||
}
|
||||
|
||||
void CircleElement::getNonPackedRects(ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const
|
||||
void CircleElement::getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const
|
||||
{
|
||||
shared_ptr<SkinPage> const & skinPage = stylesCache->cachePage();
|
||||
|
||||
if (context && context->hasCircleInfo(m_ci))
|
||||
return;
|
||||
|
||||
if (skinPage->findCircleInfo(m_ci) == 0x00FFFFFF)
|
||||
{
|
||||
if (context)
|
||||
context->addCircleInfo(m_ci);
|
||||
|
||||
v.push_back(m_ci.patternSize());
|
||||
}
|
||||
}
|
||||
|
||||
OverlayElement * CircleElement::clone(math::Matrix<double, 3, 3> const & m) const
|
||||
|
|
|
@ -32,7 +32,9 @@ namespace yg
|
|||
void draw(gl::OverlayRenderer * s, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
void map(ResourceStyleCache * stylesCache) const;
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const;
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
bool find(ResourceStyleCache * stylesCache) const;
|
||||
|
||||
int visualRank() const;
|
||||
|
|
|
@ -54,10 +54,12 @@ namespace yg
|
|||
m_elements[i]->map(stylesCache);
|
||||
}
|
||||
|
||||
void CompositeOverlayElement::getNonPackedRects(ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const
|
||||
void CompositeOverlayElement::getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const
|
||||
{
|
||||
for (unsigned i = 0; i < m_elements.size(); ++i)
|
||||
m_elements[i]->getNonPackedRects(stylesCache, v);
|
||||
m_elements[i]->getNonPackedRects(stylesCache, context, v);
|
||||
}
|
||||
|
||||
bool CompositeOverlayElement::find(ResourceStyleCache * stylesCache) const
|
||||
|
|
|
@ -28,7 +28,9 @@ namespace yg
|
|||
|
||||
void map(ResourceStyleCache * stylesCache) const;
|
||||
bool find(ResourceStyleCache * stylesCache) const;
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const;
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
|
||||
int visualRank() const;
|
||||
|
||||
|
|
|
@ -244,11 +244,10 @@ namespace yg
|
|||
vector<m2::PointU> sizes;
|
||||
sizes.reserve(100);
|
||||
|
||||
/// some glyphs will be counted twice(probably a lot of them).
|
||||
/// that way we'll actually waste a lot of texture space.
|
||||
ResourceStyleCacheContext ctx;
|
||||
|
||||
for (unsigned i = 0; i < v.size(); ++i)
|
||||
v[i]->getNonPackedRects(stylesCache, sizes);
|
||||
v[i]->getNonPackedRects(stylesCache, &ctx, sizes);
|
||||
|
||||
if (sizes.empty())
|
||||
return;
|
||||
|
@ -270,7 +269,9 @@ namespace yg
|
|||
for (pos = 0; pos < v.size(); ++pos)
|
||||
{
|
||||
sizes.clear();
|
||||
v[pos]->getNonPackedRects(stylesCache, sizes);
|
||||
ctx.clear();
|
||||
|
||||
v[pos]->getNonPackedRects(stylesCache, &ctx, sizes);
|
||||
|
||||
/// @todo Check logic!
|
||||
if (!sizes.empty())
|
||||
|
@ -289,7 +290,7 @@ namespace yg
|
|||
for (; pos < v.size(); ++pos)
|
||||
{
|
||||
sizes.clear();
|
||||
v[pos]->getNonPackedRects(stylesCache, sizes);
|
||||
v[pos]->getNonPackedRects(stylesCache, 0, sizes);
|
||||
v[pos]->setIsNeedRedraw(sizes.empty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace yg
|
|||
}
|
||||
|
||||
class ResourceStyleCache;
|
||||
class ResourceStyleCacheContext;
|
||||
|
||||
class OverlayElement
|
||||
{
|
||||
|
@ -57,7 +58,9 @@ namespace yg
|
|||
|
||||
/// caching-related functions.
|
||||
/// @{
|
||||
virtual void getNonPackedRects(ResourceStyleCache * stylesCache, vector<m2::PointU> & sizes) const = 0;
|
||||
virtual void getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * cacheContext,
|
||||
vector<m2::PointU> & sizes) const = 0;
|
||||
virtual bool find(ResourceStyleCache * stylesCache) const = 0;
|
||||
virtual void map(ResourceStyleCache * stylesCache) const = 0;
|
||||
/// @}
|
||||
|
|
|
@ -99,16 +99,18 @@ namespace yg
|
|||
return TextElement::find(m_glyphLayout, stylesCache, desc);
|
||||
}
|
||||
|
||||
void PathTextElement::getNonPackedRects(ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const
|
||||
void PathTextElement::getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const
|
||||
{
|
||||
yg::FontDesc desc = m_fontDesc;
|
||||
if (desc.m_isMasked)
|
||||
{
|
||||
TextElement::getNonPackedRects(m_glyphLayout, desc, stylesCache, v);
|
||||
TextElement::getNonPackedRects(m_glyphLayout, desc, stylesCache, context, v);
|
||||
desc.m_isMasked = false;
|
||||
}
|
||||
|
||||
TextElement::getNonPackedRects(m_glyphLayout, desc, stylesCache, v);
|
||||
TextElement::getNonPackedRects(m_glyphLayout, desc, stylesCache, context, v);
|
||||
}
|
||||
|
||||
void PathTextElement::map(ResourceStyleCache * stylesCache) const
|
||||
|
|
|
@ -27,7 +27,9 @@ namespace yg
|
|||
|
||||
void draw(gl::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const;
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
bool find(ResourceStyleCache * stylesCache) const;
|
||||
void map(ResourceStyleCache * stylesCache) const;
|
||||
|
||||
|
|
|
@ -323,19 +323,21 @@ namespace yg
|
|||
return true;
|
||||
}
|
||||
|
||||
void StraightTextElement::getNonPackedRects(ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const
|
||||
void StraightTextElement::getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const
|
||||
{
|
||||
for (unsigned i = 0; i < m_glyphLayouts.size(); ++i)
|
||||
{
|
||||
if (m_glyphLayouts[i].fontDesc().m_isMasked)
|
||||
TextElement::getNonPackedRects(m_glyphLayouts[i], m_glyphLayouts[i].fontDesc(), stylesCache, v);
|
||||
TextElement::getNonPackedRects(m_glyphLayouts[i], m_glyphLayouts[i].fontDesc(), stylesCache, context, v);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < m_glyphLayouts.size(); ++i)
|
||||
{
|
||||
yg::FontDesc fontDesc = m_glyphLayouts[i].fontDesc();
|
||||
fontDesc.m_isMasked = false;
|
||||
TextElement::getNonPackedRects(m_glyphLayouts[i], fontDesc, stylesCache, v);
|
||||
TextElement::getNonPackedRects(m_glyphLayouts[i], fontDesc, stylesCache, context, v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,9 @@ namespace yg
|
|||
|
||||
void draw(gl::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const;
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
bool find(ResourceStyleCache * stylesCache) const;
|
||||
void map(ResourceStyleCache * stylesCache) const;
|
||||
|
||||
|
|
|
@ -95,7 +95,9 @@ namespace yg
|
|||
return true;
|
||||
}
|
||||
|
||||
void SymbolElement::getNonPackedRects(ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const
|
||||
void SymbolElement::getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,9 @@ namespace yg
|
|||
void draw(gl::OverlayRenderer * s, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
void map(ResourceStyleCache * stylesCache) const;
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache, vector<m2::PointU> & v) const;
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
bool find(ResourceStyleCache * stylesCache) const;
|
||||
|
||||
uint32_t styleID() const;
|
||||
|
|
|
@ -186,6 +186,7 @@ namespace yg
|
|||
void TextElement::getNonPackedRects(GlyphLayout const & layout,
|
||||
FontDesc const & desc,
|
||||
ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const
|
||||
{
|
||||
if (!desc.IsValid())
|
||||
|
@ -203,8 +204,13 @@ namespace yg
|
|||
desc.m_isMasked,
|
||||
desc.m_isMasked ? desc.m_maskColor : desc.m_color);
|
||||
|
||||
if (context && context->hasGlyph(gk))
|
||||
continue;
|
||||
|
||||
if (skinPage->findGlyph(gk) == 0x00FFFFFF)
|
||||
{
|
||||
if (context)
|
||||
context->addGlyph(gk);
|
||||
shared_ptr<GlyphInfo> gi = glyphCache->getGlyphInfo(gk);
|
||||
v.push_back(m2::PointU(gi->m_metrics.m_width + 4, gi->m_metrics.m_height + 4));
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ namespace yg
|
|||
void getNonPackedRects(GlyphLayout const & layout,
|
||||
FontDesc const & desc,
|
||||
ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
|
||||
public:
|
||||
|
|
Loading…
Add table
Reference in a new issue