static
| 133 | |
| 134 | // static |
| 135 | drape_ptr<RenderNode> SelectionShapeGenerator::GenerateSelectionMarker(ref_ptr<dp::GraphicsContext> context, |
| 136 | ref_ptr<dp::TextureManager> mng) |
| 137 | { |
| 138 | size_t constexpr kTriangleCount = 40; |
| 139 | size_t constexpr kVertexCount = 3 * kTriangleCount; |
| 140 | auto const etalonSector = static_cast<float>(2.0 * math::pi / kTriangleCount); |
| 141 | |
| 142 | dp::TextureManager::ColorRegion color; |
| 143 | mng->GetColorRegion(df::GetColorConstant(df::kSelectionColor), color); |
| 144 | auto const colorCoord = glsl::ToVec2(color.GetTexRect().Center()); |
| 145 | |
| 146 | buffer_vector<MarkerVertex, kTriangleCount> buffer; |
| 147 | |
| 148 | glsl::vec2 const startNormal(0.0f, 1.0f); |
| 149 | |
| 150 | for (size_t i = 0; i < kTriangleCount + 1; ++i) |
| 151 | { |
| 152 | auto const normal = glsl::rotate(startNormal, i * etalonSector); |
| 153 | auto const nextNormal = glsl::rotate(startNormal, (i + 1) * etalonSector); |
| 154 | |
| 155 | buffer.emplace_back(glsl::vec2(0.0f, 0.0f), colorCoord); |
| 156 | buffer.emplace_back(normal, colorCoord); |
| 157 | buffer.emplace_back(nextNormal, colorCoord); |
| 158 | } |
| 159 | |
| 160 | auto state = CreateRenderState(gpu::Program::Accuracy, DepthLayer::OverlayLayer); |
| 161 | state.SetColorTexture(color.GetTexture()); |
| 162 | state.SetDepthTestEnabled(false); |
| 163 | |
| 164 | drape_ptr<RenderNode> renderNode; |
| 165 | { |
| 166 | dp::Batcher batcher(kTriangleCount * dp::Batcher::IndexPerTriangle, kVertexCount); |
| 167 | batcher.SetBatcherHash(static_cast<uint64_t>(BatcherBucket::Default)); |
| 168 | dp::SessionGuard guard(context, batcher, |
| 169 | [&renderNode](dp::RenderState const & state, drape_ptr<dp::RenderBucket> && b) |
| 170 | { |
| 171 | drape_ptr<dp::RenderBucket> bucket = std::move(b); |
| 172 | ASSERT(bucket->GetOverlayHandlesCount() == 0, ()); |
| 173 | renderNode = make_unique_dp<RenderNode>(state, bucket->MoveBuffer()); |
| 174 | }); |
| 175 | |
| 176 | dp::AttributeProvider provider(1 /* stream count */, kVertexCount); |
| 177 | provider.InitStream(0 /* stream index */, GetMarkerBindingInfo(), make_ref(buffer.data())); |
| 178 | |
| 179 | batcher.InsertTriangleList(context, state, make_ref(&provider), nullptr); |
| 180 | } |
| 181 | return renderNode; |
| 182 | } |
| 183 | |
| 184 | // static |
| 185 | drape_ptr<RenderNode> SelectionShapeGenerator::GenerateTrackSelectionMarker(ref_ptr<dp::GraphicsContext> context, |
nothing calls this directly
no test coverage detected