diff options
author | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2015-10-30 15:34:17 +0300 |
---|---|---|
committer | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2015-11-30 16:26:54 +0300 |
commit | f3b2c7109ddae38a95c625b80e1b00fa21b5acbe (patch) | |
tree | 8d6e6086976ac88bf5f4717d9d2624052e0360d2 /drape_frontend/rule_drawer.cpp | |
parent | f30b34283d952a35e2757c510b893fdc4e58c3ae (diff) |
Rendering optimizations
Diffstat (limited to 'drape_frontend/rule_drawer.cpp')
-rw-r--r-- | drape_frontend/rule_drawer.cpp | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/drape_frontend/rule_drawer.cpp b/drape_frontend/rule_drawer.cpp index 828212a774..6d5b5ea4d6 100644 --- a/drape_frontend/rule_drawer.cpp +++ b/drape_frontend/rule_drawer.cpp @@ -22,8 +22,15 @@ namespace df { -int const SIMPLIFY_BOTTOM = 10; -int const SIMPLIFY_TOP = 12; +int const kLineSimplifyLevelStart = 10; +int const kLineSimplifyLevelEnd = 12; + +size_t kMinFlushSizes[df::PrioritiesCount] = +{ + 1, // AreaPriority + 5, // TextAndPoiPriority + 10, // LinePriority +}; RuleDrawer::RuleDrawer(TDrawerCallback const & fn, ref_ptr<EngineContext> context) : m_callback(fn) @@ -35,6 +42,25 @@ RuleDrawer::RuleDrawer(TDrawerCallback const & fn, ref_ptr<EngineContext> contex m_geometryConvertor.OnSize(0, 0, tileSize, tileSize); m_geometryConvertor.SetFromRect(m2::AnyRectD(m_globalRect)); m_currentScaleGtoP = 1.0f / m_geometryConvertor.GetScale(); + + for (size_t i = 0; i < m_mapShapes.size(); i++) + m_mapShapes[i].reserve(kMinFlushSizes[i] + 1); +} + +RuleDrawer::~RuleDrawer() +{ + for (size_t i = 0; i < m_mapShapes.size(); i++) + { + if (!m_mapShapes[i].empty()) + { + for (auto const & shape : m_mapShapes[i]) + shape->Prepare(m_context->GetTextureManager()); + + vector<drape_ptr<MapShape>> mapShapes; + mapShapes.swap(m_mapShapes[i]); + m_context->Flush(move(mapShapes)); + } + } } void RuleDrawer::operator()(FeatureType const & f) @@ -62,7 +88,9 @@ void RuleDrawer::operator()(FeatureType const & f) auto insertShape = [this](drape_ptr<MapShape> && shape) { - m_mapShapes.push_back(move(shape)); + int const index = static_cast<int>(shape->GetPriority()); + ASSERT_LESS(index, m_mapShapes.size(), ()); + m_mapShapes[index].push_back(move(shape)); }; if (s.AreaStyleExists()) @@ -79,7 +107,8 @@ void RuleDrawer::operator()(FeatureType const & f) else if (s.LineStyleExists()) { ApplyLineFeature apply(insertShape, f.GetID(), s.GetCaptionDescription(), m_currentScaleGtoP, - zoomLevel >= SIMPLIFY_BOTTOM && zoomLevel <= SIMPLIFY_TOP, f.GetPointsCount()); + zoomLevel >= kLineSimplifyLevelStart && zoomLevel <= kLineSimplifyLevelEnd, + f.GetPointsCount()); f.ForEachPointRef(apply, zoomLevel); if (apply.HasGeometry()) @@ -129,10 +158,18 @@ void RuleDrawer::operator()(FeatureType const & f) insertShape(make_unique_dp<TextShape>(r.Center(), tp)); #endif - for (auto & shape : m_mapShapes) - shape->Prepare(m_context->GetTextureManager()); - - m_context->Flush(move(m_mapShapes)); + for (size_t i = 0; i < m_mapShapes.size(); i++) + { + if (m_mapShapes[i].size() >= kMinFlushSizes[i]) + { + for (auto const & shape : m_mapShapes[i]) + shape->Prepare(m_context->GetTextureManager()); + + vector<drape_ptr<MapShape>> mapShapes; + mapShapes.swap(m_mapShapes[i]); + m_context->Flush(move(mapShapes)); + } + } } } // namespace df |