diff --git a/drape/overlay_handle.cpp b/drape/overlay_handle.cpp index 493e5e8676..15c4d3fe45 100644 --- a/drape/overlay_handle.cpp +++ b/drape/overlay_handle.cpp @@ -1,14 +1,10 @@ #include "drape/overlay_handle.hpp" -#include "drape/constants.hpp" - #include "base/macros.hpp" #include "base/internal/message.hpp" -#include "base/logging.hpp" #include -#include #include namespace dp @@ -231,22 +227,23 @@ std::string SquareHandle::GetOverlayDebugInfo() } #endif +/// @param[in] minZoomLevel Minimum visible zoom level (less is better) +/// @param[in] rank Rank of the feature (bigger is better) +/// @param[in] depth Manual priority from styles (bigger is better) uint64_t CalculateOverlayPriority(int minZoomLevel, uint8_t rank, float depth) { - // Overlay priority consider the following: - // - Minimum visible zoom level (the less the better); - // - Manual priority from styles (equals to the depth); - // - Rank of the feature (the more the better); - // [1 byte - zoom][4 bytes - priority][1 byte - rank][2 bytes - 0xFFFF]. - uint8_t const minZoom = 0xFF - static_cast(std::max(minZoomLevel, 0)); + // Even if minZoomLevel < 0 (-1 is not visible), we will get more consistent |minZoom| value (less is worse). + ASSERT_GREATER_OR_EQUAL(minZoomLevel, 0, ()); + uint8_t const minZoom = 0xFF - static_cast(minZoomLevel); - float const kMinDepth = -100000.0f; - float const kMaxDepth = 100000.0f; + float constexpr kMinDepth = -100000.0f; + float constexpr kMaxDepth = 100000.0f; float const d = base::Clamp(depth, kMinDepth, kMaxDepth) - kMinDepth; - auto const priority = static_cast(d); + // Pack into uint64_t priority value (bigger is better). + // [1 byte - zoom][4 bytes - priority][1 byte - rank][2 bytes - 0xFFFF]. return (static_cast(minZoom) << 56) | - (static_cast(priority) << 24) | + (static_cast(d) << 24) | (static_cast(rank) << 16) | static_cast(0xFFFF); } diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 6c6e923d04..9ff3181a23 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -1882,14 +1882,12 @@ void FrontendRenderer::BuildOverlayTree(ScreenBase const & modelView) void FrontendRenderer::PrepareBucket(dp::RenderState const & state, drape_ptr & bucket) { CHECK(m_context != nullptr, ()); - auto program = m_gpuProgramManager->GetProgram(state.GetProgram()); - auto program3d = m_gpuProgramManager->GetProgram(state.GetProgram3d()); - bool const isPerspective = m_userEventStream.GetCurrentScreen().isPerspective(); - if (isPerspective) - program3d->Bind(); - else - program->Bind(); - bucket->GetBuffer()->Build(m_context, isPerspective ? program3d : program); + + auto program = m_gpuProgramManager->GetProgram(m_userEventStream.GetCurrentScreen().isPerspective() ? + state.GetProgram3d() : state.GetProgram()); + + program->Bind(); + bucket->GetBuffer()->Build(m_context, program); } void FrontendRenderer::RenderSingleGroup(ref_ptr context,