diff options
author | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2016-02-25 10:47:50 +0300 |
---|---|---|
committer | Sergey Yershov <yershov@corp.mail.ru> | 2016-03-23 16:49:07 +0300 |
commit | 5734a69628c04a7da793b485561fbe87d87e0f12 (patch) | |
tree | ac19fec19e3a7576d81b46552912189f95ae9cec | |
parent | a048a0e94cc5e10621d08fb18d0b8356a7c850a6 (diff) |
Optimized render groups
-rw-r--r-- | drape/overlay_handle.hpp | 4 | ||||
-rwxr-xr-x | drape_frontend/frontend_renderer.cpp | 12 | ||||
-rwxr-xr-x | drape_frontend/render_group.cpp | 55 | ||||
-rwxr-xr-x | drape_frontend/render_group.hpp | 12 | ||||
-rw-r--r-- | drape_frontend/text_handle.cpp | 3 | ||||
-rwxr-xr-x | drape_frontend/tile_key.cpp | 8 | ||||
-rwxr-xr-x | drape_frontend/tile_key.hpp | 3 |
7 files changed, 27 insertions, 70 deletions
diff --git a/drape/overlay_handle.hpp b/drape/overlay_handle.hpp index 1277ab25ae..e26f821e2f 100644 --- a/drape/overlay_handle.hpp +++ b/drape/overlay_handle.hpp @@ -147,8 +147,8 @@ public: string const & debugStr, bool isBillboard = false); - virtual m2::RectD GetPixelRect(ScreenBase const & screen, bool perspective) const override; - virtual void GetPixelShape(ScreenBase const & screen, Rects & rects, bool perspective) const override; + m2::RectD GetPixelRect(ScreenBase const & screen, bool perspective) const override; + void GetPixelShape(ScreenBase const & screen, Rects & rects, bool perspective) const override; #ifdef DEBUG_OVERLAYS_OUTPUT virtual string GetOverlayDebugInfo() override; diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index cd43bb31bd..7412c87097 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -96,7 +96,6 @@ struct RemoveTilePredicate { if (m_predicate(group)) { - group->Disappear(); group->DeleteLater(); m_deletionMark = true; return group->CanBeDeleted(); @@ -735,6 +734,16 @@ void FrontendRenderer::AddToRenderGroup(dp::GLState const & state, RenderLayer::RenderLayerID id = RenderLayer::GetLayerID(state); RenderLayer & layer = m_layers[id]; + for (auto const & g : layer.m_renderGroups) + { + if (!g->IsPendingOnDelete() && g->GetState() == state && g->GetTileKey().EqualStrict(newTile)) + { + g->AddBucket(move(renderBucket)); + layer.m_isDirty = true; + return; + } + } + drape_ptr<RenderGroup> group = make_unique_dp<RenderGroup>(state, newTile); ref_ptr<dp::GpuProgram> program = m_gpuProgramManager->GetProgram(state.GetProgramIndex()); ref_ptr<dp::GpuProgram> program3d = m_gpuProgramManager->GetProgram(state.GetProgram3dIndex()); @@ -742,7 +751,6 @@ void FrontendRenderer::AddToRenderGroup(dp::GLState const & state, group->AddBucket(move(renderBucket)); layer.m_renderGroups.push_back(move(group)); - layer.m_renderGroups.back()->Appear(); layer.m_isDirty = true; } diff --git a/drape_frontend/render_group.cpp b/drape_frontend/render_group.cpp index 8b8765d239..c9f91dcee4 100755 --- a/drape_frontend/render_group.cpp +++ b/drape_frontend/render_group.cpp @@ -65,7 +65,7 @@ void RenderGroup::Update(ScreenBase const & modelView) void RenderGroup::CollectOverlay(ref_ptr<dp::OverlayTree> tree) { - if (CanBeDeleted() || GetOpacity() < 1.0) + if (CanBeDeleted()) return; ASSERT(m_shader != nullptr, ()); @@ -139,54 +139,6 @@ bool RenderGroup::IsLess(RenderGroup const & other) const return m_state < other.m_state; } -void RenderGroup::UpdateAnimation() -{ - double const opactity = GetOpacity(); - m_uniforms.SetFloatValue("u_opacity", opactity); -} - -double RenderGroup::GetOpacity() const -{ - if (m_appearAnimation != nullptr) - return m_appearAnimation->GetOpacity(); - - if (m_disappearAnimation != nullptr) - return m_disappearAnimation->GetOpacity(); - - return 1.0; -} - -bool RenderGroup::IsAnimating() const -{ - if (m_appearAnimation && !m_appearAnimation->IsFinished()) - return true; - - if (m_disappearAnimation && !m_disappearAnimation->IsFinished()) - return true; - - return false; -} - -void RenderGroup::Appear() -{ - // Commented because of perfomance reasons. - //if (IsOverlay()) - //{ - // m_appearAnimation = make_unique<OpacityAnimation>(0.25 /* duration */, 0.0 /* delay */, - // 0.0 /* startOpacity */, 1.0 /* endOpacity */); - //} -} - -void RenderGroup::Disappear() -{ - // Commented because of perfomance reasons. - //if (IsOverlay()) - //{ - // m_disappearAnimation = make_unique<OpacityAnimation>(0.1 /* duration */, 0.1 /* delay */, - // 1.0 /* startOpacity */, 0.0 /* endOpacity */); - //} -} - bool RenderGroup::UpdateFeaturesWaitingStatus(TCheckFeaturesWaiting isFeaturesWaiting, int currentZoom, ref_ptr<dp::OverlayTree> tree) { if (!m_sharedFeaturesWaiting) @@ -230,10 +182,7 @@ bool RenderGroupComparator::operator()(drape_ptr<RenderGroup> const & l, drape_p if (lDepth != rDepth) return lDepth < rDepth; - if (my::AlmostEqualULPs(l->GetOpacity(), r->GetOpacity())) - return lState < rState; - else - return l->GetOpacity() > r->GetOpacity(); + return lState < rState; } if (rCanBeDeleted) diff --git a/drape_frontend/render_group.hpp b/drape_frontend/render_group.hpp index 21eff40c38..bff45dcc25 100755 --- a/drape_frontend/render_group.hpp +++ b/drape_frontend/render_group.hpp @@ -75,7 +75,7 @@ public: bool CanBeDeleted() const { - return IsPendingOnDelete() && !IsAnimating() && !IsSharedFeaturesWaiting(); + return IsPendingOnDelete() && !IsSharedFeaturesWaiting(); } using TCheckFeaturesWaiting = function<bool(m2::RectD const &)>; @@ -83,18 +83,8 @@ public: bool IsLess(RenderGroup const & other) const; - void UpdateAnimation() override; - double GetOpacity() const; - bool IsAnimating() const; - - void Appear(); - void Disappear(); - private: vector<drape_ptr<dp::RenderBucket> > m_renderBuckets; - unique_ptr<OpacityAnimation> m_disappearAnimation; - unique_ptr<OpacityAnimation> m_appearAnimation; - mutable bool m_pendingOnDelete; mutable bool m_sharedFeaturesWaiting; diff --git a/drape_frontend/text_handle.cpp b/drape_frontend/text_handle.cpp index 0c07012f7b..f256158f7f 100644 --- a/drape_frontend/text_handle.cpp +++ b/drape_frontend/text_handle.cpp @@ -68,7 +68,8 @@ bool TextHandle::Update(ScreenBase const & screen) bool TextHandle::IndexesRequired() const { - return true; + // Disable indices usage for text handles. + return false; } void TextHandle::SetForceUpdateNormals(bool forceUpdate) const diff --git a/drape_frontend/tile_key.cpp b/drape_frontend/tile_key.cpp index 5180fd88eb..cd1ff9dc7e 100755 --- a/drape_frontend/tile_key.cpp +++ b/drape_frontend/tile_key.cpp @@ -58,6 +58,14 @@ bool TileKey::LessStrict(TileKey const & other) const return m_x < other.m_x; } +bool TileKey::EqualStrict(TileKey const & other) const +{ + return m_x == other.m_x && + m_y == other.m_y && + m_zoomLevel == other.m_zoomLevel && + m_generation == other.m_generation; +} + m2::RectD TileKey::GetGlobalRect(bool clipByDataMaxZoom) const { int const zoomLevel = clipByDataMaxZoom ? ClipTileZoomByMaxDataZoom(m_zoomLevel) : m_zoomLevel; diff --git a/drape_frontend/tile_key.hpp b/drape_frontend/tile_key.hpp index dff53a75cf..d4245ca600 100755 --- a/drape_frontend/tile_key.hpp +++ b/drape_frontend/tile_key.hpp @@ -17,9 +17,10 @@ struct TileKey bool operator < (TileKey const & other) const; bool operator == (TileKey const & other) const; - // This method implements strict comparison of tile keys. It's necessary to merger of + // This methods implement strict comparison of tile keys. It's necessary to merger of // batches which must not merge batches with different m_generation. bool LessStrict(TileKey const & other) const; + bool EqualStrict(TileKey const & other) const; m2::RectD GetGlobalRect(bool clipByDataMaxZoom = true) const; |