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

Method DrawSubStringOutlined

libs/drape_frontend/text_shape.cpp:353–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351}
352
353void TextShape::DrawSubStringOutlined(ref_ptr<dp::GraphicsContext> context, StraightTextLayout const & layout,
354 dp::FontDecl const & font, ref_ptr<dp::Batcher> batcher,
355 ref_ptr<dp::TextureManager> textures, bool isPrimary, bool isOptional) const
356{
357 gpu::TTextOutlinedStaticVertexBuffer staticBuffer;
358 gpu::TTextDynamicVertexBuffer dynamicBuffer;
359
360 dp::TextureManager::ColorRegion color, outline;
361 textures->GetColorRegion(font.m_color, color);
362 textures->GetColorRegion(font.m_outlineColor, outline);
363
364 auto const finalOffset = layout.GetTextOffset(m_symbolSizes.front(), m_params.m_titleDecl.m_anchor, m_symbolAnchor);
365 layout.CacheDynamicGeometry(finalOffset, dynamicBuffer);
366
367 layout.CacheStaticGeometry(color, outline, staticBuffer);
368
369 auto state = CreateRenderState(gpu::Program::TextOutlined, m_params.m_depthLayer);
370 state.SetProgram3d(gpu::Program::TextOutlinedBillboard);
371 state.SetDepthTestEnabled(m_params.m_depthTestEnabled);
372 ASSERT(color.GetTexture() == outline.GetTexture(), ());
373 state.SetColorTexture(color.GetTexture());
374 state.SetMaskTexture(layout.GetMaskTexture());
375
376 gpu::TTextDynamicVertexBuffer initialDynBuffer(dynamicBuffer.size());
377
378 m2::PointF const & pixelSize = layout.GetPixelSize();
379
380 dp::OverlayID overlayId(m_params.m_featureId, m_params.m_markId, m_tileCoords, m_textIndex);
381 drape_ptr<StraightTextHandle> handle = make_unique_dp<StraightTextHandle>(
382 overlayId, layout.GetGlyphs(), m_params.m_titleDecl.m_anchor, glsl::ToVec2(m_basePoint),
383 glsl::vec2(pixelSize.x, pixelSize.y), finalOffset, GetOverlayPriority(), textures, isOptional,
384 std::move(dynamicBuffer), m_params.m_minVisibleScale, true);
385 if (m_symbolSizes.size() > 1)
386 handle->SetDynamicSymbolSizes(layout, m_symbolSizes, m_symbolAnchor);
387 handle->SetPivotZ(m_params.m_posZ);
388
389 ASSERT_LESS(m_params.m_startOverlayRank + 1, dp::OverlayRanksCount, ());
390 handle->SetOverlayRank(isPrimary ? m_params.m_startOverlayRank : m_params.m_startOverlayRank + 1);
391
392 handle->SetExtendingSize(m_params.m_extendingSize);
393 if (m_params.m_specialDisplacement == SpecialDisplacement::UserMark ||
394 m_params.m_specialDisplacement == SpecialDisplacement::SpecialModeUserMark)
395 {
396 handle->SetSpecialLayerOverlay(true);
397 }
398
399 dp::AttributeProvider provider(2, static_cast<uint32_t>(staticBuffer.size()));
400 provider.InitStream(0, gpu::TextOutlinedStaticVertex::GetBindingInfo(), make_ref(staticBuffer.data()));
401 provider.InitStream(1, gpu::TextDynamicVertex::GetBindingInfo(), make_ref(initialDynBuffer.data()));
402 batcher->InsertListOfStrip(context, state, make_ref(&provider), std::move(handle), 4);
403}
404
405// TODO: *Shape classes are concerned with drawing themselves. Its strange they decide/manipulate overlays' priorities
406// in the scene. It seems more logical to set priorities beforehand in the creators of *Shapes and pass on final values

Callers

nothing calls this directly

Calls 15

CreateRenderStateFunction · 0.85
ASSERTFunction · 0.85
ToVec2Function · 0.85
vec2Class · 0.85
GetBindingInfoFunction · 0.85
make_refFunction · 0.85
GetColorRegionMethod · 0.80
GetTextOffsetMethod · 0.80
frontMethod · 0.80
CacheDynamicGeometryMethod · 0.80
CacheStaticGeometryMethod · 0.80
SetProgram3dMethod · 0.80

Tested by

no test coverage detected