diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 363c5e239c..7531beefec 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -1302,7 +1302,7 @@ void FrontendRenderer::RenderNavigationOverlayLayer(ScreenBase const & modelView bool FrontendRenderer::HasTransitData() { - return !m_layers[RenderState::TransitMarkLayer].m_renderGroups.empty(); + return m_routeRenderer->HasTransitData(); } void FrontendRenderer::RenderTrafficLayer(ScreenBase const & modelView) diff --git a/drape_frontend/route_renderer.cpp b/drape_frontend/route_renderer.cpp index 38880f61b8..5001c8e228 100644 --- a/drape_frontend/route_renderer.cpp +++ b/drape_frontend/route_renderer.cpp @@ -229,6 +229,14 @@ RouteRenderer::Subroutes::iterator FindSubroute(RouteRenderer::Subroutes & subro return info.m_subrouteId == subrouteId; }); } + +float GetCurrentHalfWidth(df::RouteRenderer::SubrouteInfo const & subrouteInfo) +{ + if (subrouteInfo.m_subroute->m_maxPixelWidth < 0.0f) + return subrouteInfo.m_baseHalfWidth; + + return std::min(subrouteInfo.m_baseHalfWidth, subrouteInfo.m_subroute->m_maxPixelWidth * 0.5f); +} } // namespace RouteRenderer::RouteRenderer(PreviewPointsRequestCallback && previewPointsRequest) @@ -249,7 +257,7 @@ void RouteRenderer::UpdateRoute(ScreenBase const & screen, CacheRouteArrowsCallb double zoom = 0.0; float halfWidth = 0.0; InterpolateByZoom(subrouteInfo.m_subroute, screen, halfWidth, zoom); - subrouteInfo.m_currentHalfWidth = halfWidth; + subrouteInfo.m_baseHalfWidth = halfWidth; if (zoom < kArrowAppearingZoomLevel) { @@ -386,8 +394,9 @@ void RouteRenderer::RenderSubroute(SubrouteInfo const & subrouteInfo, size_t sub return; auto const & subrouteData = subrouteInfo.m_subrouteData[subrouteDataIndex]; + float const currentHalfWidth = GetCurrentHalfWidth(subrouteInfo); - auto const screenHalfWidth = static_cast(subrouteInfo.m_currentHalfWidth * screen.GetScale()); + auto const screenHalfWidth = static_cast(currentHalfWidth * screen.GetScale()); auto dist = static_cast(kInvalidDistance); if (m_followingEnabled) { @@ -408,7 +417,7 @@ void RouteRenderer::RenderSubroute(SubrouteInfo const & subrouteInfo, size_t sub glsl::vec4 const color = glsl::ToVec4(df::GetColorConstant(style.m_color)); uniforms.SetFloatValue("u_color", color.r, color.g, color.b, color.a); - uniforms.SetFloatValue("u_routeParams", subrouteInfo.m_currentHalfWidth, screenHalfWidth, dist, + uniforms.SetFloatValue("u_routeParams", currentHalfWidth, screenHalfWidth, dist, trafficShown ? 1.0f : 0.0f); glsl::vec4 const maskColor = glsl::ToVec4(GetMaskColor(subrouteData->m_subroute->m_routeType, @@ -454,13 +463,14 @@ void RouteRenderer::RenderSubrouteArrows(SubrouteInfo const & subrouteInfo, } dp::GLState const & state = subrouteInfo.m_arrowsData->m_renderProperty.m_state; + float const currentHalfWidth = GetCurrentHalfWidth(subrouteInfo); // Set up shaders and apply common uniforms. dp::UniformValuesStorage uniforms = commonUniforms; math::Matrix mv = screen.GetModelView(subrouteInfo.m_arrowsData->m_pivot, kShapeCoordScalar); uniforms.SetMatrix4x4Value("modelView", mv.m_data); - auto const arrowHalfWidth = static_cast(subrouteInfo.m_currentHalfWidth * kArrowHeightFactor); + auto const arrowHalfWidth = static_cast(currentHalfWidth * kArrowHeightFactor); uniforms.SetFloatValue("u_arrowHalfWidth", arrowHalfWidth); uniforms.SetFloatValue("u_opacity", 1.0f); @@ -493,13 +503,14 @@ void RouteRenderer::RenderSubrouteMarkers(SubrouteInfo const & subrouteInfo, Scr dist = static_cast(m_distanceFromBegin - subrouteInfo.m_subroute->m_baseDistance); dp::GLState const & state = subrouteInfo.m_markersData->m_renderProperty.m_state; + float const currentHalfWidth = GetCurrentHalfWidth(subrouteInfo); // Set up shaders and apply common uniforms. dp::UniformValuesStorage uniforms = commonUniforms; math::Matrix mv = screen.GetModelView(subrouteInfo.m_markersData->m_pivot, kShapeCoordScalar); uniforms.SetMatrix4x4Value("modelView", mv.m_data); - uniforms.SetFloatValue("u_routeParams", subrouteInfo.m_currentHalfWidth, dist); + uniforms.SetFloatValue("u_routeParams", currentHalfWidth, dist); uniforms.SetFloatValue("u_opacity", 1.0f); glsl::vec4 const maskColor = glsl::ToVec4(GetMaskColor(subrouteInfo.m_subroute->m_routeType, @@ -544,20 +555,17 @@ void RouteRenderer::RenderRoute(ScreenBase const & screen, bool trafficShown, ref_ptr mng, dp::UniformValuesStorage const & commonUniforms) { - if (!m_subroutes.empty()) + for (auto const & subroute : m_subroutes) { - for (auto const & subroute : m_subroutes) - { - // Render subroutes. - for (size_t i = 0; i < subroute.m_subrouteData.size(); ++i) - RenderSubroute(subroute, i, screen, trafficShown, mng, commonUniforms); + // Render subroutes. + for (size_t i = 0; i < subroute.m_subrouteData.size(); ++i) + RenderSubroute(subroute, i, screen, trafficShown, mng, commonUniforms); - // Render markers. - RenderSubrouteMarkers(subroute, screen, mng, commonUniforms); + // Render markers. + RenderSubrouteMarkers(subroute, screen, mng, commonUniforms); - // Render arrows. - RenderSubrouteArrows(subroute, screen, mng, commonUniforms); - } + // Render arrows. + RenderSubrouteArrows(subroute, screen, mng, commonUniforms); } // Render preview. @@ -730,4 +738,14 @@ void RouteRenderer::SetSubrouteVisibility(dp::DrapeID id, bool isVisible) else m_hiddenSubroutes.insert(id); } + +bool RouteRenderer::HasTransitData() const +{ + for (auto const & subroute : m_subroutes) + { + if (subroute.m_subroute->m_routeType == RouteType::Transit) + return true; + } + return false; +} } // namespace df diff --git a/drape_frontend/route_renderer.hpp b/drape_frontend/route_renderer.hpp index bf49fd1707..33cd910d43 100644 --- a/drape_frontend/route_renderer.hpp +++ b/drape_frontend/route_renderer.hpp @@ -45,7 +45,7 @@ public: drape_ptr m_arrowsData; std::vector m_arrowBorders; - float m_currentHalfWidth = 0.0f; + float m_baseHalfWidth = 0.0f; drape_ptr m_markersData; }; @@ -87,6 +87,8 @@ public: void SetSubrouteVisibility(dp::DrapeID id, bool isVisible); + bool HasTransitData() const; + private: void RenderSubroute(SubrouteInfo const & subrouteInfo, size_t subrouteDataIndex, ScreenBase const & screen, bool trafficShown, ref_ptr mng, diff --git a/drape_frontend/route_shape.hpp b/drape_frontend/route_shape.hpp index 1523e95140..e1c569119c 100644 --- a/drape_frontend/route_shape.hpp +++ b/drape_frontend/route_shape.hpp @@ -145,6 +145,7 @@ struct Subroute std::vector m_traffic; double m_baseDistance = 0.0; double m_baseDepthIndex = 0.0; + float m_maxPixelWidth = -1.0f; SubrouteStyleType m_styleType = SubrouteStyleType::Single; std::vector m_style; diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index b30a44675c..670e806010 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -497,13 +497,15 @@ void RoutingManager::InsertRoute(Route const & route) { case RouterType::Vehicle: case RouterType::Taxi: - subroute->m_routeType = m_currentRouterType == RouterType::Vehicle ? - df::RouteType::Car : df::RouteType::Taxi; - subroute->AddStyle(df::SubrouteStyle(df::kRouteColor, df::kRouteOutlineColor)); - FillTrafficForRendering(segments, subroute->m_traffic); - FillTurnsDistancesForRendering(segments, subroute->m_baseDistance, - subroute->m_turns); - break; + { + subroute->m_routeType = m_currentRouterType == RouterType::Vehicle ? + df::RouteType::Car : df::RouteType::Taxi; + subroute->AddStyle(df::SubrouteStyle(df::kRouteColor, df::kRouteOutlineColor)); + FillTrafficForRendering(segments, subroute->m_traffic); + FillTurnsDistancesForRendering(segments, subroute->m_baseDistance, + subroute->m_turns); + break; + } case RouterType::Transit: { subroute->m_routeType = df::RouteType::Transit; @@ -517,15 +519,19 @@ void RoutingManager::InsertRoute(Route const & route) break; } case RouterType::Pedestrian: - subroute->m_routeType = df::RouteType::Pedestrian; - subroute->AddStyle(df::SubrouteStyle(df::kRoutePedestrian, df::RoutePattern(4.0, 2.0))); - break; + { + subroute->m_routeType = df::RouteType::Pedestrian; + subroute->AddStyle(df::SubrouteStyle(df::kRoutePedestrian, df::RoutePattern(4.0, 2.0))); + break; + } case RouterType::Bicycle: - subroute->m_routeType = df::RouteType::Bicycle; - subroute->AddStyle(df::SubrouteStyle(df::kRouteBicycle, df::RoutePattern(8.0, 2.0))); - FillTurnsDistancesForRendering(segments, subroute->m_baseDistance, - subroute->m_turns); - break; + { + subroute->m_routeType = df::RouteType::Bicycle; + subroute->AddStyle(df::SubrouteStyle(df::kRouteBicycle, df::RoutePattern(8.0, 2.0))); + FillTurnsDistancesForRendering(segments, subroute->m_baseDistance, + subroute->m_turns); + break; + } default: ASSERT(false, ("Unknown router type")); } @@ -972,19 +978,19 @@ void RoutingManager::SetDrapeEngine(ref_ptr engine, bool is3dAl } m_drapeEngine.SafeCall(&df::DrapeEngine::RequestSymbolsSize, symbols, [this](std::vector const & sizes) - { - GetPlatform().RunTask(Platform::Thread::Gui, [this, sizes]() - { - auto it = kTransitSymbols.begin(); - for (size_t i = 0; i < sizes.size(); i += 3) - { - m_transitSymbolSizes[it->second + "-s"] = sizes[i]; - m_transitSymbolSizes[it->second + "-m"] = sizes[i + 1]; - m_transitSymbolSizes[it->second + "-l"] = sizes[i + 2]; - ++it; - } - }); - }); + { + GetPlatform().RunTask(Platform::Thread::Gui, [this, sizes]() + { + auto it = kTransitSymbols.begin(); + for (size_t i = 0; i < sizes.size(); i += 3) + { + m_transitSymbolSizes[it->second + "-s"] = sizes[i]; + m_transitSymbolSizes[it->second + "-m"] = sizes[i + 1]; + m_transitSymbolSizes[it->second + "-l"] = sizes[i + 2]; + ++it; + } + }); + }); // In case of the engine reinitialization recover route. if (IsRoutingActive()) diff --git a/map/transit/transit_display.cpp b/map/transit/transit_display.cpp index 751ef1492c..45f5452d19 100644 --- a/map/transit/transit_display.cpp +++ b/map/transit/transit_display.cpp @@ -166,6 +166,15 @@ TransitRouteDisplay::TransitRouteDisplay(TransitReadManager & transitReadManager , m_bmManager(bmManager) , m_symbolSizes(transitSymbolSizes) { + float maxSymbolSize = -1.0f; + for (auto const & symbolSize : m_symbolSizes) + { + if (maxSymbolSize < symbolSize.second.x) + maxSymbolSize = symbolSize.second.x; + if (maxSymbolSize < symbolSize.second.y) + maxSymbolSize = symbolSize.second.y; + } + m_maxSubrouteWidth = maxSymbolSize * kGateBgScale / kStopMarkerScale; } TransitRouteInfo const & TransitRouteDisplay::GetRouteInfo() @@ -194,6 +203,7 @@ void TransitRouteDisplay::ProcessSubroute(vector const & segments, std::vector transitMarks; + subroute.m_maxPixelWidth = m_maxSubrouteWidth; subroute.m_styleType = df::SubrouteStyleType::Multiple; subroute.m_style.clear(); subroute.m_style.reserve(segments.size()); diff --git a/map/transit/transit_display.hpp b/map/transit/transit_display.hpp index 12cfb635c9..9e3a4963cb 100644 --- a/map/transit/transit_display.hpp +++ b/map/transit/transit_display.hpp @@ -126,4 +126,5 @@ private: TransitRouteInfo m_routeInfo; int m_subrouteIndex = 0; + float m_maxSubrouteWidth = -1.0f; };