Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 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 | |
Robert Phillips | e453fa0 | 2021-08-19 14:57:05 -0400 | [diff] [blame] | 8 | #include "src/gpu/ops/StrokeTessellateOp.h" |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 9 | |
| 10 | #include "src/core/SkPathPriv.h" |
Robert Phillips | 06273bc | 2021-08-11 15:43:50 -0400 | [diff] [blame] | 11 | #include "src/gpu/GrAppliedClip.h" |
| 12 | #include "src/gpu/GrOpFlushState.h" |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 13 | #include "src/gpu/GrRecordingContextPriv.h" |
Chris Dalton | 82007f5 | 2021-04-20 00:45:50 -0600 | [diff] [blame] | 14 | #include "src/gpu/tessellate/GrStrokeFixedCountTessellator.h" |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 15 | #include "src/gpu/tessellate/GrStrokeHardwareTessellator.h" |
Chris Dalton | 3b41278 | 2021-06-01 13:40:03 -0600 | [diff] [blame] | 16 | #include "src/gpu/tessellate/shaders/GrTessellationShader.h" |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 17 | |
Chris Dalton | 3b41278 | 2021-06-01 13:40:03 -0600 | [diff] [blame] | 18 | using DynamicStroke = GrStrokeTessellationShader::DynamicStroke; |
Chris Dalton | 82094cd | 2021-02-19 01:11:27 -0700 | [diff] [blame] | 19 | |
Robert Phillips | 62bd633 | 2021-08-26 09:56:55 -0400 | [diff] [blame] | 20 | namespace { |
| 21 | |
| 22 | bool can_use_hardware_tessellation(int numVerbs, const GrPipeline& pipeline, const GrCaps& caps) { |
| 23 | if (!caps.shaderCaps()->tessellationSupport() || |
| 24 | !caps.shaderCaps()->infinitySupport() /* The hw tessellation shaders use infinity. */) { |
| 25 | return false; |
| 26 | } |
| 27 | if (pipeline.usesLocalCoords()) { |
| 28 | // Our back door for HW tessellation shaders isn't currently capable of passing varyings to |
| 29 | // the fragment shader, so if the processors have varyings, we need to use instanced draws |
| 30 | // instead. |
| 31 | return false; |
| 32 | } |
| 33 | // Only use hardware tessellation if we're drawing a somewhat large number of verbs. Otherwise |
| 34 | // we seem to be better off using instanced draws. |
| 35 | return numVerbs >= caps.minStrokeVerbsForHwTessellation(); |
| 36 | } |
| 37 | |
| 38 | } // anonymous namespace |
| 39 | |
| 40 | namespace skgpu::v1 { |
| 41 | |
| 42 | StrokeTessellateOp::StrokeTessellateOp(GrAAType aaType, const SkMatrix& viewMatrix, |
| 43 | const SkPath& path, const SkStrokeRec& stroke, |
| 44 | GrPaint&& paint) |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 45 | : GrDrawOp(ClassID()) |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 46 | , fAAType(aaType) |
| 47 | , fViewMatrix(viewMatrix) |
Chris Dalton | 1017a35 | 2021-02-18 15:22:54 -0700 | [diff] [blame] | 48 | , fPathStrokeList(path, stroke, paint.getColor4f()) |
| 49 | , fTotalCombinedVerbCnt(path.countVerbs()) |
| 50 | , fProcessors(std::move(paint)) { |
Chris Dalton | 1017a35 | 2021-02-18 15:22:54 -0700 | [diff] [blame] | 51 | if (!this->headColor().fitsInBytes()) { |
| 52 | fShaderFlags |= ShaderFlags::kWideColor; |
| 53 | } |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 54 | SkRect devBounds = path.getBounds(); |
Chris Dalton | 18d4964 | 2021-05-13 16:38:10 -0600 | [diff] [blame] | 55 | if (!this->headStroke().isHairlineStyle()) { |
| 56 | // Non-hairlines inflate in local path space (pre-transform). |
Chris Dalton | 0638df1 | 2021-05-14 15:57:39 -0600 | [diff] [blame] | 57 | fInflationRadius = stroke.getInflationRadius(); |
| 58 | devBounds.outset(fInflationRadius, fInflationRadius); |
Chris Dalton | 18d4964 | 2021-05-13 16:38:10 -0600 | [diff] [blame] | 59 | } |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 60 | viewMatrix.mapRect(&devBounds, devBounds); |
Chris Dalton | 18d4964 | 2021-05-13 16:38:10 -0600 | [diff] [blame] | 61 | if (this->headStroke().isHairlineStyle()) { |
| 62 | // Hairlines inflate in device space (post-transform). |
Chris Dalton | 0638df1 | 2021-05-14 15:57:39 -0600 | [diff] [blame] | 63 | fInflationRadius = SkStrokeRec::GetInflationRadius(stroke.getJoin(), stroke.getMiter(), |
| 64 | stroke.getCap(), 1); |
| 65 | devBounds.outset(fInflationRadius, fInflationRadius); |
Chris Dalton | 18d4964 | 2021-05-13 16:38:10 -0600 | [diff] [blame] | 66 | } |
Chris Dalton | 57ab06c | 2021-04-22 12:57:28 -0600 | [diff] [blame] | 67 | this->setBounds(devBounds, HasAABloat::kNo, IsHairline::kNo); |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Robert Phillips | 62bd633 | 2021-08-26 09:56:55 -0400 | [diff] [blame] | 70 | void StrokeTessellateOp::visitProxies(const GrVisitProxyFunc& func) const { |
Chris Dalton | b064334 | 2020-12-15 01:04:12 -0700 | [diff] [blame] | 71 | if (fFillProgram) { |
Robert Phillips | 294723d | 2021-06-17 09:23:58 -0400 | [diff] [blame] | 72 | fFillProgram->visitFPProxies(func); |
Chris Dalton | b064334 | 2020-12-15 01:04:12 -0700 | [diff] [blame] | 73 | } else if (fStencilProgram) { |
Robert Phillips | 294723d | 2021-06-17 09:23:58 -0400 | [diff] [blame] | 74 | fStencilProgram->visitFPProxies(func); |
Chris Dalton | b064334 | 2020-12-15 01:04:12 -0700 | [diff] [blame] | 75 | } else { |
Robert Phillips | 294723d | 2021-06-17 09:23:58 -0400 | [diff] [blame] | 76 | fProcessors.visitProxies(func); |
Chris Dalton | b064334 | 2020-12-15 01:04:12 -0700 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | |
Robert Phillips | 62bd633 | 2021-08-26 09:56:55 -0400 | [diff] [blame] | 80 | GrProcessorSet::Analysis StrokeTessellateOp::finalize(const GrCaps& caps, |
| 81 | const GrAppliedClip* clip, |
| 82 | GrClampType clampType) { |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 83 | // Make sure the finalize happens before combining. We might change fNeedsStencil here. |
Chris Dalton | ed82686 | 2021-02-22 12:01:12 -0700 | [diff] [blame] | 84 | SkASSERT(fPathStrokeList.fNext == nullptr); |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 85 | const GrProcessorSet::Analysis& analysis = fProcessors.finalize( |
Chris Dalton | 1017a35 | 2021-02-18 15:22:54 -0700 | [diff] [blame] | 86 | this->headColor(), GrProcessorAnalysisCoverage::kNone, clip, |
Chris Dalton | 57ab06c | 2021-04-22 12:57:28 -0600 | [diff] [blame] | 87 | &GrUserStencilSettings::kUnused, caps, clampType, &this->headColor()); |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 88 | fNeedsStencil = !analysis.unaffectedByDstValue(); |
| 89 | return analysis; |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Robert Phillips | 62bd633 | 2021-08-26 09:56:55 -0400 | [diff] [blame] | 92 | GrOp::CombineResult StrokeTessellateOp::onCombineIfPossible(GrOp* grOp, SkArenaAlloc* alloc, |
| 93 | const GrCaps& caps) { |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 94 | SkASSERT(grOp->classID() == this->classID()); |
Robert Phillips | 62bd633 | 2021-08-26 09:56:55 -0400 | [diff] [blame] | 95 | auto* op = static_cast<StrokeTessellateOp*>(grOp); |
Chris Dalton | 42582fc | 2021-02-18 11:29:49 -0700 | [diff] [blame] | 96 | |
Chris Dalton | 2a63f82 | 2021-05-27 14:14:11 -0600 | [diff] [blame] | 97 | // This must be called after finalize(). fNeedsStencil can change in finalize(). |
| 98 | SkASSERT(fProcessors.isFinalized()); |
| 99 | SkASSERT(op->fProcessors.isFinalized()); |
| 100 | |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 101 | if (fNeedsStencil || |
| 102 | op->fNeedsStencil || |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 103 | fViewMatrix != op->fViewMatrix || |
| 104 | fAAType != op->fAAType || |
Chris Dalton | 42582fc | 2021-02-18 11:29:49 -0700 | [diff] [blame] | 105 | fProcessors != op->fProcessors || |
| 106 | this->headStroke().isHairlineStyle() != op->headStroke().isHairlineStyle()) { |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 107 | return CombineResult::kCannotCombine; |
| 108 | } |
| 109 | |
Chris Dalton | 42582fc | 2021-02-18 11:29:49 -0700 | [diff] [blame] | 110 | auto combinedFlags = fShaderFlags | op->fShaderFlags; |
| 111 | if (!(combinedFlags & ShaderFlags::kDynamicStroke) && |
| 112 | !DynamicStroke::StrokesHaveEqualDynamicState(this->headStroke(), op->headStroke())) { |
| 113 | // The paths have different stroke properties. We will need to enable dynamic stroke if we |
| 114 | // still decide to combine them. |
Chris Dalton | bb33be2 | 2021-02-24 16:30:34 -0700 | [diff] [blame] | 115 | if (this->headStroke().isHairlineStyle()) { |
| 116 | return CombineResult::kCannotCombine; // Dynamic hairlines aren't supported. |
| 117 | } |
Chris Dalton | 42582fc | 2021-02-18 11:29:49 -0700 | [diff] [blame] | 118 | combinedFlags |= ShaderFlags::kDynamicStroke; |
| 119 | } |
Chris Dalton | 1017a35 | 2021-02-18 15:22:54 -0700 | [diff] [blame] | 120 | if (!(combinedFlags & ShaderFlags::kDynamicColor) && this->headColor() != op->headColor()) { |
| 121 | // The paths have different colors. We will need to enable dynamic color if we still decide |
| 122 | // to combine them. |
| 123 | combinedFlags |= ShaderFlags::kDynamicColor; |
| 124 | } |
| 125 | |
| 126 | // Don't actually enable new dynamic state on ops that already have lots of verbs. |
| 127 | constexpr static GrTFlagsMask<ShaderFlags> kDynamicStatesMask(ShaderFlags::kDynamicStroke | |
| 128 | ShaderFlags::kDynamicColor); |
| 129 | ShaderFlags neededDynamicStates = combinedFlags & kDynamicStatesMask; |
| 130 | if (neededDynamicStates != ShaderFlags::kNone) { |
| 131 | if (!this->shouldUseDynamicStates(neededDynamicStates) || |
| 132 | !op->shouldUseDynamicStates(neededDynamicStates)) { |
Chris Dalton | 42582fc | 2021-02-18 11:29:49 -0700 | [diff] [blame] | 133 | return CombineResult::kCannotCombine; |
| 134 | } |
| 135 | } |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 136 | |
Chris Dalton | 42582fc | 2021-02-18 11:29:49 -0700 | [diff] [blame] | 137 | fShaderFlags = combinedFlags; |
Chris Dalton | ed82686 | 2021-02-22 12:01:12 -0700 | [diff] [blame] | 138 | |
| 139 | // Concat the op's PathStrokeList. Since the head element is allocated inside the op, we need to |
| 140 | // copy it. |
| 141 | auto* headCopy = alloc->make<PathStrokeList>(std::move(op->fPathStrokeList)); |
| 142 | *fPathStrokeTail = headCopy; |
| 143 | fPathStrokeTail = (op->fPathStrokeTail == &op->fPathStrokeList.fNext) ? &headCopy->fNext |
| 144 | : op->fPathStrokeTail; |
| 145 | |
Chris Dalton | 0638df1 | 2021-05-14 15:57:39 -0600 | [diff] [blame] | 146 | fInflationRadius = std::max(fInflationRadius, op->fInflationRadius); |
Chris Dalton | ed82686 | 2021-02-22 12:01:12 -0700 | [diff] [blame] | 147 | fTotalCombinedVerbCnt += op->fTotalCombinedVerbCnt; |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 148 | return CombineResult::kMerged; |
| 149 | } |
| 150 | |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 151 | // Marks every stencil value as "1". |
| 152 | constexpr static GrUserStencilSettings kMarkStencil( |
| 153 | GrUserStencilSettings::StaticInit< |
| 154 | 0x0001, |
| 155 | GrUserStencilTest::kLessIfInClip, // Match kTestAndResetStencil. |
| 156 | 0x0000, // Always fail. |
| 157 | GrUserStencilOp::kZero, |
| 158 | GrUserStencilOp::kReplace, |
| 159 | 0xffff>()); |
| 160 | |
| 161 | // Passes if the stencil value is nonzero. Also resets the stencil value to zero on pass. This is |
| 162 | // formulated to match kMarkStencil everywhere except the ref and compare mask. This will allow us |
| 163 | // to use the same pipeline for both stencil and fill if dynamic stencil state is supported. |
| 164 | constexpr static GrUserStencilSettings kTestAndResetStencil( |
| 165 | GrUserStencilSettings::StaticInit< |
| 166 | 0x0000, |
| 167 | GrUserStencilTest::kLessIfInClip, // i.e., "not equal to zero, if in clip". |
| 168 | 0x0001, |
| 169 | GrUserStencilOp::kZero, |
| 170 | GrUserStencilOp::kReplace, |
| 171 | 0xffff>()); |
| 172 | |
Robert Phillips | 62bd633 | 2021-08-26 09:56:55 -0400 | [diff] [blame] | 173 | void StrokeTessellateOp::prePrepareTessellator(GrTessellationShader::ProgramArgs&& args, |
| 174 | GrAppliedClip&& clip) { |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 175 | SkASSERT(!fTessellator); |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 176 | SkASSERT(!fFillProgram); |
| 177 | SkASSERT(!fStencilProgram); |
Chris Dalton | 0638df1 | 2021-05-14 15:57:39 -0600 | [diff] [blame] | 178 | // GrOp::setClippedBounds() should have been called by now. |
| 179 | SkASSERT(SkRect::MakeIWH(args.fWriteView.width(), |
| 180 | args.fWriteView.height()).contains(this->bounds())); |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 181 | |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 182 | const GrCaps& caps = *args.fCaps; |
| 183 | SkArenaAlloc* arena = args.fArena; |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 184 | |
Chris Dalton | 0638df1 | 2021-05-14 15:57:39 -0600 | [diff] [blame] | 185 | std::array<float, 2> matrixMinMaxScales; |
| 186 | if (!fViewMatrix.getMinMaxScales(matrixMinMaxScales.data())) { |
| 187 | matrixMinMaxScales.fill(1); |
| 188 | } |
| 189 | |
| 190 | float devInflationRadius = fInflationRadius; |
| 191 | if (!this->headStroke().isHairlineStyle()) { |
| 192 | devInflationRadius *= matrixMinMaxScales[1]; |
| 193 | } |
| 194 | SkRect strokeCullBounds = this->bounds().makeOutset(devInflationRadius, devInflationRadius); |
| 195 | |
Chris Dalton | 198ac15 | 2021-06-09 13:49:43 -0600 | [diff] [blame] | 196 | auto* pipeline = GrTessellationShader::MakePipeline(args, fAAType, std::move(clip), |
| 197 | std::move(fProcessors)); |
| 198 | |
| 199 | if (can_use_hardware_tessellation(fTotalCombinedVerbCnt, *pipeline, caps)) { |
Chris Dalton | 82007f5 | 2021-04-20 00:45:50 -0600 | [diff] [blame] | 200 | // Only use hardware tessellation if we're drawing a somewhat large number of verbs. |
| 201 | // Otherwise we seem to be better off using instanced draws. |
Chris Dalton | 6904303 | 2021-07-01 11:17:53 -0600 | [diff] [blame] | 202 | fTessellator = arena->make<GrStrokeHardwareTessellator>(*caps.shaderCaps(), fShaderFlags, |
Chris Dalton | 13adb4a | 2021-05-26 10:21:56 -0600 | [diff] [blame] | 203 | fViewMatrix, &fPathStrokeList, |
Chris Dalton | 0638df1 | 2021-05-14 15:57:39 -0600 | [diff] [blame] | 204 | matrixMinMaxScales, |
| 205 | strokeCullBounds); |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 206 | } else { |
Chris Dalton | 6904303 | 2021-07-01 11:17:53 -0600 | [diff] [blame] | 207 | fTessellator = arena->make<GrStrokeFixedCountTessellator>(*caps.shaderCaps(), fShaderFlags, |
| 208 | fViewMatrix, &fPathStrokeList, |
Chris Dalton | 0638df1 | 2021-05-14 15:57:39 -0600 | [diff] [blame] | 209 | matrixMinMaxScales, |
Chris Dalton | 6904303 | 2021-07-01 11:17:53 -0600 | [diff] [blame] | 210 | strokeCullBounds); |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 211 | } |
| 212 | |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 213 | auto fillStencil = &GrUserStencilSettings::kUnused; |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 214 | if (fNeedsStencil) { |
Chris Dalton | 2f733ec | 2021-06-01 12:11:57 -0600 | [diff] [blame] | 215 | fStencilProgram = GrTessellationShader::MakeProgram(args, fTessellator->shader(), pipeline, |
| 216 | &kMarkStencil); |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 217 | fillStencil = &kTestAndResetStencil; |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 218 | args.fXferBarrierFlags = GrXferBarrierFlags::kNone; |
Chris Dalton | 55abaf5 | 2020-12-08 10:25:13 -0700 | [diff] [blame] | 219 | } |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 220 | |
Chris Dalton | 2f733ec | 2021-06-01 12:11:57 -0600 | [diff] [blame] | 221 | fFillProgram = GrTessellationShader::MakeProgram(args, fTessellator->shader(), pipeline, |
| 222 | fillStencil); |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 223 | } |
| 224 | |
Robert Phillips | 62bd633 | 2021-08-26 09:56:55 -0400 | [diff] [blame] | 225 | void StrokeTessellateOp::onPrePrepare(GrRecordingContext* context, |
| 226 | const GrSurfaceProxyView& writeView, GrAppliedClip* clip, |
| 227 | const GrDstProxyView& dstProxyView, |
| 228 | GrXferBarrierFlags renderPassXferBarriers, GrLoadOp |
| 229 | colorLoadOp) { |
Chris Dalton | 2a26c50 | 2021-08-26 10:05:11 -0600 | [diff] [blame] | 230 | // DMSAA is not supported on DDL. |
| 231 | bool usesMSAASurface = writeView.asRenderTargetProxy()->numSamples() > 1; |
| 232 | this->prePrepareTessellator({context->priv().recordTimeAllocator(), writeView, usesMSAASurface, |
| 233 | &dstProxyView, renderPassXferBarriers, colorLoadOp, |
| 234 | context->priv().caps()}, |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 235 | (clip) ? std::move(*clip) : GrAppliedClip::Disabled()); |
| 236 | if (fStencilProgram) { |
| 237 | context->priv().recordProgramInfo(fStencilProgram); |
| 238 | } |
| 239 | if (fFillProgram) { |
| 240 | context->priv().recordProgramInfo(fFillProgram); |
| 241 | } |
| 242 | } |
| 243 | |
Robert Phillips | 62bd633 | 2021-08-26 09:56:55 -0400 | [diff] [blame] | 244 | void StrokeTessellateOp::onPrepare(GrOpFlushState* flushState) { |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 245 | if (!fTessellator) { |
| 246 | this->prePrepareTessellator({flushState->allocator(), flushState->writeView(), |
Chris Dalton | 2a26c50 | 2021-08-26 10:05:11 -0600 | [diff] [blame] | 247 | flushState->usesMSAASurface(), &flushState->dstProxyView(), |
| 248 | flushState->renderPassBarriers(), flushState->colorLoadOp(), |
| 249 | &flushState->caps()}, flushState->detachAppliedClip()); |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 250 | } |
| 251 | SkASSERT(fTessellator); |
Chris Dalton | 6ca9e18 | 2021-04-19 20:49:45 -0600 | [diff] [blame] | 252 | fTessellator->prepare(flushState, fTotalCombinedVerbCnt); |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Robert Phillips | 62bd633 | 2021-08-26 09:56:55 -0400 | [diff] [blame] | 255 | void StrokeTessellateOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) { |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 256 | if (fStencilProgram) { |
Chris Dalton | 82094cd | 2021-02-19 01:11:27 -0700 | [diff] [blame] | 257 | flushState->bindPipelineAndScissorClip(*fStencilProgram, chainBounds); |
Robert Phillips | 787fd9d | 2021-03-22 14:48:09 -0400 | [diff] [blame] | 258 | flushState->bindTextures(fStencilProgram->geomProc(), nullptr, fStencilProgram->pipeline()); |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 259 | fTessellator->draw(flushState); |
| 260 | } |
| 261 | if (fFillProgram) { |
Chris Dalton | 82094cd | 2021-02-19 01:11:27 -0700 | [diff] [blame] | 262 | flushState->bindPipelineAndScissorClip(*fFillProgram, chainBounds); |
Robert Phillips | 787fd9d | 2021-03-22 14:48:09 -0400 | [diff] [blame] | 263 | flushState->bindTextures(fFillProgram->geomProc(), nullptr, fFillProgram->pipeline()); |
Chris Dalton | 2224100 | 2021-02-04 09:47:40 -0700 | [diff] [blame] | 264 | fTessellator->draw(flushState); |
| 265 | } |
Chris Dalton | 0e54309 | 2020-11-03 14:09:16 -0700 | [diff] [blame] | 266 | } |
Robert Phillips | 62bd633 | 2021-08-26 09:56:55 -0400 | [diff] [blame] | 267 | |
| 268 | } // namespace skgpu::v1 |