@@ -91,20 +91,13 @@ void GrTessellatePathOp::onPrepare(GrOpFlushState* state) {
9191
9292void GrTessellatePathOp::onExecute (GrOpFlushState* state, const SkRect& chainBounds) {
9393 GrAppliedClip clip = state->detachAppliedClip ();
94- GrPipeline::FixedDynamicState fixedDynamicState;
95- if (clip.scissorState ().enabled ()) {
96- fixedDynamicState.fScissorRect = clip.scissorState ().rect ();
97- }
98-
99- this ->drawStencilPass (state, clip.hardClip (), &fixedDynamicState);
100-
94+ this ->drawStencilPass (state, clip.hardClip ());
10195 if (!(Flags::kStencilOnly & fFlags )) {
102- this ->drawCoverPass (state, std::move (clip), &fixedDynamicState );
96+ this ->drawCoverPass (state, std::move (clip));
10397 }
10498}
10599
106- void GrTessellatePathOp::drawStencilPass (GrOpFlushState* state, const GrAppliedHardClip& hardClip,
107- const GrPipeline::FixedDynamicState* fixedDynamicState) {
100+ void GrTessellatePathOp::drawStencilPass (GrOpFlushState* state, const GrAppliedHardClip& hardClip) {
108101 // Increments clockwise triangles and decrements counterclockwise. Used for "winding" fill.
109102 constexpr static GrUserStencilSettings kIncrDecrStencil (
110103 GrUserStencilSettings::StaticInitSeparate<
@@ -140,19 +133,24 @@ void GrTessellatePathOp::drawStencilPass(GrOpFlushState* state, const GrAppliedH
140133
141134 GrPipeline pipeline (initArgs, GrDisableColorXPFactory::MakeXferProcessor (), hardClip);
142135
136+ GrOpsRenderPass* renderPass = state->opsRenderPass ();
137+
143138 if (fStencilPathShader ) {
144139 SkASSERT (fPathVertexBuffer );
145- fStencilPathShader ->issueDraw (state, &pipeline, fixedDynamicState, fPathVertexBuffer ,
146- fPathVertexCount , fBasePathVertex , this ->bounds ());
140+ GrPathShader::ProgramInfo programInfo (state->outputView (), &pipeline, fStencilPathShader );
141+ renderPass->bindPipeline (programInfo, this ->bounds (), hardClip.scissorRectIfEnabled ());
142+ renderPass->bindBuffers (nullptr , nullptr , fPathVertexBuffer .get ());
143+ renderPass->draw (fPathVertexCount , fBasePathVertex );
147144 }
148145
149146 if (fCubicInstanceBuffer ) {
150147 // Here we treat the cubic instance buffer as tessellation patches to stencil the curves.
151- GrMesh mesh;
152- mesh.setNonIndexedNonInstanced (fCubicInstanceCount * 4 );
153- mesh.setVertexData (fCubicInstanceBuffer , fBaseCubicInstance * 4 );
154- GrStencilCubicShader (fViewMatrix ).issueDraw (
155- state, &pipeline, fixedDynamicState, mesh, this ->bounds ());
148+ GrStencilCubicShader shader (fViewMatrix );
149+ GrPathShader::ProgramInfo programInfo (state->outputView (), &pipeline, &shader);
150+ renderPass->bindPipeline (programInfo, this ->bounds (), hardClip.scissorRectIfEnabled ());
151+ // Bind instancedBuff as vertex.
152+ renderPass->bindBuffers (nullptr , nullptr , fCubicInstanceBuffer .get ());
153+ renderPass->draw (fCubicInstanceCount * 4 , fBaseCubicInstance * 4 );
156154 }
157155
158156 // http://skbug.com/9739
@@ -161,8 +159,10 @@ void GrTessellatePathOp::drawStencilPass(GrOpFlushState* state, const GrAppliedH
161159 }
162160}
163161
164- void GrTessellatePathOp::drawCoverPass (GrOpFlushState* state, GrAppliedClip&& clip,
165- const GrPipeline::FixedDynamicState* fixedDynamicState) {
162+ void GrTessellatePathOp::drawCoverPass (GrOpFlushState* state, GrAppliedClip&& clip) {
163+ GrOpsRenderPass* renderPass = state->opsRenderPass ();
164+ const SkIRect* scissorRectIfEnabled = clip.scissorRectIfEnabled ();
165+
166166 // Allows non-zero stencil values to pass and write a color, and resets the stencil value back
167167 // to zero; discards immediately on stencil values of zero.
168168 // NOTE: It's ok to not check the clip here because the previous stencil pass only wrote to
@@ -191,7 +191,6 @@ void GrTessellatePathOp::drawCoverPass(GrOpFlushState* state, GrAppliedClip&& cl
191191 initArgs.fCaps = &state->caps ();
192192 initArgs.fDstProxyView = state->drawOpArgs ().dstProxyView ();
193193 initArgs.fOutputSwizzle = state->drawOpArgs ().outputSwizzle ();
194-
195194 GrPipeline pipeline (initArgs, std::move (fProcessors ), std::move (clip));
196195
197196 if (fFillPathShader ) {
@@ -237,25 +236,32 @@ void GrTessellatePathOp::drawCoverPass(GrOpFlushState* state, GrAppliedClip&& cl
237236 SkASSERT (!pipeline.hasStencilClip ());
238237 pipeline.setUserStencil (&kFillOrInvertStencil );
239238 }
240- fFillPathShader ->issueDraw (state, &pipeline, fixedDynamicState, fPathVertexBuffer ,
241- fPathVertexCount , fBasePathVertex , this ->bounds ());
239+ GrPathShader::ProgramInfo programInfo (state->outputView (), &pipeline, fFillPathShader );
240+ renderPass->bindPipeline (programInfo, this ->bounds (), scissorRectIfEnabled);
241+ renderPass->bindTextures (*fFillPathShader , nullptr , pipeline);
242+ renderPass->bindBuffers (nullptr , nullptr , fPathVertexBuffer .get ());
243+ renderPass->draw (fPathVertexCount , fBasePathVertex );
242244
243245 if (fCubicInstanceBuffer ) {
244246 // At this point, every pixel is filled in except the ones touched by curves. Issue a
245247 // final cover pass over the curves by drawing their convex hulls. This will fill in any
246248 // remaining samples and reset the stencil buffer.
247- GrMesh mesh;
248- mesh.setInstanced (fCubicInstanceBuffer , fCubicInstanceCount , fBaseCubicInstance , 4 );
249249 pipeline.setUserStencil (&kTestAndResetStencil );
250- GrFillCubicHullShader (fViewMatrix , fColor ).issueDraw (
251- state, &pipeline, fixedDynamicState, mesh, this ->bounds ());
250+ GrFillCubicHullShader shader (fViewMatrix , fColor );
251+ GrPathShader::ProgramInfo programInfo (state->outputView (), &pipeline, &shader);
252+ renderPass->bindPipeline (programInfo, this ->bounds (), scissorRectIfEnabled);
253+ renderPass->bindTextures (shader, nullptr , pipeline);
254+ renderPass->bindBuffers (nullptr , fCubicInstanceBuffer .get (), nullptr );
255+ renderPass->drawInstanced (fCubicInstanceCount , fBaseCubicInstance , 4 , 0 );
252256 }
253257 } else {
254258 // There is not a fill shader for the path. Just draw a bounding box.
255- GrMesh mesh;
256- mesh.setNonIndexedNonInstanced (4 );
257259 pipeline.setUserStencil (&kTestAndResetStencil );
258- GrFillBoundingBoxShader (fViewMatrix , fColor , fPath .getBounds ()).issueDraw (
259- state, &pipeline, fixedDynamicState, mesh, this ->bounds ());
260+ GrFillBoundingBoxShader shader (fViewMatrix , fColor , fPath .getBounds ());
261+ GrPathShader::ProgramInfo programInfo (state->outputView (), &pipeline, &shader);
262+ renderPass->bindPipeline (programInfo, this ->bounds (), scissorRectIfEnabled);
263+ renderPass->bindTextures (shader, nullptr , pipeline);
264+ renderPass->bindBuffers (nullptr , nullptr , nullptr );
265+ renderPass->draw (4 , 0 );
260266 }
261267}
0 commit comments