From cc0787c79f932987a2db48c863c1b9505f08b15c Mon Sep 17 00:00:00 2001 From: ExMix Date: Wed, 9 Apr 2014 13:48:12 +0300 Subject: [PATCH] [drape] review fix --- drape/glstate.cpp | 34 +++++++--------------------------- drape/glstate.hpp | 14 +++++++------- drape/overlay_tree.cpp | 12 +++++++++++- 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/drape/glstate.cpp b/drape/glstate.cpp index 76a5ed8289..44fead6499 100644 --- a/drape/glstate.cpp +++ b/drape/glstate.cpp @@ -27,7 +27,7 @@ void Blending::Apply() const GLFunctions::glDisable(GLConst::GLBlending); } -bool Blending::operator < (const Blending & other) const +bool Blending::operator < (Blending const & other) const { if (m_isEnabled != other.m_isEnabled) return m_isEnabled < other.m_isEnabled; @@ -39,7 +39,7 @@ bool Blending::operator < (const Blending & other) const return m_blendDstFactor < other.m_blendDstFactor; } -bool Blending::operator == (const Blending & other) const +bool Blending::operator == (Blending const & other) const { return m_isEnabled == other.m_isEnabled && m_blendFunction == other.m_blendFunction && @@ -56,59 +56,39 @@ GLState::GLState(uint32_t gpuProgramIndex, DepthLayer depthLayer) { } -const GLState::DepthLayer &GLState::GetDepthLayer() const -{ - return m_depthLayer; -} - void GLState::SetTextureSet(int32_t textureSet) { m_mask |= TEXTURE_BIT; m_textureSet = textureSet; } -int32_t GLState::GetTextureSet() const -{ - return m_textureSet; -} - bool GLState::HasTextureSet() const { return (m_mask & TEXTURE_BIT) != 0; } -void GLState::SetColor(const Color & c) +void GLState::SetColor(Color const & c) { m_mask |= COLOR_BIT; m_color = c; } -const Color & GLState::GetColor() const -{ - return m_color; -} - bool GLState::HasColor() const { return (m_mask & COLOR_BIT) != 0; } -void GLState::SetBlending(const Blending & blending) +void GLState::SetBlending(Blending const & blending) { m_blending = blending; } -const Blending & GLState::GetBlending() const -{ - return m_blending; -} - int GLState::GetProgramIndex() const { return m_gpuProgramIndex; } -bool GLState::operator<(const GLState & other) const +bool GLState::operator<(GLState const & other) const { if (m_mask != other.m_mask) return m_mask < other.m_mask; @@ -126,13 +106,13 @@ bool GLState::operator<(const GLState & other) const namespace { - void ApplyUniformValue(const UniformValue & value, RefPointer program) + void ApplyUniformValue(UniformValue const & value, RefPointer program) { value.Apply(program); } } -void ApplyUniforms(const UniformValuesStorage & uniforms, RefPointer program) +void ApplyUniforms(UniformValuesStorage const & uniforms, RefPointer program) { uniforms.ForeachValue(bind(&ApplyUniformValue, _1, program)); } diff --git a/drape/glstate.hpp b/drape/glstate.hpp index 5b0f8cb530..192671fb99 100644 --- a/drape/glstate.hpp +++ b/drape/glstate.hpp @@ -31,22 +31,22 @@ public: GLState(uint32_t gpuProgramIndex, DepthLayer depthLayer); - DepthLayer const & GetDepthLayer() const; + DepthLayer const & GetDepthLayer() const { return m_depthLayer; } void SetTextureSet(int32_t textureSet); - int32_t GetTextureSet() const; + int32_t GetTextureSet() const { return m_textureSet; } bool HasTextureSet() const; void SetColor(Color const & c); - Color const & GetColor() const; + Color const & GetColor() const { return m_color; } bool HasColor() const; void SetBlending(Blending const & blending); - const Blending & GetBlending() const; + const Blending & GetBlending() const { return m_blending; } - int GetProgramIndex() const; + int GetProgramIndex() const { return m_gpuProgramIndex; } - bool operator<(const GLState & other) const; + bool operator<(GLState const & other) const; private: uint32_t m_gpuProgramIndex; @@ -58,5 +58,5 @@ private: uint32_t m_mask; }; -void ApplyUniforms(const UniformValuesStorage & uniforms, RefPointer program); +void ApplyUniforms(UniformValuesStorage const & uniforms, RefPointer program); void ApplyState(GLState state, RefPointer program, RefPointer textures); diff --git a/drape/overlay_tree.cpp b/drape/overlay_tree.cpp index b184c5b6b3..351d8f3cc3 100644 --- a/drape/overlay_tree.cpp +++ b/drape/overlay_tree.cpp @@ -14,10 +14,20 @@ void OverlayTree::Add(RefPointer handle) m2::RectD pixelRect = handle->GetPixelRect(m_modelView); find_result_t elements; + /* + * Find elements that already on OverlayTree and it's pixel rect + * intersect with handle pixel rect ("Intersected elements") + */ FindIntersectedFunctor f(pixelRect, elements); m_tree.for_each(f); double inputPriority = handle->GetPriority(); + /* + * In this loop we decide which element must be visible + * If input element "handle" more priority than all "Intersected elements" + * than we remove all "Intersected elements" and insert input element "handle" + * But if some of already inserted elements more priority than we don't insert "handle" + */ for (find_result_t::const_iterator it = elements.begin(); it != elements.end(); ++it) { if (inputPriority < (*it)->m_nodeValue->GetPriority()) @@ -88,7 +98,7 @@ void OverlayTree::FindIntersectedFunctor::operator()(OverlayTree::Node const & n m2::RectD const & r = base_t::m_rect; bool isIntersect = !((node.m_pts[2] <= r.minX()) || (node.m_pts[0] >= r.maxX()) || - (node.m_pts[3] <= r.minY()) || (node.m_pts[1] >= r.maxY())); + (node.m_pts[3] <= r.minY()) || (node.m_pts[1] >= r.maxY())); if (isIntersect) m_intersections.push_back(&node); }