MCPcopy Create free account
hub / github.com/comaps/comaps / RenderSubroute

Method RenderSubroute

libs/drape_frontend/route_renderer.cpp:428–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426}
427
428void RouteRenderer::RenderSubroute(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
429 SubrouteInfo const & subrouteInfo, size_t subrouteDataIndex,
430 ScreenBase const & screen, bool trafficShown, FrameValues const & frameValues)
431{
432 ASSERT_LESS(subrouteDataIndex, subrouteInfo.m_subrouteData.size(), ());
433 if (subrouteInfo.m_subrouteData[subrouteDataIndex]->m_renderProperty.m_buckets.empty())
434 return;
435
436 // Skip rendering of hidden subroutes.
437 if (m_hiddenSubroutes.find(subrouteInfo.m_subrouteId) != m_hiddenSubroutes.end())
438 return;
439
440 auto const & subrouteData = subrouteInfo.m_subrouteData[subrouteDataIndex];
441 float const currentHalfWidth = GetCurrentHalfWidth(subrouteInfo);
442
443 auto const screenHalfWidth = static_cast<float>(currentHalfWidth * screen.GetScale());
444 auto dist = static_cast<float>(kInvalidDistance);
445 if (m_followingEnabled)
446 {
447 auto const distanceOffset = subrouteInfo.m_subroute->m_baseDistance + subrouteData->m_distanceOffset;
448 dist = static_cast<float>(m_distanceFromBegin - distanceOffset);
449 }
450
451 dp::RenderState const & state = subrouteData->m_renderProperty.m_state;
452 size_t const styleIndex = subrouteData->m_styleIndex;
453 ASSERT_LESS(styleIndex, subrouteInfo.m_subroute->m_style.size(), ());
454 auto const & style = subrouteInfo.m_subroute->m_style[styleIndex];
455
456 // Set up parameters.
457 gpu::RouteProgramParams params;
458 frameValues.SetTo(params);
459 math::Matrix<float, 4, 4> mv = screen.GetModelView(subrouteData->m_pivot, kShapeCoordScalar);
460 params.m_modelView = glsl::make_mat4(mv.m_data);
461 params.m_color = glsl::ToVec4(df::GetColorConstant(style.m_color));
462 params.m_routeParams = glsl::vec4(currentHalfWidth, screenHalfWidth, dist, trafficShown ? 1.0f : 0.0f);
463
464 // Adjust line color depending on route type and subroute distance. After the first stop point
465 // route color is adjusted according to RouteMaskCar, RouteMaskBicycle or RouteMaskPedestrian properties.
466 params.m_maskColor =
467 glsl::ToVec4(GetRouteMaskColor(subrouteData->m_subroute->m_routeType, subrouteData->m_subroute->m_baseDistance));
468 if (style.m_pattern.m_isDashed)
469 {
470 params.m_pattern = glsl::vec2(static_cast<float>(screenHalfWidth * style.m_pattern.m_dashLength),
471 static_cast<float>(screenHalfWidth * style.m_pattern.m_gapLength));
472 }
473 else
474 {
475 params.m_outlineColor = glsl::ToVec4(df::GetColorConstant(style.m_outlineColor));
476 }
477 params.m_fakeBorders =
478 glsl::vec2(subrouteData->m_subroute->m_headFakeDistance, subrouteData->m_subroute->m_tailFakeDistance);
479 params.m_fakeColor = glsl::ToVec4(df::GetColorConstant(kRouteFakeColor));
480 params.m_fakeOutlineColor = glsl::ToVec4(df::GetColorConstant(kRouteFakeOutlineColor));
481
482 ref_ptr<dp::GpuProgram> prg =
483 mng->GetProgram(style.m_pattern.m_isDashed ? gpu::Program::RouteDash : gpu::Program::Route);
484 prg->Bind();
485 dp::ApplyState(context, prg, state);

Callers

nothing calls this directly

Calls 15

GetCurrentHalfWidthFunction · 0.85
ToVec4Function · 0.85
GetColorConstantFunction · 0.85
vec2Class · 0.85
ApplyStateFunction · 0.85
SetToMethod · 0.80
GetModelViewMethod · 0.80
GetParamsSetterMethod · 0.80
GetDrawAsLineMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected