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