forked from organicmaps/organicmaps
removed ResourceStyleCache and all caching related functions from OverlayElement.
This commit is contained in:
parent
0502942041
commit
530f436fdc
20 changed files with 0 additions and 676 deletions
|
@ -304,21 +304,6 @@ void Ruler::draw(yg::gl::OverlayRenderer * s, math::Matrix<double, 3, 3> const &
|
|||
}
|
||||
}
|
||||
|
||||
void Ruler::map(yg::ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
}
|
||||
|
||||
bool Ruler::find(yg::ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Ruler::getNonPackedRects(yg::ResourceStyleCache * stylesCache,
|
||||
yg::ResourceStyleCacheContext * cacheContext,
|
||||
vector<m2::PointU> & v) const
|
||||
{
|
||||
}
|
||||
|
||||
int Ruler::visualRank() const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
|
||||
namespace yg
|
||||
{
|
||||
class ResourceStyleCache;
|
||||
class ResourceStyleCacheContext;
|
||||
|
||||
namespace gl
|
||||
{
|
||||
class Screen;
|
||||
|
@ -74,10 +71,6 @@ public:
|
|||
|
||||
void draw(yg::gl::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
void map(yg::ResourceStyleCache * stylesCache) const;
|
||||
bool find(yg::ResourceStyleCache * stylesCache) 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;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "circle_element.hpp"
|
||||
|
||||
#include "resource_style_cache.hpp"
|
||||
#include "overlay_renderer.hpp"
|
||||
#include "resource_style.hpp"
|
||||
#include "skin.hpp"
|
||||
|
@ -69,40 +68,6 @@ namespace yg
|
|||
return 500;
|
||||
}
|
||||
|
||||
void CircleElement::map(ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
shared_ptr<SkinPage> const & skinPage = stylesCache->cachePage();
|
||||
|
||||
ASSERT(skinPage->hasRoom(m_ci), ());
|
||||
|
||||
skinPage->mapCircleInfo(m_ci);
|
||||
}
|
||||
|
||||
bool CircleElement::find(ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
shared_ptr<SkinPage> const & skinPage = stylesCache->cachePage();
|
||||
|
||||
return skinPage->findCircleInfo(m_ci) != 0x00FFFFFF;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return new CircleElement(*this, m);
|
||||
|
|
|
@ -31,12 +31,6 @@ namespace yg
|
|||
|
||||
void draw(gl::OverlayRenderer * s, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
void map(ResourceStyleCache * stylesCache) const;
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
bool find(ResourceStyleCache * stylesCache) const;
|
||||
|
||||
int visualRank() const;
|
||||
|
||||
OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const;
|
||||
|
|
|
@ -48,29 +48,6 @@ namespace yg
|
|||
m_elements[i]->draw(r, m);
|
||||
}
|
||||
|
||||
void CompositeOverlayElement::map(ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
for (unsigned i = 0; i < m_elements.size(); ++i)
|
||||
m_elements[i]->map(stylesCache);
|
||||
}
|
||||
|
||||
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, context, v);
|
||||
}
|
||||
|
||||
bool CompositeOverlayElement::find(ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
for (unsigned i = 0; i < m_elements.size(); ++i)
|
||||
if (!m_elements[i]->find(stylesCache))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CompositeOverlayElement::visualRank() const
|
||||
{
|
||||
int res = numeric_limits<int>::min();
|
||||
|
|
|
@ -26,15 +26,8 @@ namespace yg
|
|||
|
||||
void draw(gl::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
void map(ResourceStyleCache * stylesCache) const;
|
||||
bool find(ResourceStyleCache * stylesCache) const;
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
|
||||
int visualRank() const;
|
||||
|
||||
|
||||
void offset(m2::PointD const & offs);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "info_layer.hpp"
|
||||
#include "text_element.hpp"
|
||||
#include "resource_style_cache.hpp"
|
||||
|
||||
#include "../base/logging.hpp"
|
||||
#include "../base/stl_add.hpp"
|
||||
|
@ -235,77 +234,6 @@ namespace yg
|
|||
for_each(v.begin(), v.end(), bind(&InfoLayer::processOverlayElement, this, _1, cref(m)));
|
||||
}
|
||||
|
||||
void InfoLayer::cache(ResourceStyleCache * stylesCache)
|
||||
{
|
||||
/// collecting elements into vector sorted by visualPriority
|
||||
|
||||
vector<shared_ptr<OverlayElement> > v;
|
||||
m_tree.ForEach(MakeBackInsertFunctor(v));
|
||||
|
||||
sort(v.begin(), v.end(), &greater_priority);
|
||||
|
||||
/// making all elements visible
|
||||
|
||||
for (unsigned i = 0; i < v.size(); ++i)
|
||||
v[i]->setIsNeedRedraw(true);
|
||||
|
||||
/// collecting all the unpacked rects from all elements
|
||||
|
||||
vector<m2::PointU> sizes;
|
||||
sizes.reserve(100);
|
||||
|
||||
ResourceStyleCacheContext ctx;
|
||||
|
||||
for (unsigned i = 0; i < v.size(); ++i)
|
||||
v[i]->getNonPackedRects(stylesCache, &ctx, sizes);
|
||||
|
||||
if (sizes.empty())
|
||||
return;
|
||||
|
||||
/// if there are enough room to cache all the elements
|
||||
if (stylesCache->hasRoom(&sizes[0], sizes.size()))
|
||||
{
|
||||
/// cache them
|
||||
for (unsigned i = 0; i < v.size(); ++i)
|
||||
v[i]->map(stylesCache);
|
||||
}
|
||||
else
|
||||
{
|
||||
/// no room to cache, so clear all pages and re-cache from the beginning
|
||||
stylesCache->clear();
|
||||
|
||||
int pos = 0;
|
||||
|
||||
for (pos = 0; pos < v.size(); ++pos)
|
||||
{
|
||||
sizes.clear();
|
||||
ctx.clear();
|
||||
|
||||
v[pos]->getNonPackedRects(stylesCache, &ctx, sizes);
|
||||
|
||||
/// @todo Check logic!
|
||||
if (!sizes.empty())
|
||||
{
|
||||
if (stylesCache->hasRoom(&sizes[0], sizes.size()))
|
||||
v[pos]->map(stylesCache);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (v.size() - pos >= 1)
|
||||
LOG(LINFO, ("making ", v.size() - pos, "elements invisible"));
|
||||
|
||||
/// partially uncached elements should be invisible
|
||||
for (; pos < v.size(); ++pos)
|
||||
{
|
||||
sizes.clear();
|
||||
v[pos]->getNonPackedRects(stylesCache, 0, sizes);
|
||||
v[pos]->setIsNeedRedraw(sizes.empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InfoLayer::clip(m2::RectI const & r)
|
||||
{
|
||||
vector<shared_ptr<OverlayElement> > v;
|
||||
|
@ -369,19 +297,6 @@ namespace yg
|
|||
return !res.empty();
|
||||
}
|
||||
|
||||
bool InfoLayer::checkCached(ResourceStyleCache * s) const
|
||||
{
|
||||
vector<shared_ptr<OverlayElement> > v;
|
||||
m_tree.ForEach(MakeBackInsertFunctor(v));
|
||||
|
||||
for (unsigned i = 0; i < v.size(); ++i)
|
||||
if (v[i]->isNeedRedraw())
|
||||
if (!v[i]->find(s))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
InfoLayer * InfoLayer::clone() const
|
||||
{
|
||||
InfoLayer * res = new InfoLayer(*this);
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
namespace yg
|
||||
{
|
||||
class ResourceStyleCache;
|
||||
|
||||
struct OverlayElementTraits
|
||||
{
|
||||
static m2::RectD const LimitRect(shared_ptr<OverlayElement> const & elem);
|
||||
|
@ -47,8 +45,6 @@ namespace yg
|
|||
|
||||
void clear();
|
||||
|
||||
void cache(ResourceStyleCache * cache);
|
||||
|
||||
void setCouldOverlap(bool flag);
|
||||
|
||||
void merge(InfoLayer const & infoLayer, math::Matrix<double, 3, 3> const & m);
|
||||
|
@ -56,7 +52,6 @@ namespace yg
|
|||
void clip(m2::RectI const & r);
|
||||
|
||||
bool checkHasEquals(InfoLayer const * l) const;
|
||||
bool checkCached(ResourceStyleCache * s) const;
|
||||
|
||||
InfoLayer * clone() const;
|
||||
};
|
||||
|
|
|
@ -13,9 +13,6 @@ namespace yg
|
|||
class OverlayRenderer;
|
||||
}
|
||||
|
||||
class ResourceStyleCache;
|
||||
class ResourceStyleCacheContext;
|
||||
|
||||
class OverlayElement
|
||||
{
|
||||
private:
|
||||
|
@ -56,15 +53,6 @@ namespace yg
|
|||
virtual void draw(gl::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const = 0;
|
||||
virtual int visualRank() const = 0;
|
||||
|
||||
/// caching-related functions.
|
||||
/// @{
|
||||
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;
|
||||
/// @}
|
||||
|
||||
m2::PointD const & pivot() const;
|
||||
void setPivot(m2::PointD const & pv);
|
||||
|
||||
|
|
|
@ -86,46 +86,6 @@ namespace yg
|
|||
m_glyphLayout.setPivot(pivot());
|
||||
}
|
||||
|
||||
bool PathTextElement::find(ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
yg::FontDesc desc = m_fontDesc;
|
||||
if (desc.m_isMasked)
|
||||
{
|
||||
if (!TextElement::find(m_glyphLayout, stylesCache, desc))
|
||||
return false;
|
||||
desc.m_isMasked = false;
|
||||
}
|
||||
|
||||
return TextElement::find(m_glyphLayout, stylesCache, desc);
|
||||
}
|
||||
|
||||
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, context, v);
|
||||
desc.m_isMasked = false;
|
||||
}
|
||||
|
||||
TextElement::getNonPackedRects(m_glyphLayout, desc, stylesCache, context, v);
|
||||
}
|
||||
|
||||
void PathTextElement::map(ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
yg::FontDesc desc = m_fontDesc;
|
||||
|
||||
if (desc.m_isMasked)
|
||||
{
|
||||
TextElement::map(m_glyphLayout, stylesCache, desc);
|
||||
desc.m_isMasked = false;
|
||||
}
|
||||
|
||||
TextElement::map(m_glyphLayout, stylesCache, desc);
|
||||
}
|
||||
|
||||
int PathTextElement::visualRank() const
|
||||
{
|
||||
return 2000 + m_fontDesc.m_size;
|
||||
|
|
|
@ -27,12 +27,6 @@ namespace yg
|
|||
|
||||
void draw(gl::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
bool find(ResourceStyleCache * stylesCache) const;
|
||||
void map(ResourceStyleCache * stylesCache) const;
|
||||
|
||||
int visualRank() const;
|
||||
|
||||
void offset(m2::PointD const & offs);
|
||||
|
|
|
@ -1,152 +0,0 @@
|
|||
#include "../base/SRC_FIRST.hpp"
|
||||
|
||||
#include "resource_style_cache.hpp"
|
||||
#include "text_element.hpp"
|
||||
#include "glyph_cache.hpp"
|
||||
#include "skin_page.hpp"
|
||||
#include "resource_manager.hpp"
|
||||
#include "base_texture.hpp"
|
||||
#include "packets_queue.hpp"
|
||||
#include "internal/opengl.hpp"
|
||||
#include "renderer.hpp"
|
||||
|
||||
#include "../base/thread.hpp"
|
||||
|
||||
namespace yg
|
||||
{
|
||||
|
||||
struct ResourceStyleCacheContext::Impl
|
||||
{
|
||||
/// the following sets are used to see, whether
|
||||
/// in the current InfoLayer::cache process we've already
|
||||
/// caching some resource (glyph, color, penInfo, e.t.c.)
|
||||
/// to avoid caching it twice.
|
||||
/// @{
|
||||
|
||||
typedef set<PenInfo> TPenInfoSet;
|
||||
TPenInfoSet m_penInfoSet;
|
||||
|
||||
typedef set<CircleInfo> TCircleInfoSet;
|
||||
TCircleInfoSet m_circleInfoSet;
|
||||
|
||||
typedef set<Color> TColorSet;
|
||||
TColorSet m_colorSet;
|
||||
|
||||
typedef set<GlyphKey> TGlyphSet;
|
||||
TGlyphSet m_glyphSet;
|
||||
|
||||
/// @}
|
||||
};
|
||||
|
||||
ResourceStyleCacheContext::ResourceStyleCacheContext()
|
||||
{
|
||||
m_impl = new Impl();
|
||||
}
|
||||
|
||||
ResourceStyleCacheContext::~ResourceStyleCacheContext()
|
||||
{
|
||||
delete m_impl;
|
||||
}
|
||||
|
||||
bool ResourceStyleCacheContext::hasColor(Color const & c) const
|
||||
{
|
||||
return m_impl->m_colorSet.count(c);
|
||||
}
|
||||
|
||||
void ResourceStyleCacheContext::addColor(Color const & c)
|
||||
{
|
||||
m_impl->m_colorSet.insert(c);
|
||||
}
|
||||
|
||||
bool ResourceStyleCacheContext::hasPenInfo(PenInfo const & pi) const
|
||||
{
|
||||
return m_impl->m_penInfoSet.count(pi);
|
||||
}
|
||||
|
||||
void ResourceStyleCacheContext::addPenInfo(PenInfo const & pi)
|
||||
{
|
||||
m_impl->m_penInfoSet.insert(pi);
|
||||
}
|
||||
|
||||
bool ResourceStyleCacheContext::hasCircleInfo(CircleInfo const & ci) const
|
||||
{
|
||||
return m_impl->m_circleInfoSet.count(ci);
|
||||
}
|
||||
|
||||
void ResourceStyleCacheContext::addCircleInfo(CircleInfo const & ci)
|
||||
{
|
||||
m_impl->m_circleInfoSet.insert(ci);
|
||||
}
|
||||
|
||||
bool ResourceStyleCacheContext::hasGlyph(GlyphKey const & gk) const
|
||||
{
|
||||
return m_impl->m_glyphSet.count(gk);
|
||||
}
|
||||
|
||||
void ResourceStyleCacheContext::addGlyph(GlyphKey const & gk)
|
||||
{
|
||||
m_impl->m_glyphSet.insert(gk);
|
||||
}
|
||||
|
||||
void ResourceStyleCacheContext::clear()
|
||||
{
|
||||
m_impl->m_circleInfoSet.clear();
|
||||
m_impl->m_colorSet.clear();
|
||||
m_impl->m_glyphSet.clear();
|
||||
m_impl->m_penInfoSet.clear();
|
||||
}
|
||||
ResourceStyleCache::ResourceStyleCache(shared_ptr<ResourceManager> const & rm,
|
||||
int glyphCacheID,
|
||||
yg::gl::PacketsQueue * glQueue)
|
||||
: m_rm(rm),
|
||||
m_glQueue(glQueue)
|
||||
{
|
||||
m_glyphCache = m_rm->glyphCache(glyphCacheID);
|
||||
m_cachePage.reset(new SkinPage());
|
||||
m_cachePage->setTexture(m_rm->styleCacheTextures()->Reserve());
|
||||
}
|
||||
|
||||
ResourceStyleCache::~ResourceStyleCache()
|
||||
{
|
||||
m_rm->styleCacheTextures()->Free(m_cachePage->texture());
|
||||
}
|
||||
|
||||
shared_ptr<SkinPage> const & ResourceStyleCache::cachePage()
|
||||
{
|
||||
return m_cachePage;
|
||||
}
|
||||
|
||||
shared_ptr<ResourceManager> const & ResourceStyleCache::resourceManager()
|
||||
{
|
||||
return m_rm;
|
||||
}
|
||||
|
||||
GlyphCache * ResourceStyleCache::glyphCache()
|
||||
{
|
||||
return m_glyphCache;
|
||||
}
|
||||
|
||||
void ResourceStyleCache::clear()
|
||||
{
|
||||
m_cachePage->clear();
|
||||
}
|
||||
|
||||
void ResourceStyleCache::upload()
|
||||
{
|
||||
// m_cachePage->uploadData(m_glQueue);
|
||||
|
||||
if (m_glQueue)
|
||||
m_glQueue->processPacket(yg::gl::Packet(make_shared_ptr(new yg::gl::Renderer::FinishCommand()), yg::gl::Packet::ECommand));
|
||||
|
||||
/// waiting for upload to complete
|
||||
if (m_glQueue)
|
||||
m_glQueue->completeCommands();
|
||||
else
|
||||
OGLCHECK(glFinish());
|
||||
}
|
||||
|
||||
bool ResourceStyleCache::hasRoom(m2::PointU const * sizes, size_t cnt) const
|
||||
{
|
||||
return m_cachePage->hasRoom(sizes, cnt);
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "../std/shared_ptr.hpp"
|
||||
#include "../std/set.hpp"
|
||||
#include "../geometry/point2d.hpp"
|
||||
|
||||
namespace yg
|
||||
{
|
||||
namespace gl
|
||||
{
|
||||
class PacketsQueue;
|
||||
}
|
||||
|
||||
class StraightTextElement;
|
||||
class PathTextElement;
|
||||
class SkinPage;
|
||||
class GlyphCache;
|
||||
class ResourceManager;
|
||||
struct Color;
|
||||
struct PenInfo;
|
||||
struct CircleInfo;
|
||||
struct GlyphKey;
|
||||
|
||||
class ResourceStyleCacheContext
|
||||
{
|
||||
private:
|
||||
|
||||
struct Impl;
|
||||
Impl * m_impl;
|
||||
|
||||
/// noncopyable
|
||||
ResourceStyleCacheContext(ResourceStyleCacheContext const & src);
|
||||
ResourceStyleCacheContext const & operator=(ResourceStyleCacheContext const & src);
|
||||
|
||||
public:
|
||||
|
||||
ResourceStyleCacheContext();
|
||||
~ResourceStyleCacheContext();
|
||||
|
||||
bool hasColor(Color const & c) const;
|
||||
void addColor(Color const & c);
|
||||
|
||||
bool hasPenInfo(PenInfo const & pi) const;
|
||||
void addPenInfo(PenInfo const & pi);
|
||||
|
||||
bool hasCircleInfo(CircleInfo const & ci) const;
|
||||
void addCircleInfo(CircleInfo const & ci);
|
||||
|
||||
bool hasGlyph(GlyphKey const & gk) const;
|
||||
void addGlyph(GlyphKey const & gk);
|
||||
|
||||
void clear();
|
||||
};
|
||||
|
||||
/// - cache of potentially all yg::ResourceStyle's
|
||||
/// - cache is build on the separate thread (CoverageGenerator thread)
|
||||
/// - it is used to remove texture uploading code from the GUI-thread
|
||||
class ResourceStyleCache
|
||||
{
|
||||
private:
|
||||
|
||||
shared_ptr<ResourceManager> m_rm;
|
||||
GlyphCache * m_glyphCache;
|
||||
yg::gl::PacketsQueue * m_glQueue;
|
||||
|
||||
shared_ptr<SkinPage> m_cachePage;
|
||||
|
||||
public:
|
||||
|
||||
ResourceStyleCache(shared_ptr<ResourceManager> const & rm,
|
||||
int glyphCacheID,
|
||||
yg::gl::PacketsQueue * glQueue);
|
||||
|
||||
~ResourceStyleCache();
|
||||
|
||||
shared_ptr<SkinPage> const & cachePage();
|
||||
|
||||
shared_ptr<ResourceManager> const & resourceManager();
|
||||
|
||||
GlyphCache * glyphCache();
|
||||
|
||||
void upload();
|
||||
void clear();
|
||||
|
||||
bool hasRoom(m2::PointU const * sizes, size_t cnt) const;
|
||||
};
|
||||
}
|
|
@ -290,60 +290,6 @@ namespace yg
|
|||
m_glyphLayouts[i].setPivot(m_glyphLayouts[i].pivot() + offs);
|
||||
}
|
||||
|
||||
void StraightTextElement::map(ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
for (unsigned i = 0; i < m_glyphLayouts.size(); ++i)
|
||||
{
|
||||
if (m_glyphLayouts[i].fontDesc().m_isMasked)
|
||||
TextElement::map(m_glyphLayouts[i], stylesCache, m_glyphLayouts[i].fontDesc());
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < m_glyphLayouts.size(); ++i)
|
||||
{
|
||||
yg::FontDesc fontDesc = m_glyphLayouts[i].fontDesc();
|
||||
fontDesc.m_isMasked = false;
|
||||
TextElement::map(m_glyphLayouts[i], stylesCache, fontDesc);
|
||||
}
|
||||
}
|
||||
|
||||
bool StraightTextElement::find(ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
for (unsigned i = 0; i < m_glyphLayouts.size(); ++i)
|
||||
{
|
||||
if (m_glyphLayouts[i].fontDesc().m_isMasked)
|
||||
if (!TextElement::find(m_glyphLayouts[i], stylesCache, m_glyphLayouts[i].fontDesc()))
|
||||
return false;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < m_glyphLayouts.size(); ++i)
|
||||
{
|
||||
yg::FontDesc fontDesc = m_glyphLayouts[i].fontDesc();
|
||||
fontDesc.m_isMasked = false;
|
||||
if (!TextElement::find(m_glyphLayouts[i], stylesCache, fontDesc))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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, 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, context, v);
|
||||
}
|
||||
}
|
||||
|
||||
int StraightTextElement::visualRank() const
|
||||
{
|
||||
return 1000 + m_fontDesc.m_size;
|
||||
|
|
|
@ -33,12 +33,6 @@ namespace yg
|
|||
|
||||
void draw(gl::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
bool find(ResourceStyleCache * stylesCache) const;
|
||||
void map(ResourceStyleCache * stylesCache) const;
|
||||
|
||||
int visualRank() const;
|
||||
|
||||
void offset(m2::PointD const & offs);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "../base/logging.hpp"
|
||||
|
||||
#include "symbol_element.hpp"
|
||||
#include "resource_style_cache.hpp"
|
||||
#include "resource_style.hpp"
|
||||
#include "overlay_renderer.hpp"
|
||||
#include "skin.hpp"
|
||||
|
@ -86,21 +85,6 @@ namespace yg
|
|||
style->m_pipelineID);
|
||||
}
|
||||
|
||||
void SymbolElement::map(ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
}
|
||||
|
||||
bool SymbolElement::find(ResourceStyleCache * stylesCache) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SymbolElement::getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const
|
||||
{
|
||||
}
|
||||
|
||||
int SymbolElement::visualRank() const
|
||||
{
|
||||
return 0000;
|
||||
|
|
|
@ -35,12 +35,6 @@ namespace yg
|
|||
vector<m2::AnyRectD> const & boundRects() const;
|
||||
void draw(gl::OverlayRenderer * s, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
void map(ResourceStyleCache * stylesCache) const;
|
||||
void getNonPackedRects(ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
bool find(ResourceStyleCache * stylesCache) const;
|
||||
|
||||
uint32_t styleID() const;
|
||||
|
||||
int visualRank() const;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include "screen.hpp"
|
||||
#include "skin.hpp"
|
||||
#include "skin_page.hpp"
|
||||
#include "resource_style_cache.hpp"
|
||||
#include "resource_manager.hpp"
|
||||
#include "overlay_renderer.hpp"
|
||||
#include "resource_style.hpp"
|
||||
|
@ -126,95 +125,4 @@ namespace yg
|
|||
screen->drawGlyph(glyphPt, m2::PointD(0.0, 0.0), glyphAngle, 0, glyphStyle, depth);
|
||||
}
|
||||
}
|
||||
|
||||
void TextElement::map(GlyphLayout const & layout,
|
||||
ResourceStyleCache * stylesCache,
|
||||
FontDesc const & desc) const
|
||||
{
|
||||
if (!desc.IsValid())
|
||||
return;
|
||||
|
||||
shared_ptr<SkinPage> const & skinPage = stylesCache->cachePage();
|
||||
GlyphCache * glyphCache = stylesCache->glyphCache();
|
||||
|
||||
for (unsigned i = layout.firstVisible(); i < layout.lastVisible(); ++i)
|
||||
{
|
||||
GlyphLayoutElem const & elem = layout.entries()[i];
|
||||
|
||||
GlyphKey gk(elem.m_sym,
|
||||
desc.m_size,
|
||||
desc.m_isMasked,
|
||||
desc.m_isMasked ? desc.m_maskColor : desc.m_color);
|
||||
|
||||
bool packed = skinPage->findGlyph(gk) != 0x00FFFFFF;
|
||||
|
||||
if (!packed)
|
||||
{
|
||||
if (skinPage->hasRoom(gk, glyphCache))
|
||||
{
|
||||
skinPage->mapGlyph(gk, glyphCache);
|
||||
packed = true;
|
||||
}
|
||||
}
|
||||
|
||||
CHECK(packed, ("couldn't pack"));
|
||||
}
|
||||
}
|
||||
|
||||
bool TextElement::find(GlyphLayout const & layout, ResourceStyleCache * stylesCache, FontDesc const & desc) const
|
||||
{
|
||||
if (!desc.IsValid())
|
||||
return false;
|
||||
|
||||
shared_ptr<SkinPage> const & skinPage = stylesCache->cachePage();
|
||||
|
||||
for (unsigned i = layout.firstVisible(); i < layout.lastVisible(); ++i)
|
||||
{
|
||||
GlyphLayoutElem const & elem = layout.entries()[i];
|
||||
|
||||
GlyphKey gk(elem.m_sym,
|
||||
desc.m_size,
|
||||
desc.m_isMasked,
|
||||
desc.m_isMasked ? desc.m_maskColor : desc.m_color);
|
||||
|
||||
if (skinPage->findGlyph(gk) == 0x00FFFFFF)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextElement::getNonPackedRects(GlyphLayout const & layout,
|
||||
FontDesc const & desc,
|
||||
ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const
|
||||
{
|
||||
if (!desc.IsValid())
|
||||
return;
|
||||
|
||||
shared_ptr<SkinPage> const & skinPage = stylesCache->cachePage();
|
||||
GlyphCache * glyphCache = stylesCache->glyphCache();
|
||||
|
||||
for (unsigned i = layout.firstVisible(); i < layout.lastVisible(); ++i)
|
||||
{
|
||||
GlyphLayoutElem const & elem = layout.entries()[i];
|
||||
|
||||
GlyphKey gk(elem.m_sym,
|
||||
desc.m_size,
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,26 +44,6 @@ namespace yg
|
|||
bool isBidi() const;
|
||||
bool isAuxBidi() const;
|
||||
|
||||
protected:
|
||||
|
||||
using OverlayElement::map;
|
||||
using OverlayElement::find;
|
||||
using OverlayElement::getNonPackedRects;
|
||||
|
||||
void map(GlyphLayout const & layout,
|
||||
ResourceStyleCache * stylesCache,
|
||||
FontDesc const & desc) const;
|
||||
|
||||
bool find(GlyphLayout const & layout,
|
||||
ResourceStyleCache * stylesCache,
|
||||
FontDesc const & desc) const;
|
||||
|
||||
void getNonPackedRects(GlyphLayout const & layout,
|
||||
FontDesc const & desc,
|
||||
ResourceStyleCache * stylesCache,
|
||||
ResourceStyleCacheContext * context,
|
||||
vector<m2::PointU> & v) const;
|
||||
|
||||
public:
|
||||
|
||||
struct Params : OverlayElement::Params
|
||||
|
|
|
@ -53,7 +53,6 @@ SOURCES += \
|
|||
symbol_element.cpp \
|
||||
overlay_renderer.cpp \
|
||||
render_state_updater.cpp \
|
||||
resource_style_cache.cpp \
|
||||
composite_overlay_element.cpp \
|
||||
path_text_element.cpp \
|
||||
straight_text_element.cpp \
|
||||
|
@ -113,7 +112,6 @@ HEADERS += \
|
|||
symbol_element.hpp \
|
||||
overlay_renderer.hpp \
|
||||
render_state_updater.hpp \
|
||||
resource_style_cache.hpp \
|
||||
composite_overlay_element.hpp \
|
||||
path_text_element.hpp \
|
||||
straight_text_element.hpp \
|
||||
|
|
Loading…
Add table
Reference in a new issue