| 23 | {} |
| 24 | |
| 25 | void PathSymbolShape::Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher, |
| 26 | ref_ptr<dp::TextureManager> textures) const |
| 27 | { |
| 28 | dp::TextureManager::SymbolRegion region; |
| 29 | textures->GetSymbolRegion(m_params.m_symbolName, region); |
| 30 | m2::RectF const & rect = region.GetTexRect(); |
| 31 | auto const lt = glsl::ToVec2(rect.LeftTop()); |
| 32 | auto const lb = glsl::ToVec2(rect.LeftBottom()); |
| 33 | auto const rt = glsl::ToVec2(rect.RightTop()); |
| 34 | auto const rb = glsl::ToVec2(rect.RightBottom()); |
| 35 | |
| 36 | m2::PointF const halfPxSize = region.GetPixelSize() * 0.5f; |
| 37 | |
| 38 | gpu::VBUnknownSizeT<gpu::SolidTexturingVertex> buffer; |
| 39 | |
| 40 | m2::Spline::iterator splineIter = m_spline.CreateIterator(); |
| 41 | double pToGScale = 1.0 / m_params.m_baseGtoPScale; |
| 42 | splineIter.Advance(m_params.m_offset * pToGScale); |
| 43 | auto const step = static_cast<float>(m_params.m_step * pToGScale); |
| 44 | |
| 45 | while (!splineIter.BeginAgain()) |
| 46 | { |
| 47 | glsl::vec4 const pivot(glsl::ToVec2(ConvertToLocal(splineIter.m_pos, m_params.m_tileCenter, kShapeCoordScalar)), |
| 48 | m_params.m_depth, 0.0f); |
| 49 | |
| 50 | glsl::vec2 const n = halfPxSize.y * glsl::normalize(glsl::vec2(-splineIter.m_dir.y, splineIter.m_dir.x)); |
| 51 | glsl::vec2 const d = halfPxSize.x * glsl::normalize(glsl::vec2(splineIter.m_dir.x, splineIter.m_dir.y)); |
| 52 | |
| 53 | buffer.emplace_back(pivot, -d - n, lt); |
| 54 | buffer.emplace_back(pivot, -d + n, lb); |
| 55 | buffer.emplace_back(pivot, d - n, rt); |
| 56 | buffer.emplace_back(pivot, d + n, rb); |
| 57 | splineIter.Advance(step); |
| 58 | } |
| 59 | |
| 60 | if (buffer.empty()) |
| 61 | return; |
| 62 | |
| 63 | auto state = CreateRenderState(gpu::Program::PathSymbol, m_params.m_depthLayer); |
| 64 | state.SetColorTexture(region.GetTexture()); |
| 65 | state.SetDepthTestEnabled(m_params.m_depthTestEnabled); |
| 66 | state.SetTextureIndex(region.GetTextureIndex()); |
| 67 | |
| 68 | dp::AttributeProvider provider(1, static_cast<uint32_t>(buffer.size())); |
| 69 | provider.InitStream(0, gpu::SolidTexturingVertex::GetBindingInfo(), make_ref(buffer.data())); |
| 70 | batcher->InsertListOfStrip(context, state, make_ref(&provider), 4); |
| 71 | } |
| 72 | } // namespace df |
nothing calls this directly
no test coverage detected