Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
MiddleOutFanRenderStep.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
14
17
18namespace skgpu::graphite {
19
21 : RenderStep("MiddleOutFanRenderStep",
22 evenOdd ? "even-odd" : "winding",
23 Flags::kRequiresMSAA,
24 /*uniforms=*/{{"localToDevice", SkSLType::kFloat4x4}},
27 /*vertexAttrs=*/
31 /*instanceAttrs=*/{}) {}
32
34
36 return R"(
37 float4 devPosition = localToDevice * float4(position, 0.0, 1.0);
38 devPosition.z = depth;
39 stepLocalCoords = position;
40 )";
41}
42
44 const DrawParams& params,
45 skvx::ushort2 ssboIndices) const {
46 // TODO: Have Shape provide a path-like iterator so we don't actually have to convert non
47 // paths to SkPath just to iterate their pts/verbs
48 SkPath path = params.geometry().shape().asPath();
49
50 const int maxTrianglesInFans = std::max(path.countVerbs() - 2, 0);
51
52 float depth = params.order().depthAsFloat();
53
54 DrawWriter::Vertices verts{*writer};
55 verts.reserve(maxTrianglesInFans * 3);
56 for (tess::PathMiddleOutFanIter it(path); !it.done();) {
57 for (auto [p0, p1, p2] : it.nextStack()) {
58 verts.append(3) << p0 << depth << ssboIndices
59 << p1 << depth << ssboIndices
60 << p2 << depth << ssboIndices;
61 }
62 }
63}
64
66 PipelineDataGatherer* gatherer) const {
67 SkDEBUGCODE(UniformExpectationsValidator uev(gatherer, this->uniforms());)
68
69 gatherer->write(params.transform().matrix());
70}
71
72} // namespace skgpu::graphite
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
void writeUniformsAndTextures(const DrawParams &, PipelineDataGatherer *) const override
void writeVertices(DrawWriter *, const DrawParams &, skvx::ushort2 ssboIndices) const override
SkSpan< const Uniform > uniforms() const
Definition Renderer.h:143
const EmbeddedViewParams * params
constexpr DepthStencilSettings kWindingStencilPass
constexpr DepthStencilSettings kEvenOddStencilPass