diff --git a/drape/overlay_handle.cpp b/drape/overlay_handle.cpp index 4d622ea5b6..a517e21d4b 100644 --- a/drape/overlay_handle.cpp +++ b/drape/overlay_handle.cpp @@ -26,7 +26,6 @@ OverlayHandle::OverlayHandle(FeatureID const & id, , m_anchor(anchor) , m_priority(priority) , m_isVisible(false) - , m_isValid(true) { } diff --git a/drape/overlay_handle.hpp b/drape/overlay_handle.hpp index cd38cc01f6..e05ff00f24 100644 --- a/drape/overlay_handle.hpp +++ b/drape/overlay_handle.hpp @@ -31,11 +31,9 @@ public: bool IsVisible() const; void SetIsVisible(bool isVisible); - bool IsValid() const { return m_isValid; } - m2::PointD GetPivot(ScreenBase const & screen) const; - virtual void Update(ScreenBase const & /*screen*/) {} + virtual bool Update(ScreenBase const & /*screen*/) { return true; } virtual m2::RectD GetPixelRect(ScreenBase const & screen) const = 0; virtual void GetPixelShape(ScreenBase const & screen, Rects & rects) const = 0; @@ -54,9 +52,6 @@ public: FeatureID const & GetFeatureID() const; double const & GetPriority() const; -protected: - void SetIsValid(bool isValid) { m_isValid = isValid; } - protected: FeatureID const m_id; dp::Anchor const m_anchor; @@ -67,7 +62,6 @@ protected: private: bool m_isVisible; - bool m_isValid; dp::IndexStorage m_indexes; struct LessOffsetNode diff --git a/drape/overlay_tree.cpp b/drape/overlay_tree.cpp index 2b75ade6a8..3c8044961b 100644 --- a/drape/overlay_tree.cpp +++ b/drape/overlay_tree.cpp @@ -25,22 +25,20 @@ void OverlayTree::ForceUpdate() m_frameCounter = -1; } -void OverlayTree::StartOverlayPlacing(ScreenBase const & screen, bool canOverlap) +void OverlayTree::StartOverlayPlacing(ScreenBase const & screen) { ASSERT(IsNeedUpdate(), ()); Clear(); m_traits.m_modelView = screen; - m_canOverlap = canOverlap; } void OverlayTree::Add(ref_ptr handle, bool isTransparent) { ScreenBase const & modelView = GetModelView(); - handle->SetIsVisible(m_canOverlap); - handle->Update(modelView); + handle->SetIsVisible(false); - if (!handle->IsValid()) + if (!handle->Update(modelView)) return; m2::RectD const pixelRect = handle->GetPixelRect(modelView); @@ -92,9 +90,7 @@ void OverlayTree::Select(m2::RectD const & rect, TSelectResult & result) const ScreenBase screen = m_traits.m_modelView; ForEachInRect(rect, [&](detail::OverlayInfo const & info) { - if (info.m_handle->IsValid() && - info.m_handle->IsVisible() && - info.m_handle->GetFeatureID().IsValid()) + if (info.m_handle->IsVisible() && info.m_handle->GetFeatureID().IsValid()) { OverlayHandle::Rects shape; info.m_handle->GetPixelShape(screen, shape); diff --git a/drape/overlay_tree.hpp b/drape/overlay_tree.hpp index 78769a17fd..3c35908d0e 100644 --- a/drape/overlay_tree.hpp +++ b/drape/overlay_tree.hpp @@ -51,7 +51,7 @@ public: bool IsNeedUpdate() const; void ForceUpdate(); - void StartOverlayPlacing(ScreenBase const & screen, bool canOverlap = false); + void StartOverlayPlacing(ScreenBase const & screen); void Add(ref_ptr handle, bool isTransparent); void EndOverlayPlacing(); @@ -62,7 +62,6 @@ private: ScreenBase const & GetModelView() const { return m_traits.m_modelView; } private: - bool m_canOverlap = false; int m_frameCounter = -1; }; diff --git a/drape/render_bucket.cpp b/drape/render_bucket.cpp index b4d0fb0dce..b980a12cd5 100644 --- a/drape/render_bucket.cpp +++ b/drape/render_bucket.cpp @@ -85,17 +85,14 @@ void RenderBucket::Render(ScreenBase const & screen) bool hasIndexMutation = false; for (drape_ptr const & handle : m_overlay) { - if (handle->IsValid()) + if (handle->IndexesRequired() && handle->IsVisible()) { - if (handle->IndexesRequired() && handle->IsVisible()) - { - handle->GetElementIndexes(rfpIndex); - hasIndexMutation = true; - } - - if (handle->HasDynamicAttributes()) - handle->GetAttributeMutation(rfpAttrib, screen); + handle->GetElementIndexes(rfpIndex); + hasIndexMutation = true; } + + if (handle->HasDynamicAttributes()) + handle->GetAttributeMutation(rfpAttrib, screen); } m_buffer->ApplyMutation(hasIndexMutation ? rfpIndex : nullptr, rfpAttrib); diff --git a/drape_frontend/gui/button.cpp b/drape_frontend/gui/button.cpp index 94851eaff2..9619ca04d9 100644 --- a/drape_frontend/gui/button.cpp +++ b/drape_frontend/gui/button.cpp @@ -89,12 +89,12 @@ void ButtonHandle::OnTapEnd() m_isInPressedState = false; } -void ButtonHandle::Update(ScreenBase const & screen) +bool ButtonHandle::Update(ScreenBase const & screen) { glsl::vec4 color = glsl::ToVec4(m_isInPressedState ? dp::Color(0x0, 0x0, 0x0, 0xCC) : dp::Color(0x0, 0x0, 0x0, 0x99)); m_uniforms.SetFloatValue("u_color", color.r, color.g, color.b, color.a); - TBase::Update(screen); + return TBase::Update(screen); } void Button::Draw(Params const & params, ShapeControl & control, ref_ptr texMgr) diff --git a/drape_frontend/gui/button.hpp b/drape_frontend/gui/button.hpp index 029a6d2963..2f7784803c 100644 --- a/drape_frontend/gui/button.hpp +++ b/drape_frontend/gui/button.hpp @@ -17,7 +17,7 @@ public: void OnTapBegin() override; void OnTapEnd() override; - void Update(ScreenBase const & screen) override; + bool Update(ScreenBase const & screen) override; private: bool m_isInPressedState; diff --git a/drape_frontend/gui/compass.cpp b/drape_frontend/gui/compass.cpp index 4d580680df..4b29591119 100644 --- a/drape_frontend/gui/compass.cpp +++ b/drape_frontend/gui/compass.cpp @@ -46,7 +46,7 @@ namespace m_tapHandler(); } - void Update(ScreenBase const & screen) override + bool Update(ScreenBase const & screen) override { float angle = ang::AngleIn2PI(screen.GetAngle()); @@ -76,6 +76,8 @@ namespace if (m_animation.IsFinished()) SetIsVisible(isVisible); + + return true; } private: diff --git a/drape_frontend/gui/copyright_label.cpp b/drape_frontend/gui/copyright_label.cpp index b5703112af..49b2a8bfe9 100644 --- a/drape_frontend/gui/copyright_label.cpp +++ b/drape_frontend/gui/copyright_label.cpp @@ -28,10 +28,10 @@ namespace SetIsVisible(true); } - void Update(ScreenBase const & screen) override + bool Update(ScreenBase const & screen) override { if (!IsVisible()) - return; + return false; TBase::Update(screen); @@ -44,6 +44,8 @@ namespace } m_uniforms.SetFloatValue("u_opacity", m_animation->GetOpacity()); + + return true; } private: diff --git a/drape_frontend/gui/country_status.cpp b/drape_frontend/gui/country_status.cpp index 44e91ae856..a4aa4dd3d5 100644 --- a/drape_frontend/gui/country_status.cpp +++ b/drape_frontend/gui/country_status.cpp @@ -35,10 +35,10 @@ public: m_tapHandler(); } - void Update(ScreenBase const & screen) override + bool Update(ScreenBase const & screen) override { SetIsVisible(DrapeGui::GetCountryStatusHelper().IsVisibleForState(m_state)); - TBase::Update(screen); + return TBase::Update(screen); } private: @@ -57,10 +57,10 @@ public: , m_state(state) {} - void Update(ScreenBase const & screen) override + bool Update(ScreenBase const & screen) override { SetIsVisible(DrapeGui::GetCountryStatusHelper().IsVisibleForState(m_state)); - TBase::Update(screen); + return TBase::Update(screen); } private: @@ -76,14 +76,14 @@ public: : TBase(anchor, m2::PointF::Zero()), m_state(state) {} - void Update(ScreenBase const & screen) override + bool Update(ScreenBase const & screen) override { CountryStatusHelper & helper = DrapeGui::GetCountryStatusHelper(); SetIsVisible(helper.IsVisibleForState(m_state)); if (IsVisible()) SetContent(helper.GetProgressValue()); - TBase::Update(screen); + return TBase::Update(screen); } private: diff --git a/drape_frontend/gui/layer_render.cpp b/drape_frontend/gui/layer_render.cpp index 7ed117f940..af945d8d45 100644 --- a/drape_frontend/gui/layer_render.cpp +++ b/drape_frontend/gui/layer_render.cpp @@ -128,7 +128,7 @@ public: SetIsVisible(true); } - void Update(ScreenBase const & screen) override + bool Update(ScreenBase const & screen) override { int newScale = df::GetDrawTileScale(screen); if (m_scale != newScale) @@ -141,7 +141,7 @@ public: m2::PointF offset(10.0f * vs, 30.0f * vs); SetPivot(glsl::ToVec2(m2::PointF(screen.PixelRect().LeftBottom()) + offset)); - TBase::Update(screen); + return TBase::Update(screen); } private: diff --git a/drape_frontend/gui/ruler.cpp b/drape_frontend/gui/ruler.cpp index 196f163cec..1767d4a7c3 100644 --- a/drape_frontend/gui/ruler.cpp +++ b/drape_frontend/gui/ruler.cpp @@ -55,7 +55,7 @@ public: { } - void Update(ScreenBase const & screen) + bool Update(ScreenBase const & screen) { RulerHelper & helper = DrapeGui::GetRulerHelper(); @@ -89,6 +89,8 @@ public: if (m_animation.IsFinished()) TBase::SetIsVisible(m_isVisibleAtEnd); + + return true; } protected: @@ -137,7 +139,7 @@ public: { } - void Update(ScreenBase const & screen) override + bool Update(ScreenBase const & screen) override { SetIsVisible(DrapeGui::GetRulerHelper().IsVisible(screen)); if (IsVisible() && (DrapeGui::GetRulerHelper().IsTextDirty() || m_firstUpdate)) @@ -146,7 +148,7 @@ public: m_firstUpdate = false; } - TBase::Update(screen); + return TBase::Update(screen); } void SetPivot(glsl::vec2 const & pivot) override diff --git a/drape_frontend/gui/shape.cpp b/drape_frontend/gui/shape.cpp index b61f0be337..0f08d045f6 100644 --- a/drape_frontend/gui/shape.cpp +++ b/drape_frontend/gui/shape.cpp @@ -12,7 +12,7 @@ Handle::Handle(dp::Anchor anchor, const m2::PointF & pivot, const m2::PointF & s { } -void Handle::Update(ScreenBase const & screen) +bool Handle::Update(ScreenBase const & screen) { using namespace glsl; @@ -22,6 +22,8 @@ void Handle::Update(ScreenBase const & screen) value_ptr(transpose(translate(mat4(), vec3(m_pivot, 0.0))))); m_uniforms.SetFloatValue("u_opacity", 1.0); } + + return true; } bool Handle::IndexesRequired() const @@ -42,7 +44,7 @@ void Handle::GetPixelShape(const ScreenBase & screen, dp::OverlayHandle::Rects & bool TappableHandle::IsTapped(m2::RectD const & touchArea) const { - if (!IsVisible() || !IsValid()) + if (!IsVisible()) return false; if (m_anchor == dp::Anchor::Center) @@ -88,7 +90,7 @@ void ShapeRenderer::Render(ScreenBase const & screen, ref_ptrUpdate(screen); - if (!(info.m_handle->IsValid() && info.m_handle->IsVisible())) + if (!info.m_handle->IsVisible()) return; ref_ptr prg = mng->GetProgram(info.m_state.GetProgramIndex()); diff --git a/drape_frontend/gui/shape.hpp b/drape_frontend/gui/shape.hpp index abca255ec1..55db04fc7e 100644 --- a/drape_frontend/gui/shape.hpp +++ b/drape_frontend/gui/shape.hpp @@ -20,7 +20,7 @@ public: dp::UniformValuesStorage const & GetUniforms() const { return m_uniforms; } - void Update(ScreenBase const & screen) override; + bool Update(ScreenBase const & screen) override; virtual bool IsTapped(m2::RectD const & touchArea) const { return false; } virtual void OnTapBegin(){} diff --git a/drape_frontend/path_text_shape.cpp b/drape_frontend/path_text_shape.cpp index c1d5a0dae6..06c8fb8204 100644 --- a/drape_frontend/path_text_shape.cpp +++ b/drape_frontend/path_text_shape.cpp @@ -42,21 +42,13 @@ public: m_normals.resize(4 * m_layout->GetGlyphCount()); } - void Update(ScreenBase const & screen) override + bool Update(ScreenBase const & screen) override { - if (m_layout->CacheDynamicGeometry(m_centerPointIter, screen, m_normals)) - { - SetIsValid(true); - return; - } - - SetIsValid(false); + return m_layout->CacheDynamicGeometry(m_centerPointIter, screen, m_normals); } m2::RectD GetPixelRect(ScreenBase const & screen) const override { - ASSERT(IsValid(), ()); - m2::PointD const pixelPivot(screen.GtoP(m_centerPointIter.m_pos)); m2::RectD result; for (gpu::TextDynamicVertex const & v : m_normals) @@ -67,8 +59,6 @@ public: void GetPixelShape(ScreenBase const & screen, Rects & rects) const override { - ASSERT(IsValid(), ()); - m2::PointD const pixelPivot(screen.GtoP(m_centerPointIter.m_pos)); for (size_t quadIndex = 0; quadIndex < m_normals.size(); quadIndex += 4) { diff --git a/drape_frontend/text_handle.cpp b/drape_frontend/text_handle.cpp index 549e559d21..6e4583fe55 100644 --- a/drape_frontend/text_handle.cpp +++ b/drape_frontend/text_handle.cpp @@ -20,7 +20,6 @@ TextHandle::TextHandle(FeatureID const & id, dp::Anchor anchor, double priority, void TextHandle::GetAttributeMutation(ref_ptr mutator, ScreenBase const & screen) const { - ASSERT(IsValid(), ()); UNUSED_VALUE(screen); bool const isVisible = IsVisible(); diff --git a/drape_head/testing_engine.cpp b/drape_head/testing_engine.cpp index cdf013e221..79f51fae6f 100644 --- a/drape_head/testing_engine.cpp +++ b/drape_head/testing_engine.cpp @@ -404,7 +404,7 @@ void TestingEngine::Draw() vector > & buckets = it->second; dp::OverlayTree tree; - tree.StartOverlayPlacing(m_modelView, true); + tree.StartOverlayPlacing(m_modelView); for (size_t i = 0; i < buckets.size(); ++i) buckets[i]->CollectOverlayHandles(make_ref(&tree), false); for (size_t i = 0; i < buckets.size(); ++i) @@ -662,8 +662,7 @@ void TestingEngine::OnFlushData(dp::GLState const & state, drape_ptrGetOverlayHandlesCount(); ++i) { ref_ptr handle = m_scene[state].back()->GetOverlayHandle(i); - handle->Update(m_modelView); - if (handle->IsValid()) + if (handle->Update(m_modelView)) { m_boundRects.push_back(handle->GetPixelRect(m_modelView)); m_rects.resize(m_rects.size() + 1);