diff --git a/gm/clockwise.cpp b/gm/clockwise.cpp index 6861f3fdfc..8b7b0decbe 100644 --- a/gm/clockwise.cpp +++ b/gm/clockwise.cpp @@ -161,7 +161,7 @@ private: return; } GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kPlus, - flushState->drawOpArgs().fOutputSwizzle); + flushState->drawOpArgs().outputSwizzle()); GrMesh mesh(GrPrimitiveType::kTriangleStrip); mesh.setNonIndexedNonInstanced(4); mesh.setVertexData(std::move(fVertexBuffer)); diff --git a/gm/fwidth_squircle.cpp b/gm/fwidth_squircle.cpp index 734c2b89be..598e8309d5 100644 --- a/gm/fwidth_squircle.cpp +++ b/gm/fwidth_squircle.cpp @@ -171,7 +171,7 @@ private: return; } GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kSrcOver, - flushState->drawOpArgs().fOutputSwizzle); + flushState->drawOpArgs().outputSwizzle()); GrMesh mesh(GrPrimitiveType::kTriangleStrip); mesh.setNonIndexedNonInstanced(4); mesh.setVertexData(std::move(fVertexBuffer)); diff --git a/gm/samplelocations.cpp b/gm/samplelocations.cpp index bcf4174e23..e930d0a339 100644 --- a/gm/samplelocations.cpp +++ b/gm/samplelocations.cpp @@ -232,7 +232,7 @@ private: ); GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kSrcOver, - flushState->drawOpArgs().fOutputSwizzle, + flushState->drawOpArgs().outputSwizzle(), GrPipeline::InputFlags::kHWAntialias, &kStencilWrite); GrMesh mesh(GrPrimitiveType::kTriangleStrip); diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp index 7068ba48da..56e9df2b42 100644 --- a/samplecode/SampleCCPRGeometry.cpp +++ b/samplecode/SampleCCPRGeometry.cpp @@ -335,7 +335,7 @@ void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state, } GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kPlus, - state->drawOpArgs().fOutputSwizzle); + state->drawOpArgs().outputSwizzle()); std::unique_ptr proc; if (state->caps().shaderCaps()->geometryShaderSupport()) { diff --git a/src/gpu/GrOpFlushState.cpp b/src/gpu/GrOpFlushState.cpp index 7e1261e4f0..8e1001938b 100644 --- a/src/gpu/GrOpFlushState.cpp +++ b/src/gpu/GrOpFlushState.cpp @@ -40,7 +40,7 @@ void GrOpFlushState::executeDrawsAndUploadsForMeshDrawOp( pipelineArgs.fDstProxy = this->dstProxy(); pipelineArgs.fCaps = &this->caps(); pipelineArgs.fUserStencil = stencilSettings; - pipelineArgs.fOutputSwizzle = this->drawOpArgs().fOutputSwizzle; + pipelineArgs.fOutputSwizzle = this->drawOpArgs().outputSwizzle(); GrPipeline* pipeline = this->allocator()->make(pipelineArgs, std::move(processorSet), this->detachAppliedClip()); @@ -134,7 +134,7 @@ void GrOpFlushState::recordDraw( const GrPipeline::FixedDynamicState* fixedDynamicState, const GrPipeline::DynamicStateArrays* dynamicStateArrays) { SkASSERT(fOpArgs); - SkASSERT(fOpArgs->fOp); + SkDEBUGCODE(fOpArgs->validate()); bool firstDraw = fDraws.begin() == fDraws.end(); auto& draw = fDraws.append(&fArena); GrDeferredUploadToken token = fTokenTracker->issueDrawToken(); @@ -154,7 +154,7 @@ void GrOpFlushState::recordDraw( draw.fDynamicStateArrays = dynamicStateArrays; draw.fMeshes = meshes; draw.fMeshCnt = meshCnt; - draw.fOp = fOpArgs->fOp; + draw.fOp = fOpArgs->op(); if (firstDraw) { fBaseDrawToken = token; } @@ -193,7 +193,7 @@ void GrOpFlushState::putBackVertices(int vertices, size_t vertexStride) { } GrAppliedClip GrOpFlushState::detachAppliedClip() { - return fOpArgs->fAppliedClip ? std::move(*fOpArgs->fAppliedClip) : GrAppliedClip(); + return fOpArgs->appliedClip() ? std::move(*fOpArgs->appliedClip()) : GrAppliedClip(); } GrStrikeCache* GrOpFlushState::glyphCache() const { diff --git a/src/gpu/GrOpFlushState.h b/src/gpu/GrOpFlushState.h index ed8a39ce07..27dac24774 100644 --- a/src/gpu/GrOpFlushState.h +++ b/src/gpu/GrOpFlushState.h @@ -57,22 +57,44 @@ public: /** Additional data required on a per-op basis when executing GrOps. */ struct OpArgs { - GrSurfaceOrigin origin() const { return fProxy->origin(); } - GrRenderTarget* renderTarget() const { return fProxy->peekRenderTarget(); } + explicit OpArgs(GrOp* op, GrRenderTargetProxy* proxy, GrAppliedClip* appliedClip, + const GrXferProcessor::DstProxy& dstProxy) + : fOp(op) + , fProxy(proxy) + , fAppliedClip(appliedClip) + , fDstProxy(dstProxy) { + } - GrOp* fOp; - // TODO: do we still need the dst proxy here? - GrRenderTargetProxy* fProxy; - GrAppliedClip* fAppliedClip; - GrSwizzle fOutputSwizzle; - GrXferProcessor::DstProxy fDstProxy; + int numSamples() const { return fProxy->numSamples(); } + GrSurfaceOrigin origin() const { return fProxy->origin(); } + GrSwizzle outputSwizzle() const { return fProxy->outputSwizzle(); } + + GrOp* op() { return fOp; } + GrRenderTargetProxy* proxy() const { return fProxy; } + GrRenderTarget* renderTarget() const { return fProxy->peekRenderTarget(); } + GrAppliedClip* appliedClip() { return fAppliedClip; } + const GrAppliedClip* appliedClip() const { return fAppliedClip; } + const GrXferProcessor::DstProxy& dstProxy() const { return fDstProxy; } + +#ifdef SK_DEBUG + void validate() const { + SkASSERT(fOp); + SkASSERT(fProxy); + } +#endif + + private: + GrOp* fOp; + GrRenderTargetProxy* fProxy; + GrAppliedClip* fAppliedClip; + GrXferProcessor::DstProxy fDstProxy; // TODO: do we still need the dst proxy here? }; void setOpArgs(OpArgs* opArgs) { fOpArgs = opArgs; } const OpArgs& drawOpArgs() const { SkASSERT(fOpArgs); - SkASSERT(fOpArgs->fOp); + SkDEBUGCODE(fOpArgs->validate()); return *fOpArgs; } @@ -105,10 +127,10 @@ public: int* actualIndexCount) final; void putBackIndices(int indexCount) final; void putBackVertices(int vertices, size_t vertexStride) final; - GrRenderTargetProxy* proxy() const final { return fOpArgs->fProxy; } - const GrAppliedClip* appliedClip() final { return fOpArgs->fAppliedClip; } + GrRenderTargetProxy* proxy() const final { return fOpArgs->proxy(); } + const GrAppliedClip* appliedClip() final { return fOpArgs->appliedClip(); } GrAppliedClip detachAppliedClip() final; - const GrXferProcessor::DstProxy& dstProxy() const final { return fOpArgs->fDstProxy; } + const GrXferProcessor::DstProxy& dstProxy() const final { return fOpArgs->dstProxy(); } GrDeferredUploadTarget* deferredUploadTarget() final { return this; } const GrCaps& caps() const final; GrResourceProvider* resourceProvider() const final { return fResourceProvider; } diff --git a/src/gpu/GrOpsTask.cpp b/src/gpu/GrOpsTask.cpp index f7ceca53a1..5670bd1d88 100644 --- a/src/gpu/GrOpsTask.cpp +++ b/src/gpu/GrOpsTask.cpp @@ -412,13 +412,12 @@ void GrOpsTask::onPrepare(GrOpFlushState* flushState) { #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK TRACE_EVENT0("skia.gpu", chain.head()->name()); #endif - GrOpFlushState::OpArgs opArgs = { + GrOpFlushState::OpArgs opArgs( chain.head(), fTarget->asRenderTargetProxy(), chain.appliedClip(), - fTarget.get()->asRenderTargetProxy()->outputSwizzle(), - chain.dstProxy() - }; + chain.dstProxy()); + flushState->setOpArgs(&opArgs); chain.head()->prepare(flushState); flushState->setOpArgs(nullptr); @@ -532,13 +531,10 @@ bool GrOpsTask::onExecute(GrOpFlushState* flushState) { TRACE_EVENT0("skia.gpu", chain.head()->name()); #endif - GrOpFlushState::OpArgs opArgs { - chain.head(), - fTarget->asRenderTargetProxy(), - chain.appliedClip(), - fTarget.get()->asRenderTargetProxy()->outputSwizzle(), - chain.dstProxy() - }; + GrOpFlushState::OpArgs opArgs(chain.head(), + fTarget->asRenderTargetProxy(), + chain.appliedClip(), + chain.dstProxy()); flushState->setOpArgs(&opArgs); chain.head()->execute(flushState, chain.bounds()); diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.cpp b/src/gpu/ccpr/GrCCDrawPathsOp.cpp index 3bc2c7c3f1..06556c493d 100644 --- a/src/gpu/ccpr/GrCCDrawPathsOp.cpp +++ b/src/gpu/ccpr/GrCCDrawPathsOp.cpp @@ -433,8 +433,8 @@ void GrCCDrawPathsOp::onExecute(GrOpFlushState* flushState, const SkRect& chainB GrPipeline::InitArgs initArgs; initArgs.fCaps = &flushState->caps(); - initArgs.fDstProxy = flushState->drawOpArgs().fDstProxy; - initArgs.fOutputSwizzle = flushState->drawOpArgs().fOutputSwizzle; + initArgs.fDstProxy = flushState->drawOpArgs().dstProxy(); + initArgs.fOutputSwizzle = flushState->drawOpArgs().outputSwizzle(); auto clip = flushState->detachAppliedClip(); GrPipeline::FixedDynamicState fixedDynamicState(clip.scissorState().rect()); GrPipeline pipeline(initArgs, std::move(fProcessors), std::move(clip)); diff --git a/src/gpu/ccpr/GrCCPerFlushResources.cpp b/src/gpu/ccpr/GrCCPerFlushResources.cpp index 9a9fad36b9..4174dba318 100644 --- a/src/gpu/ccpr/GrCCPerFlushResources.cpp +++ b/src/gpu/ccpr/GrCCPerFlushResources.cpp @@ -90,7 +90,7 @@ public: srcProxy->textureSwizzle(), srcProxy->origin()); GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kSrc, - flushState->drawOpArgs().fOutputSwizzle); + flushState->drawOpArgs().outputSwizzle()); GrPipeline::FixedDynamicState dynamicState; dynamicState.fPrimitiveProcessorTextures = &srcProxy; @@ -133,7 +133,7 @@ public: void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override { ProcessorType proc; GrPipeline pipeline(GrScissorTest::kEnabled, SkBlendMode::kPlus, - flushState->drawOpArgs().fOutputSwizzle); + flushState->drawOpArgs().outputSwizzle()); fResources->filler().drawFills(flushState, &proc, pipeline, fFillBatchID, fDrawBounds); fResources->stroker().drawStrokes(flushState, &proc, fStrokeBatchID, fDrawBounds); } diff --git a/src/gpu/ccpr/GrCCStroker.cpp b/src/gpu/ccpr/GrCCStroker.cpp index 21b04f5527..98b8038564 100644 --- a/src/gpu/ccpr/GrCCStroker.cpp +++ b/src/gpu/ccpr/GrCCStroker.cpp @@ -701,7 +701,7 @@ void GrCCStroker::drawStrokes(GrOpFlushState* flushState, GrCCCoverageProcessor* ? &fZeroTallies : fScissorSubBatches[startScissorSubBatch - 1].fEndInstances; GrPipeline pipeline(GrScissorTest::kEnabled, SkBlendMode::kPlus, - flushState->drawOpArgs().fOutputSwizzle); + flushState->drawOpArgs().outputSwizzle()); // Draw linear strokes. this->appendStrokeMeshesToBuffers(0, batch, startIndices, startScissorSubBatch, drawBounds); diff --git a/src/gpu/ccpr/GrStencilAtlasOp.cpp b/src/gpu/ccpr/GrStencilAtlasOp.cpp index f5b16ba851..990cabc3bd 100644 --- a/src/gpu/ccpr/GrStencilAtlasOp.cpp +++ b/src/gpu/ccpr/GrStencilAtlasOp.cpp @@ -116,7 +116,7 @@ void GrStencilAtlasOp::onExecute(GrOpFlushState* flushState, const SkRect& chain GrPipeline pipeline( GrScissorTest::kEnabled, GrDisableColorXPFactory::MakeXferProcessor(), - flushState->drawOpArgs().fOutputSwizzle, GrPipeline::InputFlags::kHWAntialias, + flushState->drawOpArgs().outputSwizzle(), GrPipeline::InputFlags::kHWAntialias, &kIncrDecrStencil); GrSampleMaskProcessor sampleMaskProc; @@ -139,7 +139,7 @@ void GrStencilAtlasOp::onExecute(GrOpFlushState* flushState, const SkRect& chain : &kResolveStencilCoverageAndReset; GrPipeline resolvePipeline(GrScissorTest::kEnabled, SkBlendMode::kSrc, - flushState->drawOpArgs().fOutputSwizzle, noHWAA, + flushState->drawOpArgs().outputSwizzle(), noHWAA, stencilResolveSettings); GrPipeline::FixedDynamicState scissorRectState(drawBoundsRect); diff --git a/src/gpu/ops/GrDrawPathOp.cpp b/src/gpu/ops/GrDrawPathOp.cpp index c346683687..d7bb20da12 100644 --- a/src/gpu/ops/GrDrawPathOp.cpp +++ b/src/gpu/ops/GrDrawPathOp.cpp @@ -49,8 +49,8 @@ GrPipeline::InitArgs GrDrawPathOpBase::pipelineInitArgs(const GrOpFlushState& st } args.fUserStencil = &kCoverPass; args.fCaps = &state.caps(); - args.fDstProxy = state.drawOpArgs().fDstProxy; - args.fOutputSwizzle = state.drawOpArgs().fOutputSwizzle; + args.fDstProxy = state.drawOpArgs().dstProxy(); + args.fOutputSwizzle = state.drawOpArgs().outputSwizzle(); return args; } @@ -67,7 +67,7 @@ const GrProcessorSet::Analysis& GrDrawPathOpBase::doProcessorAnalysis( void init_stencil_pass_settings(const GrOpFlushState& flushState, GrPathRendering::FillType fillType, GrStencilSettings* stencil) { - const GrAppliedClip* appliedClip = flushState.drawOpArgs().fAppliedClip; + const GrAppliedClip* appliedClip = flushState.drawOpArgs().appliedClip(); bool stencilClip = appliedClip && appliedClip->hasStencilClip(); stencil->reset(GrPathRendering::GetStencilPassSettings(fillType), stencilClip, flushState.drawOpArgs().renderTarget()->renderTargetPriv().numStencilBits()); diff --git a/src/gpu/ops/GrFillRRectOp.cpp b/src/gpu/ops/GrFillRRectOp.cpp index cb09ce3e52..bbed9f243b 100644 --- a/src/gpu/ops/GrFillRRectOp.cpp +++ b/src/gpu/ops/GrFillRRectOp.cpp @@ -741,8 +741,8 @@ void GrFillRRectOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBou initArgs.fInputFlags = GrPipeline::InputFlags::kHWAntialias; } initArgs.fCaps = &flushState->caps(); - initArgs.fDstProxy = flushState->drawOpArgs().fDstProxy; - initArgs.fOutputSwizzle = flushState->drawOpArgs().fOutputSwizzle; + initArgs.fDstProxy = flushState->drawOpArgs().dstProxy(); + initArgs.fOutputSwizzle = flushState->drawOpArgs().outputSwizzle(); auto clip = flushState->detachAppliedClip(); GrPipeline::FixedDynamicState* fixedDynamicState = flushState->allocator()->make(clip.scissorState().rect()); diff --git a/src/gpu/ops/GrStencilPathOp.cpp b/src/gpu/ops/GrStencilPathOp.cpp index 0707678f56..1cfd8ff04a 100644 --- a/src/gpu/ops/GrStencilPathOp.cpp +++ b/src/gpu/ops/GrStencilPathOp.cpp @@ -34,7 +34,7 @@ void GrStencilPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds GrStencilSettings stencil(GrPathRendering::GetStencilPassSettings(fPath->getFillType()), fHasStencilClip, numStencilBits); - GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().fProxy, + GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().proxy(), &fViewMatrix, &fScissor, &stencil); state->gpu()->pathRendering()->stencilPath(args, fPath.get()); } diff --git a/tests/DrawOpAtlasTest.cpp b/tests/DrawOpAtlasTest.cpp index c7245ce422..cbd0917252 100644 --- a/tests/DrawOpAtlasTest.cpp +++ b/tests/DrawOpAtlasTest.cpp @@ -211,13 +211,11 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrAtlasTextOpPreparation, reporter, ctxInfo) TestingUploadTarget uploadTarget; GrOpFlushState flushState(gpu, resourceProvider, uploadTarget.writeableTokenTracker()); - GrOpFlushState::OpArgs opArgs = { + GrOpFlushState::OpArgs opArgs( op.get(), rtc->asRenderTargetProxy(), nullptr, - rtc->asRenderTargetProxy()->outputSwizzle(), - GrXferProcessor::DstProxy(nullptr, SkIPoint::Make(0, 0)) - }; + GrXferProcessor::DstProxy(nullptr, SkIPoint::Make(0, 0))); // Cripple the atlas manager so it can't allocate any pages. This will force a failure // in the preparation of the text op diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp index a6f134815c..8a4064ca69 100644 --- a/tests/GrPipelineDynamicStateTest.cpp +++ b/tests/GrPipelineDynamicStateTest.cpp @@ -141,7 +141,7 @@ private: } void onPrepare(GrOpFlushState*) override {} void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override { - GrPipeline pipeline(fScissorTest, SkBlendMode::kSrc, state->drawOpArgs().fOutputSwizzle); + GrPipeline pipeline(fScissorTest, SkBlendMode::kSrc, state->drawOpArgs().outputSwizzle()); SkSTArray meshes; for (int i = 0; i < kNumMeshes; ++i) { GrMesh& mesh = meshes.emplace_back(GrPrimitiveType::kTriangleStrip);