#include "drape_frontend/render_state_extension.hpp" #include namespace df { std::array, static_cast(DepthLayer::LayersCount)> kStateExtensions = { make_unique_dp(DepthLayer::GeometryLayer), make_unique_dp(DepthLayer::Geometry3dLayer), make_unique_dp(DepthLayer::UserLineLayer), make_unique_dp(DepthLayer::OverlayLayer), make_unique_dp(DepthLayer::LocalAdsMarkLayer), make_unique_dp(DepthLayer::TransitSchemeLayer), make_unique_dp(DepthLayer::UserMarkLayer), make_unique_dp(DepthLayer::NavigationLayer), make_unique_dp(DepthLayer::RoutingBottomMarkLayer), make_unique_dp(DepthLayer::RoutingMarkLayer), make_unique_dp(DepthLayer::SearchMarkLayer), make_unique_dp(DepthLayer::GuiLayer) }; RenderStateExtension::RenderStateExtension(DepthLayer depthLayer) : m_depthLayer(depthLayer) {} bool RenderStateExtension::Less(ref_ptr other) const { ASSERT(dynamic_cast(other.get()) != nullptr, ()); auto const renderState = static_cast(other.get()); return m_depthLayer < renderState->m_depthLayer; } bool RenderStateExtension::Equal(ref_ptr other) const { ASSERT(dynamic_cast(other.get()) != nullptr, ()); auto const renderState = static_cast(other.get()); return m_depthLayer == renderState->m_depthLayer; } // static ref_ptr RenderStateExtensionFactory::Get(DepthLayer depthLayer) { ASSERT_LESS(static_cast(depthLayer), kStateExtensions.size(), ()); return make_ref(kStateExtensions[static_cast(depthLayer)]); } DepthLayer GetDepthLayer(dp::RenderState const & state) { return state.GetRenderStateExtension()->GetDepthLayer(); } dp::RenderState CreateRenderState(gpu::Program program, DepthLayer depthLayer) { return dp::RenderState(program, RenderStateExtensionFactory::Get(depthLayer)); } } // namespace df