forked from organicmaps/organicmaps
DrawRule order optimization.
This commit is contained in:
parent
12956f331b
commit
89ff0a1b92
4 changed files with 34 additions and 6 deletions
|
@ -92,11 +92,19 @@ public:
|
|||
T const * begin() const { return data(); }
|
||||
T const * end() const { return (data() + m_size); }
|
||||
|
||||
T * begin () {return data();}
|
||||
T * end() {return (data() + m_size); }
|
||||
|
||||
T const * data() const
|
||||
{
|
||||
return (m_size > N ? &m_dynamic[0] : m_static.data());
|
||||
}
|
||||
|
||||
T * data()
|
||||
{
|
||||
return (m_size > N ? &m_dynamic[0] : m_static.data());
|
||||
}
|
||||
|
||||
bool empty() const { return m_size == 0; }
|
||||
|
||||
size_t size() const { return m_size; }
|
||||
|
|
|
@ -137,7 +137,7 @@ void DrawerYG::drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition
|
|||
m_pScreen->drawSymbol(pt, id, pos, depth);
|
||||
}
|
||||
|
||||
void DrawerYG::drawPath(vector<m2::PointD> const & pts, di::DrawRule const * rules, size_t count)
|
||||
void DrawerYG::drawPath(vector<vector<m2::PointD> const *> const & pathes, di::DrawRule const * rules, size_t count)
|
||||
{
|
||||
// if any rule needs caching - cache as a whole vector
|
||||
bool flag = false;
|
||||
|
@ -185,9 +185,16 @@ void DrawerYG::drawPath(vector<m2::PointD> const & pts, di::DrawRule const * rul
|
|||
}
|
||||
}
|
||||
|
||||
// draw path with array of rules
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
m_pScreen->drawPath(&pts[0], pts.size(), 0, rules[i].m_rule->GetID(), rules[i].m_depth);
|
||||
// draw every path in order with array of rules.
|
||||
for (size_t i = 0; i < pathes.size(); ++i)
|
||||
{
|
||||
for (size_t j = 0; j < count; ++j)
|
||||
m_pScreen->drawPath(&pathes[i]->at(0), pathes[i]->size(), 0, rules[j].m_rule->GetID(), rules[j].m_depth);
|
||||
}
|
||||
|
||||
/* for (size_t j = 0; j < count; ++j)
|
||||
for (size_t i = 0; i < pathes.size(); ++i)
|
||||
m_pScreen->drawPath(&pathes[i]->at(0), pathes[i]->size(), 0, rules[j].m_rule->GetID(), rules[j].m_depth);*/
|
||||
}
|
||||
|
||||
void DrawerYG::drawArea(vector<m2::PointD> const & pts, rule_ptr_t pRule, int depth)
|
||||
|
@ -302,8 +309,11 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size
|
|||
|
||||
if (!pathRules.empty())
|
||||
{
|
||||
vector<vector<m2::PointD> const *> pathes;
|
||||
for (list<di::PathInfo>::const_iterator i = pInfo->m_pathes.begin(); i != pInfo->m_pathes.end(); ++i)
|
||||
drawPath(i->m_path, pathRules.data(), pathRules.size());
|
||||
pathes.push_back(&i->m_path);
|
||||
|
||||
drawPath(pathes, pathRules.data(), pathRules.size());
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < count; ++i)
|
||||
|
|
|
@ -75,7 +75,7 @@ class DrawerYG
|
|||
protected:
|
||||
void drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth);
|
||||
void drawCircle(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth);
|
||||
void drawPath(vector<m2::PointD> const & pts, di::DrawRule const * rules, size_t count);
|
||||
void drawPath(vector<vector<m2::PointD> const * > const & pathes, di::DrawRule const * rules, size_t count);
|
||||
void drawArea(vector<m2::PointD> const & pts, rule_ptr_t pRule, int depth);
|
||||
|
||||
void drawText(m2::PointD const & pt, string const & name, rule_ptr_t pRule, yg::EPosition pos, int depth);
|
||||
|
|
|
@ -63,6 +63,14 @@ namespace fwork
|
|||
|
||||
namespace
|
||||
{
|
||||
struct less_depth
|
||||
{
|
||||
bool operator() (di::DrawRule const & r1, di::DrawRule const & r2)
|
||||
{
|
||||
return r1.m_depth < r2.m_depth;
|
||||
}
|
||||
};
|
||||
|
||||
struct less_key
|
||||
{
|
||||
bool operator() (drule::Key const & r1, drule::Key const & r2) const
|
||||
|
@ -178,6 +186,8 @@ namespace fwork
|
|||
rules[i] = di::DrawRule(drule::rules().Find(m_keys[i]), depth);
|
||||
}
|
||||
|
||||
sort(rules.begin(), rules.end(), less_depth());
|
||||
|
||||
#ifdef PROFILER_DRAWING
|
||||
m_drawCount += m_keys.size();
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue