blob: 376eaf29f5f247e8120ad5f36d6d5b0463a378bb [file] [log] [blame]
Chris Daltonebb37e72021-01-27 17:59:45 -07001/*
2 * Copyright 2019 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
8#include "src/gpu/tessellate/GrPathInnerTriangulateOp.h"
9
10#include "src/gpu/GrEagerVertexAllocator.h"
Chris Daltond9bdc322021-06-01 19:22:05 -060011#include "src/gpu/GrGpu.h"
Chris Daltonebb37e72021-01-27 17:59:45 -070012#include "src/gpu/GrInnerFanTriangulator.h"
13#include "src/gpu/GrOpFlushState.h"
14#include "src/gpu/GrRecordingContextPriv.h"
Chris Daltona05ccc32021-06-29 19:42:13 -060015#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
Chris Dalton2f733ec2021-06-01 12:11:57 -060016#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
Chris Daltond9bdc322021-06-01 19:22:05 -060017#include "src/gpu/tessellate/GrPathCurveTessellator.h"
Chris Daltonebb37e72021-01-27 17:59:45 -070018#include "src/gpu/tessellate/GrTessellationPathRenderer.h"
Chris Dalton3b412782021-06-01 13:40:03 -060019#include "src/gpu/tessellate/shaders/GrPathTessellationShader.h"
Chris Daltonebb37e72021-01-27 17:59:45 -070020
Chris Dalton917f9192021-06-08 14:32:37 -060021using PathFlags = GrTessellationPathRenderer::PathFlags;
Chris Daltonebb37e72021-01-27 17:59:45 -070022
Chris Dalton2f733ec2021-06-01 12:11:57 -060023namespace {
24
25// Fills an array of convex hulls surrounding 4-point cubic or conic instances. This shader is used
Chris Dalton031d76b2021-06-08 16:32:00 -060026// for the "cover" pass after the curves have been fully stencilled.
Chris Dalton2f733ec2021-06-01 12:11:57 -060027class HullShader : public GrPathTessellationShader {
28public:
Chris Daltona05ccc32021-06-29 19:42:13 -060029 HullShader(const SkMatrix& viewMatrix, SkPMColor4f color, const GrShaderCaps& shaderCaps)
Chris Dalton2f733ec2021-06-01 12:11:57 -060030 : GrPathTessellationShader(kTessellate_HullShader_ClassID,
31 GrPrimitiveType::kTriangleStrip, 0, viewMatrix, color) {
32 constexpr static Attribute kPtsAttribs[] = {
33 {"input_points_0_1", kFloat4_GrVertexAttribType, kFloat4_GrSLType},
34 {"input_points_2_3", kFloat4_GrVertexAttribType, kFloat4_GrSLType}};
35 this->setInstanceAttributes(kPtsAttribs, SK_ARRAY_COUNT(kPtsAttribs));
Chris Daltona05ccc32021-06-29 19:42:13 -060036 if (!shaderCaps.vertexIDSupport()) {
37 constexpr static Attribute kVertexIdxAttrib("vertexidx", kFloat_GrVertexAttribType,
38 kFloat_GrSLType);
39 this->setVertexAttributes(&kVertexIdxAttrib, 1);
40 }
Chris Dalton2f733ec2021-06-01 12:11:57 -060041 }
42
43private:
Chris Daltonb63711a2021-06-01 14:52:02 -060044 const char* name() const final { return "tessellate_HullShader"; }
Chris Dalton2f733ec2021-06-01 12:11:57 -060045 void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
46 GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
47};
48
49GrGLSLGeometryProcessor* HullShader::createGLSLInstance(const GrShaderCaps&) const {
50 class Impl : public GrPathTessellationShader::Impl {
Chris Daltond2b8ba32021-06-09 00:12:59 -060051 void emitVertexCode(const GrPathTessellationShader&, GrGLSLVertexBuilder* v,
52 GrGPArgs* gpArgs) override {
Chris Dalton2f733ec2021-06-01 12:11:57 -060053 v->codeAppend(R"(
54 float4x2 P = float4x2(input_points_0_1, input_points_2_3);
55 if (isinf(P[3].y)) { // Is the curve a conic?
56 float w = P[3].x;
57 if (isinf(w)) {
58 // A conic with w=Inf is an exact triangle.
59 P = float4x2(P[0], P[1], P[2], P[2]);
60 } else {
61 // Convert the points to a trapeziodal hull that circumcscribes the conic.
62 float2 p1w = P[1] * w;
63 float T = .51; // Bias outward a bit to ensure we cover the outermost samples.
64 float2 c1 = mix(P[0], p1w, T);
65 float2 c2 = mix(P[2], p1w, T);
66 float iw = 1 / mix(1, w, T);
67 P = float4x2(P[0], c1 * iw, c2 * iw, P[2]);
68 }
69 }
70
71 // Translate the points to v0..3 where v0=0.
72 float2 v1 = P[1] - P[0], v2 = P[2] - P[0], v3 = P[3] - P[0];
73
74 // Reorder the points so v2 bisects v1 and v3.
75 if (sign(determinant(float2x2(v2,v1))) == sign(determinant(float2x2(v2,v3)))) {
76 float2 tmp = P[2];
77 if (sign(determinant(float2x2(v1,v2))) != sign(determinant(float2x2(v1,v3)))) {
78 P[2] = P[1]; // swap(P2, P1)
79 P[1] = tmp;
80 } else {
81 P[2] = P[3]; // swap(P2, P3)
82 P[3] = tmp;
83 }
Chris Daltona05ccc32021-06-29 19:42:13 -060084 })");
85
86 if (v->getProgramBuilder()->caps()->shaderCaps()->vertexIDSupport()) {
87 // If we don't have sk_VertexID support then "vertexidx" already came in as a
88 // vertex attrib.
89 v->codeAppend(R"(
90 // sk_VertexID comes in fan order. Convert to strip order.
91 int vertexidx = sk_VertexID;
92 vertexidx ^= vertexidx >> 1;)");
Chris Dalton2f733ec2021-06-01 12:11:57 -060093 }
94
Chris Daltona05ccc32021-06-29 19:42:13 -060095 v->codeAppend(R"(
Chris Dalton2f733ec2021-06-01 12:11:57 -060096 // Find the "turn direction" of each corner and net turn direction.
97 float vertexdir = 0;
98 float netdir = 0;
Chris Daltona05ccc32021-06-29 19:42:13 -060099 float2 prev, next;
100 float dir;
101 float2 localcoord;
102 float2 nextcoord;)");
103
Chris Dalton2f733ec2021-06-01 12:11:57 -0600104 for (int i = 0; i < 4; ++i) {
Chris Daltona05ccc32021-06-29 19:42:13 -0600105 v->codeAppendf(R"(
106 prev = P[%i] - P[%i];)", i, (i + 3) % 4);
107 v->codeAppendf(R"(
108 next = P[%i] - P[%i];)", (i + 1) % 4, i);
109 v->codeAppendf(R"(
110 dir = sign(determinant(float2x2(prev, next)));
111 if (vertexidx == %i) {
Chris Dalton2f733ec2021-06-01 12:11:57 -0600112 vertexdir = dir;
Chris Daltona05ccc32021-06-29 19:42:13 -0600113 localcoord = P[%i];
114 nextcoord = P[%i];
Chris Dalton2f733ec2021-06-01 12:11:57 -0600115 }
Chris Daltona05ccc32021-06-29 19:42:13 -0600116 netdir += dir;)", i, i, (i + 1) % 4);
Chris Dalton2f733ec2021-06-01 12:11:57 -0600117 }
118
Chris Daltona05ccc32021-06-29 19:42:13 -0600119 v->codeAppend(R"(
Chris Dalton2f733ec2021-06-01 12:11:57 -0600120 // Remove the non-convex vertex, if any.
121 if (vertexdir != sign(netdir)) {
Chris Daltona05ccc32021-06-29 19:42:13 -0600122 localcoord = nextcoord;
Chris Dalton2f733ec2021-06-01 12:11:57 -0600123 }
124
Chris Dalton2f733ec2021-06-01 12:11:57 -0600125 float2 vertexpos = AFFINE_MATRIX * localcoord + TRANSLATE;)");
126 gpArgs->fLocalCoordVar.set(kFloat2_GrSLType, "localcoord");
127 gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertexpos");
128 }
129 };
130 return new Impl;
131}
132
133} // namespace
134
Robert Phillips294723d2021-06-17 09:23:58 -0400135void GrPathInnerTriangulateOp::visitProxies(const GrVisitProxyFunc& func) const {
Chris Daltonebb37e72021-01-27 17:59:45 -0700136 if (fPipelineForFills) {
Robert Phillips294723d2021-06-17 09:23:58 -0400137 fPipelineForFills->visitProxies(func);
Chris Daltonebb37e72021-01-27 17:59:45 -0700138 } else {
Robert Phillips294723d2021-06-17 09:23:58 -0400139 fProcessors.visitProxies(func);
Chris Daltonebb37e72021-01-27 17:59:45 -0700140 }
141}
142
143GrDrawOp::FixedFunctionFlags GrPathInnerTriangulateOp::fixedFunctionFlags() const {
144 auto flags = FixedFunctionFlags::kUsesStencil;
145 if (GrAAType::kNone != fAAType) {
146 flags |= FixedFunctionFlags::kUsesHWAA;
147 }
148 return flags;
149}
150
151GrProcessorSet::Analysis GrPathInnerTriangulateOp::finalize(const GrCaps& caps,
152 const GrAppliedClip* clip,
Chris Daltonebb37e72021-01-27 17:59:45 -0700153 GrClampType clampType) {
Chris Dalton57ab06c2021-04-22 12:57:28 -0600154 return fProcessors.finalize(fColor, GrProcessorAnalysisCoverage::kNone, clip, nullptr, caps,
155 clampType, &fColor);
Chris Daltonebb37e72021-01-27 17:59:45 -0700156}
157
Chris Dalton2f733ec2021-06-01 12:11:57 -0600158void GrPathInnerTriangulateOp::pushFanStencilProgram(const GrTessellationShader::ProgramArgs& args,
Chris Daltonebb37e72021-01-27 17:59:45 -0700159 const GrPipeline* pipelineForStencils,
160 const GrUserStencilSettings* stencil) {
161 SkASSERT(pipelineForStencils);
Chris Daltonb63711a2021-06-01 14:52:02 -0600162 auto shader = GrPathTessellationShader::MakeSimpleTriangleShader(args.fArena, fViewMatrix,
163 SK_PMColor4fTRANSPARENT);
Chris Dalton2f733ec2021-06-01 12:11:57 -0600164 fFanPrograms.push_back(GrTessellationShader::MakeProgram(args, shader, pipelineForStencils,
165 stencil)); }
Chris Daltonebb37e72021-01-27 17:59:45 -0700166
Chris Dalton2f733ec2021-06-01 12:11:57 -0600167void GrPathInnerTriangulateOp::pushFanFillProgram(const GrTessellationShader::ProgramArgs& args,
Chris Daltonebb37e72021-01-27 17:59:45 -0700168 const GrUserStencilSettings* stencil) {
169 SkASSERT(fPipelineForFills);
Chris Daltonb63711a2021-06-01 14:52:02 -0600170 auto shader = GrPathTessellationShader::MakeSimpleTriangleShader(args.fArena, fViewMatrix,
171 fColor);
Chris Dalton2f733ec2021-06-01 12:11:57 -0600172 fFanPrograms.push_back(GrTessellationShader::MakeProgram(args, shader, fPipelineForFills,
173 stencil));
Chris Daltonebb37e72021-01-27 17:59:45 -0700174}
175
Chris Dalton2f733ec2021-06-01 12:11:57 -0600176void GrPathInnerTriangulateOp::prePreparePrograms(const GrTessellationShader::ProgramArgs& args,
Chris Daltonebb37e72021-01-27 17:59:45 -0700177 GrAppliedClip&& appliedClip) {
178 SkASSERT(!fFanTriangulator);
179 SkASSERT(!fFanPolys);
180 SkASSERT(!fPipelineForFills);
181 SkASSERT(!fTessellator);
182 SkASSERT(!fStencilCurvesProgram);
183 SkASSERT(fFanPrograms.empty());
Chris Dalton031d76b2021-06-08 16:32:00 -0600184 SkASSERT(!fCoverHullsProgram);
Chris Daltonebb37e72021-01-27 17:59:45 -0700185
186 if (fPath.countVerbs() <= 0) {
187 return;
188 }
189
Chris Dalton031d76b2021-06-08 16:32:00 -0600190 // If using wireframe, we have to fall back on a standard Redbook "stencil then cover" algorithm
Chris Dalton57ab06c2021-04-22 12:57:28 -0600191 // instead of bypassing the stencil buffer to fill the fan directly.
Chris Dalton917f9192021-06-08 14:32:37 -0600192 bool forceRedbookStencilPass = (fPathFlags & (PathFlags::kStencilOnly | PathFlags::kWireframe));
193 bool doFill = !(fPathFlags & PathFlags::kStencilOnly);
Chris Daltonebb37e72021-01-27 17:59:45 -0700194
195 bool isLinear;
196 fFanTriangulator = args.fArena->make<GrInnerFanTriangulator>(fPath, args.fArena);
197 fFanPolys = fFanTriangulator->pathToPolys(&fFanBreadcrumbs, &isLinear);
198
199 // Create a pipeline for stencil passes if needed.
200 const GrPipeline* pipelineForStencils = nullptr;
201 if (forceRedbookStencilPass || !isLinear) { // Curves always get stencilled.
Chris Dalton2f733ec2021-06-01 12:11:57 -0600202 pipelineForStencils = GrPathTessellationShader::MakeStencilOnlyPipeline(
Chris Dalton917f9192021-06-08 14:32:37 -0600203 args, fAAType, fPathFlags, appliedClip.hardClip());
Chris Daltonebb37e72021-01-27 17:59:45 -0700204 }
205
206 // Create a pipeline for fill passes if needed.
207 if (doFill) {
Chris Dalton2f733ec2021-06-01 12:11:57 -0600208 fPipelineForFills = GrTessellationShader::MakePipeline(args, fAAType,
209 std::move(appliedClip),
210 std::move(fProcessors));
Chris Daltonebb37e72021-01-27 17:59:45 -0700211 }
212
213 // Pass 1: Tessellate the outer curves into the stencil buffer.
214 if (!isLinear) {
Chris Dalton26666bd2021-06-08 16:25:46 -0600215 fTessellator = GrPathCurveTessellator::Make(args.fArena, fViewMatrix,
216 SK_PMColor4fTRANSPARENT,
Chris Daltond2b8ba32021-06-09 00:12:59 -0600217 GrPathCurveTessellator::DrawInnerFan::kNo,
Chris Dalton198ac152021-06-09 13:49:43 -0600218 fPath.countVerbs(), *pipelineForStencils,
219 *args.fCaps);
Chris Dalton2f733ec2021-06-01 12:11:57 -0600220 const GrUserStencilSettings* stencilPathSettings =
Chris Daltonbaae2dd2021-06-25 14:52:49 -0600221 GrPathTessellationShader::StencilPathSettings(GrFillRuleForSkPath(fPath));
Chris Dalton2f733ec2021-06-01 12:11:57 -0600222 fStencilCurvesProgram = GrTessellationShader::MakeProgram(args, fTessellator->shader(),
223 pipelineForStencils,
224 stencilPathSettings);
Chris Daltonebb37e72021-01-27 17:59:45 -0700225 }
226
227 // Pass 2: Fill the path's inner fan with a stencil test against the curves.
228 if (fFanPolys) {
229 if (forceRedbookStencilPass) {
Chris Dalton031d76b2021-06-08 16:32:00 -0600230 // Use a standard Redbook "stencil then cover" algorithm instead of bypassing the
231 // stencil buffer to fill the fan directly.
Chris Dalton2f733ec2021-06-01 12:11:57 -0600232 const GrUserStencilSettings* stencilPathSettings =
Chris Daltonbaae2dd2021-06-25 14:52:49 -0600233 GrPathTessellationShader::StencilPathSettings(GrFillRuleForSkPath(fPath));
Chris Dalton2f733ec2021-06-01 12:11:57 -0600234 this->pushFanStencilProgram(args, pipelineForStencils, stencilPathSettings);
Chris Daltonebb37e72021-01-27 17:59:45 -0700235 if (doFill) {
Chris Dalton2f733ec2021-06-01 12:11:57 -0600236 this->pushFanFillProgram(args,
237 GrPathTessellationShader::TestAndResetStencilSettings());
Chris Daltonebb37e72021-01-27 17:59:45 -0700238 }
239 } else if (isLinear) {
240 // There are no outer curves! Ignore stencil and fill the path directly.
241 SkASSERT(!pipelineForStencils);
242 this->pushFanFillProgram(args, &GrUserStencilSettings::kUnused);
243 } else if (!fPipelineForFills->hasStencilClip()) {
244 // These are a twist on the standard Redbook stencil settings that allow us to fill the
245 // inner polygon directly to the final render target. By the time these programs
246 // execute, the outer curves will already be stencilled in. So if the stencil value is
247 // zero, then it means the sample in question is not affected by any curves and we can
248 // fill it in directly. If the stencil value is nonzero, then we don't fill and instead
249 // continue the standard Redbook counting process.
250 constexpr static GrUserStencilSettings kFillOrIncrDecrStencil(
251 GrUserStencilSettings::StaticInitSeparate<
252 0x0000, 0x0000,
253 GrUserStencilTest::kEqual, GrUserStencilTest::kEqual,
254 0xffff, 0xffff,
255 GrUserStencilOp::kKeep, GrUserStencilOp::kKeep,
256 GrUserStencilOp::kIncWrap, GrUserStencilOp::kDecWrap,
257 0xffff, 0xffff>());
258
259 constexpr static GrUserStencilSettings kFillOrInvertStencil(
260 GrUserStencilSettings::StaticInit<
261 0x0000,
262 GrUserStencilTest::kEqual,
263 0xffff,
264 GrUserStencilOp::kKeep,
265 // "Zero" instead of "Invert" because the fan only touches any given pixel once.
266 GrUserStencilOp::kZero,
267 0xffff>());
268
269 auto* stencil = (fPath.getFillType() == SkPathFillType::kWinding)
270 ? &kFillOrIncrDecrStencil
271 : &kFillOrInvertStencil;
272 this->pushFanFillProgram(args, stencil);
273 } else {
274 // This is the same idea as above, but we use two passes instead of one because there is
275 // a stencil clip. The stencil test isn't expressive enough to do the above tests and
276 // also check the clip bit in a single pass.
277 constexpr static GrUserStencilSettings kFillIfZeroAndInClip(
278 GrUserStencilSettings::StaticInit<
279 0x0000,
280 GrUserStencilTest::kEqualIfInClip,
281 0xffff,
282 GrUserStencilOp::kKeep,
283 GrUserStencilOp::kKeep,
284 0xffff>());
285
286 constexpr static GrUserStencilSettings kIncrDecrStencilIfNonzero(
287 GrUserStencilSettings::StaticInitSeparate<
288 0x0000, 0x0000,
289 // No need to check the clip because the previous stencil pass will have only
290 // written to samples already inside the clip.
291 GrUserStencilTest::kNotEqual, GrUserStencilTest::kNotEqual,
292 0xffff, 0xffff,
293 GrUserStencilOp::kIncWrap, GrUserStencilOp::kDecWrap,
294 GrUserStencilOp::kKeep, GrUserStencilOp::kKeep,
295 0xffff, 0xffff>());
296
297 constexpr static GrUserStencilSettings kInvertStencilIfNonZero(
298 GrUserStencilSettings::StaticInit<
299 0x0000,
300 // No need to check the clip because the previous stencil pass will have only
301 // written to samples already inside the clip.
302 GrUserStencilTest::kNotEqual,
303 0xffff,
304 // "Zero" instead of "Invert" because the fan only touches any given pixel once.
305 GrUserStencilOp::kZero,
306 GrUserStencilOp::kKeep,
307 0xffff>());
308
309 // Pass 2a: Directly fill fan samples whose stencil values (from curves) are zero.
310 this->pushFanFillProgram(args, &kFillIfZeroAndInClip);
311
312 // Pass 2b: Redbook counting on fan samples whose stencil values (from curves) != 0.
313 auto* stencil = (fPath.getFillType() == SkPathFillType::kWinding)
314 ? &kIncrDecrStencilIfNonzero
315 : &kInvertStencilIfNonZero;
316 this->pushFanStencilProgram(args, pipelineForStencils, stencil);
317 }
318 }
319
320 // Pass 3: Draw convex hulls around each curve.
321 if (doFill && !isLinear) {
322 // By the time this program executes, every pixel will be filled in except the ones touched
323 // by curves. We issue a final cover pass over the curves by drawing their convex hulls.
324 // This will fill in any remaining samples and reset the stencil values back to zero.
325 SkASSERT(fTessellator);
Chris Daltona05ccc32021-06-29 19:42:13 -0600326 auto* hullShader = args.fArena->make<HullShader>(fViewMatrix, fColor,
327 *args.fCaps->shaderCaps());
Chris Dalton031d76b2021-06-08 16:32:00 -0600328 fCoverHullsProgram = GrTessellationShader::MakeProgram(
Chris Daltonebb37e72021-01-27 17:59:45 -0700329 args, hullShader, fPipelineForFills,
Chris Dalton2f733ec2021-06-01 12:11:57 -0600330 GrPathTessellationShader::TestAndResetStencilSettings());
Chris Daltonebb37e72021-01-27 17:59:45 -0700331 }
332}
333
334void GrPathInnerTriangulateOp::onPrePrepare(GrRecordingContext* context,
335 const GrSurfaceProxyView& writeView,
336 GrAppliedClip* clip,
John Stiles52cb1d02021-06-02 11:58:05 -0400337 const GrDstProxyView& dstProxyView,
Chris Daltonebb37e72021-01-27 17:59:45 -0700338 GrXferBarrierFlags renderPassXferBarriers,
339 GrLoadOp colorLoadOp) {
340 this->prePreparePrograms({context->priv().recordTimeAllocator(), writeView, &dstProxyView,
341 renderPassXferBarriers, colorLoadOp, context->priv().caps()},
342 (clip) ? std::move(*clip) : GrAppliedClip::Disabled());
343 if (fStencilCurvesProgram) {
344 context->priv().recordProgramInfo(fStencilCurvesProgram);
345 }
346 for (const GrProgramInfo* fanProgram : fFanPrograms) {
347 context->priv().recordProgramInfo(fanProgram);
348 }
Chris Dalton031d76b2021-06-08 16:32:00 -0600349 if (fCoverHullsProgram) {
350 context->priv().recordProgramInfo(fCoverHullsProgram);
Chris Daltonebb37e72021-01-27 17:59:45 -0700351 }
352}
353
Chris Daltona05ccc32021-06-29 19:42:13 -0600354GR_DECLARE_STATIC_UNIQUE_KEY(gHullVertexBufferKey);
355
Chris Daltonebb37e72021-01-27 17:59:45 -0700356void GrPathInnerTriangulateOp::onPrepare(GrOpFlushState* flushState) {
357 if (!fFanTriangulator) {
358 this->prePreparePrograms({flushState->allocator(), flushState->writeView(),
359 &flushState->dstProxyView(), flushState->renderPassBarriers(),
360 flushState->colorLoadOp(), &flushState->caps()},
361 flushState->detachAppliedClip());
362 if (!fFanTriangulator) {
363 return;
364 }
365 }
366
367 if (fFanPolys) {
368 GrEagerDynamicVertexAllocator alloc(flushState, &fFanBuffer, &fBaseFanVertex);
369 fFanVertexCount = fFanTriangulator->polysToTriangles(fFanPolys, &alloc, &fFanBreadcrumbs);
370 }
371
372 if (fTessellator) {
373 // Must be called after polysToTriangles() in order for fFanBreadcrumbs to be complete.
Chris Dalton569c01b2021-05-25 10:11:46 -0600374 fTessellator->prepare(flushState, this->bounds(), fPath, &fFanBreadcrumbs);
Chris Daltonebb37e72021-01-27 17:59:45 -0700375 }
Chris Daltona05ccc32021-06-29 19:42:13 -0600376
377 if (!flushState->caps().shaderCaps()->vertexIDSupport()) {
378 constexpr static float kStripOrderIDs[4] = {0, 1, 3, 2};
379
380 GR_DEFINE_STATIC_UNIQUE_KEY(gHullVertexBufferKey);
381
382 fHullVertexBufferIfNoIDSupport = flushState->resourceProvider()->findOrMakeStaticBuffer(
383 GrGpuBufferType::kVertex, sizeof(kStripOrderIDs), kStripOrderIDs,
384 gHullVertexBufferKey);
385 }
Chris Daltonebb37e72021-01-27 17:59:45 -0700386}
387
388void GrPathInnerTriangulateOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
389 if (fStencilCurvesProgram) {
390 SkASSERT(fTessellator);
391 flushState->bindPipelineAndScissorClip(*fStencilCurvesProgram, this->bounds());
392 fTessellator->draw(flushState);
Chris Daltond9bdc322021-06-01 19:22:05 -0600393 if (flushState->caps().requiresManualFBBarrierAfterTessellatedStencilDraw()) {
394 flushState->gpu()->insertManualFramebufferBarrier(); // http://skbug.com/9739
395 }
Chris Daltonebb37e72021-01-27 17:59:45 -0700396 }
397
398 for (const GrProgramInfo* fanProgram : fFanPrograms) {
399 SkASSERT(fFanBuffer);
400 flushState->bindPipelineAndScissorClip(*fanProgram, this->bounds());
Robert Phillips787fd9d2021-03-22 14:48:09 -0400401 flushState->bindTextures(fanProgram->geomProc(), nullptr, fanProgram->pipeline());
Chris Daltonebb37e72021-01-27 17:59:45 -0700402 flushState->bindBuffers(nullptr, nullptr, fFanBuffer);
403 flushState->draw(fFanVertexCount, fBaseFanVertex);
404 }
405
Chris Dalton031d76b2021-06-08 16:32:00 -0600406 if (fCoverHullsProgram) {
Chris Daltonebb37e72021-01-27 17:59:45 -0700407 SkASSERT(fTessellator);
Chris Dalton031d76b2021-06-08 16:32:00 -0600408 flushState->bindPipelineAndScissorClip(*fCoverHullsProgram, this->bounds());
409 flushState->bindTextures(fCoverHullsProgram->geomProc(), nullptr, *fPipelineForFills);
Chris Daltona05ccc32021-06-29 19:42:13 -0600410 fTessellator->drawHullInstances(flushState, fHullVertexBufferIfNoIDSupport);
Chris Daltonebb37e72021-01-27 17:59:45 -0700411 }
412}