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 CircleShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const { int const TriangleCount = 20; double const etalonSector = (2.0 * math::pi) / static_cast<double>(TriangleCount); dp::TextureManager::ColorRegion region; textures->GetColorRegion(m_params.m_color, region); glsl::vec2 colorPoint(glsl::ToVec2(region.GetTexRect().Center())); buffer_vector<gpu::SolidTexturingVertex, 22> vertexes; vertexes.push_back(gpu::SolidTexturingVertex { glsl::vec4(glsl::ToVec2(m_pt), m_params.m_depth, 0.0f), glsl::vec2(0.0f, 0.0f), colorPoint }); m2::PointD startNormal(0.0f, m_params.m_radius); for (size_t i = 0; i < TriangleCount + 1; ++i) { m2::PointD rotatedNormal = m2::Rotate(startNormal, (i) * etalonSector); vertexes.push_back(gpu::SolidTexturingVertex { glsl::vec4(glsl::ToVec2(m_pt), m_params.m_depth, 0.0f), glsl::ToVec2(rotatedNormal), colorPoint }); } dp::GLState state(gpu::TEXTURING_PROGRAM, dp::GLState::OverlayLayer); state.SetColorTexture(region.GetTexture()); double handleSize = 2 * m_params.m_radius; drape_ptr<dp::OverlayHandle> overlay = make_unique_dp<dp::SquareHandle>(m_params.m_id, dp::Center, m_pt, m2::PointD(handleSize, handleSize), GetOverlayPriority(), ""); dp::AttributeProvider provider(1, TriangleCount + 2); provider.InitStream(0, gpu::SolidTexturingVertex::GetBindingInfo(), make_ref(vertexes.data())); batcher->InsertTriangleFan(state, make_ref(&provider), move(overlay)); }
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); }