void TextShape::DrawSubStringOutlined(StraightTextLayout const & layout, dp::FontDecl const & font, glm::vec2 const & baseOffset, ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures, bool isPrimary, bool isOptional) const { gpu::TTextOutlinedStaticVertexBuffer staticBuffer; gpu::TTextDynamicVertexBuffer dynamicBuffer; dp::TextureManager::ColorRegion color, outline; textures->GetColorRegion(font.m_color, color); textures->GetColorRegion(font.m_outlineColor, outline); layout.Cache(glsl::vec4(glsl::ToVec2(m_basePoint), m_params.m_depth, -m_params.m_posZ), baseOffset, color, outline, staticBuffer, dynamicBuffer); dp::GLState state(gpu::TEXT_OUTLINED_PROGRAM, dp::GLState::OverlayLayer); state.SetProgram3dIndex(gpu::TEXT_OUTLINED_BILLBOARD_PROGRAM); ASSERT(color.GetTexture() == outline.GetTexture(), ()); state.SetColorTexture(color.GetTexture()); state.SetMaskTexture(layout.GetMaskTexture()); gpu::TTextDynamicVertexBuffer initialDynBuffer(dynamicBuffer.size()); m2::PointU const & pixelSize = layout.GetPixelSize(); drape_ptr<dp::OverlayHandle> handle = make_unique_dp<StraightTextHandle>(m_params.m_featureID, layout.GetText(), m_params.m_anchor, glsl::ToVec2(m_basePoint), glsl::vec2(pixelSize.x, pixelSize.y), baseOffset, GetOverlayPriority(), textures, isOptional, m_affectedByZoomPriority, move(dynamicBuffer), true); handle->SetPivotZ(m_params.m_posZ); handle->SetOverlayRank(m_hasPOI ? (isPrimary ? dp::OverlayRank1 : dp::OverlayRank2) : dp::OverlayRank0); handle->SetExtendingSize(m_params.m_extendingSize); dp::AttributeProvider provider(2, staticBuffer.size()); provider.InitStream(0, gpu::TextOutlinedStaticVertex::GetBindingInfo(), make_ref(staticBuffer.data())); provider.InitStream(1, gpu::TextDynamicVertex::GetBindingInfo(), make_ref(initialDynBuffer.data())); batcher->InsertListOfStrip(state, make_ref(&provider), move(handle), 4); }
void TextShape::DrawSubString(StraightTextLayout const & layout, df::FontDecl const & font, glsl::vec2 const & baseOffset, dp::RefPointer<dp::Batcher> batcher, dp::RefPointer<dp::TextureManager> textures) const { gpu::TTextStaticVertexBuffer staticBuffer; gpu::TTextDynamicVertexBuffer dynamicBuffer; dp::TextureManager::ColorRegion color, outline; textures->GetColorRegion(font.m_color, color); textures->GetColorRegion(font.m_outlineColor, outline); layout.Cache(glsl::vec3(glsl::ToVec2(m_basePoint), m_params.m_depth), baseOffset, color, outline, staticBuffer, dynamicBuffer); dp::GLState state(gpu::TEXT_PROGRAM, dp::GLState::OverlayLayer); state.SetBlending(dp::Blending(true)); ASSERT(color.GetTexture() == outline.GetTexture(), ()); state.SetColorTexture(color.GetTexture()); state.SetMaskTexture(layout.GetMaskTexture()); m2::PointU const & pixelSize = layout.GetPixelSize(); dp::OverlayHandle * handle = new StraightTextHandle(m_params.m_featureID, m_params.m_anchor, glsl::ToVec2(m_basePoint), glsl::vec2(pixelSize.x, pixelSize.y), baseOffset, m_params.m_depth); dp::AttributeProvider provider(2, staticBuffer.size()); provider.InitStream(0, gpu::TextStaticVertex::GetBindingInfo(), dp::MakeStackRefPointer<void>(staticBuffer.data())); provider.InitStream(1, gpu::TextDynamicVertex::GetBindingInfo(), dp::MakeStackRefPointer<void>(dynamicBuffer.data())); batcher->InsertListOfStrip(state, dp::MakeStackRefPointer(&provider), dp::MovePointer(handle), 4); }
void TextShape::DrawSubStringOutlined(ref_ptr<dp::GraphicsContext> context, StraightTextLayout const & layout, dp::FontDecl const & font, glm::vec2 const & baseOffset, ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures, bool isPrimary, bool isOptional) const { gpu::TTextOutlinedStaticVertexBuffer staticBuffer; gpu::TTextDynamicVertexBuffer dynamicBuffer; dp::TextureManager::ColorRegion color, outline; textures->GetColorRegion(font.m_color, color); textures->GetColorRegion(font.m_outlineColor, outline); auto const finalOffset = layout.GetTextOffset(m_symbolSizes.front(), m_params.m_titleDecl.m_anchor, m_symbolAnchor); layout.CacheDynamicGeometry(finalOffset, dynamicBuffer); layout.CacheStaticGeometry(color, outline, staticBuffer); auto state = CreateRenderState(gpu::Program::TextOutlined, m_params.m_depthLayer); state.SetProgram3d(gpu::Program::TextOutlinedBillboard); state.SetDepthTestEnabled(m_params.m_depthTestEnabled); ASSERT(color.GetTexture() == outline.GetTexture(), ()); state.SetColorTexture(color.GetTexture()); state.SetMaskTexture(layout.GetMaskTexture()); gpu::TTextDynamicVertexBuffer initialDynBuffer(dynamicBuffer.size()); m2::PointF const & pixelSize = layout.GetPixelSize(); auto overlayId = dp::OverlayID(m_params.m_featureID, m_tileCoords, m_textIndex); drape_ptr<StraightTextHandle> handle = make_unique_dp<StraightTextHandle>(overlayId, layout.GetText(), m_params.m_titleDecl.m_anchor, glsl::ToVec2(m_basePoint), glsl::vec2(pixelSize.x, pixelSize.y), finalOffset, GetOverlayPriority(), layout.GetFixedHeight(), textures, isOptional, std::move(dynamicBuffer), m_params.m_minVisibleScale, true); if (m_symbolSizes.size() > 1) handle->SetDynamicSymbolSizes(layout, m_symbolSizes, m_symbolAnchor); handle->SetPivotZ(m_params.m_posZ); ASSERT_LESS(m_params.m_startOverlayRank + 1, dp::OverlayRanksCount, ()); handle->SetOverlayRank(isPrimary ? m_params.m_startOverlayRank : m_params.m_startOverlayRank + 1); handle->SetExtendingSize(m_params.m_extendingSize); if (m_params.m_specialDisplacement == SpecialDisplacement::UserMark || m_params.m_specialDisplacement == SpecialDisplacement::SpecialModeUserMark) { handle->SetSpecialLayerOverlay(true); } dp::AttributeProvider provider(2, static_cast<uint32_t>(staticBuffer.size())); provider.InitStream(0, gpu::TextOutlinedStaticVertex::GetBindingInfo(), make_ref(staticBuffer.data())); provider.InitStream(1, gpu::TextDynamicVertex::GetBindingInfo(), make_ref(initialDynBuffer.data())); batcher->InsertListOfStrip(context, state, make_ref(&provider), std::move(handle), 4); }