aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/beziereffects.cpp2
-rw-r--r--gm/convexpolyeffect.cpp4
-rw-r--r--src/gpu/GrAppliedClip.h3
-rw-r--r--src/gpu/GrOpFlushState.h18
-rw-r--r--src/gpu/GrPipeline.cpp26
-rw-r--r--src/gpu/GrPipeline.h3
-rw-r--r--src/gpu/GrRenderTargetOpList.h11
-rw-r--r--src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp3
-rw-r--r--src/gpu/instanced/InstancedOp.cpp3
-rw-r--r--src/gpu/ops/GrAtlasTextOp.cpp3
-rw-r--r--src/gpu/ops/GrDashOp.cpp3
-rw-r--r--src/gpu/ops/GrDrawPathOp.cpp7
-rw-r--r--src/gpu/ops/GrShadowRRectOp.cpp4
-rw-r--r--src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp11
-rw-r--r--src/gpu/ops/GrSimpleMeshDrawOpHelper.h2
-rw-r--r--tests/PrimitiveProcessorTest.cpp3
16 files changed, 61 insertions, 45 deletions
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index b4225db0b4..956093da7d 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -44,7 +44,7 @@ protected:
}
const GrPipeline* makePipeline(Target* target) {
- return target->makePipeline(0, std::move(fProcessorSet));
+ return target->makePipeline(0, std::move(fProcessorSet), target->detachAppliedClip());
}
const GrGeometryProcessor* gp() const { return fGeometryProcessor.get(); }
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index 9c437e2ffa..414acaac5b 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -82,7 +82,9 @@ private:
fRect.toQuad(verts);
- helper.recordDraw(target, gp.get(), target->makePipeline(0, std::move(fProcessors)));
+ helper.recordDraw(
+ target, gp.get(),
+ target->makePipeline(0, std::move(fProcessors), target->detachAppliedClip()));
}
bool onCombineIfPossible(GrOp* op, const GrCaps& caps) override { return false; }
diff --git a/src/gpu/GrAppliedClip.h b/src/gpu/GrAppliedClip.h
index a389d749fa..7ef3346ed3 100644
--- a/src/gpu/GrAppliedClip.h
+++ b/src/gpu/GrAppliedClip.h
@@ -27,6 +27,9 @@ public:
const GrScissorState& scissorState() const { return fScissorState; }
const GrWindowRectsState& windowRectsState() const { return fWindowRectsState; }
GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCoverageFP.get(); }
+ sk_sp<GrFragmentProcessor> detachClipCoverageFragmentProcessor() {
+ return std::move(fClipCoverageFP);
+ }
bool hasStencilClip() const { return SkClipStack::kInvalidGenID != fClipStackID; }
/**
diff --git a/src/gpu/GrOpFlushState.h b/src/gpu/GrOpFlushState.h
index 2c860f9b81..cc1d22b962 100644
--- a/src/gpu/GrOpFlushState.h
+++ b/src/gpu/GrOpFlushState.h
@@ -8,6 +8,7 @@
#ifndef GrOpFlushState_DEFINED
#define GrOpFlushState_DEFINED
+#include "GrAppliedClip.h"
#include "GrBufferAllocPool.h"
#include "SkArenaAlloc.h"
#include "ops/GrMeshDrawOp.h"
@@ -100,8 +101,8 @@ public:
GrRenderTarget* renderTarget() const { return fProxy->priv().peekRenderTarget(); }
// TODO: do we still need the dst proxy here?
- GrRenderTargetProxy* fProxy;
- const GrAppliedClip* fAppliedClip;
+ GrRenderTargetProxy* fProxy;
+ GrAppliedClip* fAppliedClip;
GrXferProcessor::DstProxy fDstProxy;
};
@@ -112,6 +113,11 @@ public:
return *fOpArgs;
}
+ GrAppliedClip detachAppliedClip() {
+ SkASSERT(fOpArgs);
+ return fOpArgs->fAppliedClip ? std::move(*fOpArgs->fAppliedClip) : GrAppliedClip();
+ }
+
template <typename... Args>
GrPipeline* allocPipeline(Args&&... args) {
return fPipelines.make<GrPipeline>(std::forward<Args>(args)...);
@@ -239,6 +245,8 @@ public:
const GrAppliedClip* clip() const { return this->state()->drawOpArgs().fAppliedClip; }
+ GrAppliedClip detachAppliedClip() { return this->state()->detachAppliedClip(); }
+
const GrXferProcessor::DstProxy& dstProxy() const {
return this->state()->drawOpArgs().fDstProxy;
}
@@ -252,15 +260,15 @@ public:
* Helper that makes a pipeline targeting the op's render target that incorporates the op's
* GrAppliedClip.
* */
- GrPipeline* makePipeline(uint32_t pipelineFlags, GrProcessorSet&& processorSet) {
+ GrPipeline* makePipeline(uint32_t pipelineFlags, GrProcessorSet&& processorSet,
+ GrAppliedClip&& clip) {
GrPipeline::InitArgs pipelineArgs;
pipelineArgs.fFlags = pipelineFlags;
pipelineArgs.fProxy = this->proxy();
- pipelineArgs.fAppliedClip = this->clip();
pipelineArgs.fDstProxy = this->dstProxy();
pipelineArgs.fCaps = &this->caps();
pipelineArgs.fResourceProvider = this->resourceProvider();
- return this->allocPipeline(pipelineArgs, std::move(processorSet));
+ return this->allocPipeline(pipelineArgs, std::move(processorSet), std::move(clip));
}
private:
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index f6848962b8..a6e8fbad20 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -17,20 +17,19 @@
#include "ops/GrOp.h"
-GrPipeline::GrPipeline(const InitArgs& args, GrProcessorSet&& processors) {
+GrPipeline::GrPipeline(const InitArgs& args, GrProcessorSet&& processors,
+ GrAppliedClip&& appliedClip) {
SkASSERT(args.fProxy);
SkASSERT(processors.isFinalized());
fProxy.reset(args.fProxy);
fFlags = args.fFlags;
- if (args.fAppliedClip) {
- fScissorState = args.fAppliedClip->scissorState();
- if (args.fAppliedClip->hasStencilClip()) {
- fFlags |= kHasStencilClip_Flag;
- }
- fWindowRectsState = args.fAppliedClip->windowRectsState();
+ fScissorState = appliedClip.scissorState();
+ if (appliedClip.hasStencilClip()) {
+ fFlags |= kHasStencilClip_Flag;
}
+ fWindowRectsState = appliedClip.windowRectsState();
if (!args.fUserStencil->isDisabled(fFlags & kHasStencilClip_Flag)) {
fFlags |= kStencilEnabled_Flag;
}
@@ -52,7 +51,8 @@ GrPipeline::GrPipeline(const InitArgs& args, GrProcessorSet&& processors) {
fNumColorProcessors = processors.numColorFragmentProcessors();
int numTotalProcessors =
fNumColorProcessors + processors.numCoverageFragmentProcessors();
- if (args.fAppliedClip && args.fAppliedClip->clipCoverageFragmentProcessor()) {
+ auto clipFP = appliedClip.detachClipCoverageFragmentProcessor();
+ if (clipFP) {
++numTotalProcessors;
}
fFragmentProcessors.reset(numTotalProcessors);
@@ -72,12 +72,10 @@ GrPipeline::GrPipeline(const InitArgs& args, GrProcessorSet&& processors) {
this->markAsBad();
}
}
- if (args.fAppliedClip) {
- if (const GrFragmentProcessor* fp = args.fAppliedClip->clipCoverageFragmentProcessor()) {
- fFragmentProcessors[currFPIdx].reset(fp);
- if (!fp->instantiate(args.fResourceProvider)) {
- this->markAsBad();
- }
+ if (clipFP) {
+ fFragmentProcessors[currFPIdx].reset(clipFP.get());
+ if (!fFragmentProcessors[currFPIdx]->instantiate(args.fResourceProvider)) {
+ this->markAsBad();
}
}
}
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index c4c7599527..7583c6c839 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -77,7 +77,6 @@ public:
struct InitArgs {
uint32_t fFlags = 0;
const GrUserStencilSettings* fUserStencil = &GrUserStencilSettings::kUnused;
- const GrAppliedClip* fAppliedClip = nullptr;
GrRenderTargetProxy* fProxy = nullptr;
const GrCaps* fCaps = nullptr;
GrResourceProvider* fResourceProvider = nullptr;
@@ -101,7 +100,7 @@ public:
**/
GrPipeline(GrRenderTargetProxy*, ScissorState, SkBlendMode);
- GrPipeline(const InitArgs& args, GrProcessorSet&& processors);
+ GrPipeline(const InitArgs&, GrProcessorSet&&, GrAppliedClip&&);
GrPipeline(const GrPipeline&) = delete;
GrPipeline& operator=(const GrPipeline&) = delete;
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index 68c4890f1c..f162fcc5b0 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -113,18 +113,15 @@ private:
friend class GrRenderTargetContextPriv; // for stencil clip state. TODO: this is invasive
struct RecordedOp {
- RecordedOp(std::unique_ptr<GrOp> op,
- const GrAppliedClip* appliedClip,
- const DstProxy* dstProxy)
- : fOp(std::move(op))
- , fAppliedClip(appliedClip) {
+ RecordedOp(std::unique_ptr<GrOp> op, GrAppliedClip* appliedClip, const DstProxy* dstProxy)
+ : fOp(std::move(op)), fAppliedClip(appliedClip) {
if (dstProxy) {
fDstProxy = *dstProxy;
}
}
std::unique_ptr<GrOp> fOp;
- DstProxy fDstProxy;
- const GrAppliedClip* fAppliedClip;
+ DstProxy fDstProxy;
+ GrAppliedClip* fAppliedClip;
};
// If the input op is combined with an earlier op, this returns the combined op. Otherwise, it
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
index c067e3a34e..6937642c16 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
@@ -293,12 +293,11 @@ void DrawPathsOp::onExecute(GrOpFlushState* flushState) {
}
GrPipeline::InitArgs args;
- args.fAppliedClip = flushState->drawOpArgs().fAppliedClip;
args.fCaps = &flushState->caps();
args.fFlags = fSRGBFlags;
args.fProxy = flushState->drawOpArgs().fProxy;
args.fDstProxy = flushState->drawOpArgs().fDstProxy;
- GrPipeline pipeline(args, std::move(fProcessors));
+ GrPipeline pipeline(args, std::move(fProcessors), flushState->detachAppliedClip());
int baseInstance = fBaseInstance;
diff --git a/src/gpu/instanced/InstancedOp.cpp b/src/gpu/instanced/InstancedOp.cpp
index f13a1dc47b..7d50e9654e 100644
--- a/src/gpu/instanced/InstancedOp.cpp
+++ b/src/gpu/instanced/InstancedOp.cpp
@@ -226,7 +226,6 @@ void InstancedOp::onExecute(GrOpFlushState* state) {
state->gpu()->handleDirtyContext();
GrPipeline::InitArgs args;
- args.fAppliedClip = state->drawOpArgs().fAppliedClip;
args.fCaps = &state->caps();
args.fResourceProvider = state->resourceProvider();
args.fFlags = GrAATypeIsHW(fInfo.aaType()) ? GrPipeline::kHWAntialias_Flag : 0;
@@ -238,7 +237,7 @@ void InstancedOp::onExecute(GrOpFlushState* state) {
}
args.fProxy = state->drawOpArgs().fProxy;
args.fDstProxy = state->drawOpArgs().fDstProxy;
- GrPipeline pipeline(args, std::move(fProcessors));
+ GrPipeline pipeline(args, std::move(fProcessors), state->detachAppliedClip());
if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*state->gpu()->caps())) {
state->gpu()->xferBarrier(pipeline.renderTarget(), barrierType);
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index e8d3caf7d6..f0681a6241 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -93,7 +93,8 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) {
GrMaskFormat maskFormat = this->maskFormat();
FlushInfo flushInfo;
- flushInfo.fPipeline = target->makePipeline(fSRGBFlags, std::move(fProcessors));
+ flushInfo.fPipeline =
+ target->makePipeline(fSRGBFlags, std::move(fProcessors), target->detachAppliedClip());
if (this->usesDistanceFields()) {
flushInfo.fGeometryProcessor =
this->setupDfProcessor(this->viewMatrix(),
diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp
index 6ca55b0058..b00f816840 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -662,7 +662,8 @@ private:
if (fAllowsSRGBInputs) {
pipelineFlags |= GrPipeline::kAllowSRGBInputs_Flag;
}
- const GrPipeline* pipeline = target->makePipeline(pipelineFlags, std::move(fProcessorSet));
+ const GrPipeline* pipeline = target->makePipeline(pipelineFlags, std::move(fProcessorSet),
+ target->detachAppliedClip());
helper.recordDraw(target, gp.get(), pipeline);
}
diff --git a/src/gpu/ops/GrDrawPathOp.cpp b/src/gpu/ops/GrDrawPathOp.cpp
index 9cf6116b99..ad75abbd3b 100644
--- a/src/gpu/ops/GrDrawPathOp.cpp
+++ b/src/gpu/ops/GrDrawPathOp.cpp
@@ -44,7 +44,6 @@ GrPipeline::InitArgs GrDrawPathOpBase::pipelineInitArgs(const GrOpFlushState& st
args.fFlags |= GrPipeline::kHWAntialias_Flag;
}
args.fUserStencil = &kCoverPass;
- args.fAppliedClip = state.drawOpArgs().fAppliedClip;
args.fProxy = state.drawOpArgs().fProxy;
args.fCaps = &state.caps();
args.fResourceProvider = state.resourceProvider();
@@ -65,7 +64,8 @@ void init_stencil_pass_settings(const GrOpFlushState& flushState,
//////////////////////////////////////////////////////////////////////////////
void GrDrawPathOp::onExecute(GrOpFlushState* state) {
- GrPipeline pipeline(this->pipelineInitArgs(*state), this->detachProcessors());
+ GrPipeline pipeline(this->pipelineInitArgs(*state), this->detachProcessors(),
+ state->detachAppliedClip());
sk_sp<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color(), this->viewMatrix()));
GrStencilSettings stencil;
@@ -177,7 +177,8 @@ void GrDrawPathRangeOp::onExecute(GrOpFlushState* state) {
sk_sp<GrPathProcessor> pathProc(
GrPathProcessor::Create(this->color(), drawMatrix, localMatrix));
- GrPipeline pipeline(this->pipelineInitArgs(*state), this->detachProcessors());
+ GrPipeline pipeline(this->pipelineInitArgs(*state), this->detachProcessors(),
+ state->detachAppliedClip());
GrStencilSettings stencil;
init_stencil_pass_settings(*state, this->fillType(), &stencil);
if (fDraws.count() == 1) {
diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp
index 0032329df0..7a4047a149 100644
--- a/src/gpu/ops/GrShadowRRectOp.cpp
+++ b/src/gpu/ops/GrShadowRRectOp.cpp
@@ -613,8 +613,8 @@ private:
}
static const uint32_t kPipelineFlags = 0;
- const GrPipeline* pipeline =
- target->makePipeline(kPipelineFlags, GrProcessorSet::MakeEmptySet());
+ const GrPipeline* pipeline = target->makePipeline(
+ kPipelineFlags, GrProcessorSet::MakeEmptySet(), target->detachAppliedClip());
GrMesh mesh(GrPrimitiveType::kTriangles);
mesh.setIndexed(indexBuffer, fIndexCount, firstIndex, 0, fVertCount - 1);
diff --git a/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp b/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp
index f6a005bece..7c8ca2e5de 100644
--- a/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp
+++ b/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp
@@ -20,6 +20,7 @@ GrSimpleMeshDrawOpHelper::GrSimpleMeshDrawOpHelper(const MakeArgs& args, GrAATyp
, fUsesLocalCoords(false)
, fCompatibleWithAlphaAsCoveage(false) {
SkDEBUGCODE(fDidAnalysis = false);
+ SkDEBUGCODE(fMadePipeline = false);
if (GrAATypeIsHW(aaType)) {
fPipelineFlags |= GrPipeline::kHWAntialias_Flag;
}
@@ -127,7 +128,6 @@ GrPipeline::InitArgs GrSimpleMeshDrawOpHelper::pipelineInitArgs(
GrPipeline::InitArgs args;
args.fFlags = this->pipelineFlags();
args.fProxy = target->proxy();
- args.fAppliedClip = target->clip();
args.fDstProxy = target->dstProxy();
args.fCaps = &target->caps();
args.fResourceProvider = target->resourceProvider();
@@ -136,10 +136,15 @@ GrPipeline::InitArgs GrSimpleMeshDrawOpHelper::pipelineInitArgs(
GrPipeline* GrSimpleMeshDrawOpHelper::internalMakePipeline(GrMeshDrawOp::Target* target,
const GrPipeline::InitArgs& args) {
+ // A caller really should only call this once as the processor set and applied clip get
+ // moved into the GrPipeline.
+ SkASSERT(!fMadePipeline);
+ SkDEBUGCODE(fMadePipeline = true);
if (fProcessors) {
- return target->allocPipeline(args, std::move(*fProcessors));
+ return target->allocPipeline(args, std::move(*fProcessors), target->detachAppliedClip());
} else {
- return target->allocPipeline(args, GrProcessorSet::MakeEmptySet());
+ return target->allocPipeline(args, GrProcessorSet::MakeEmptySet(),
+ target->detachAppliedClip());
}
}
diff --git a/src/gpu/ops/GrSimpleMeshDrawOpHelper.h b/src/gpu/ops/GrSimpleMeshDrawOpHelper.h
index 7dfd130c86..9630f1067d 100644
--- a/src/gpu/ops/GrSimpleMeshDrawOpHelper.h
+++ b/src/gpu/ops/GrSimpleMeshDrawOpHelper.h
@@ -82,6 +82,7 @@ public:
bool compatibleWithAlphaAsCoverage() const { return fCompatibleWithAlphaAsCoveage; }
+ /** Makes a pipeline that consumes the processor set and the op's applied clip. */
GrPipeline* makePipeline(GrMeshDrawOp::Target* target) {
return this->internalMakePipeline(target, this->pipelineInitArgs(target));
}
@@ -113,6 +114,7 @@ private:
unsigned fRequiresDstTexture : 1;
unsigned fUsesLocalCoords : 1;
unsigned fCompatibleWithAlphaAsCoveage : 1;
+ SkDEBUGCODE(unsigned fMadePipeline : 1;)
SkDEBUGCODE(unsigned fDidAnalysis : 1;)
};
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index 83aa3516eb..14851a920a 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -95,7 +95,8 @@ private:
SkPoint* vertices = reinterpret_cast<SkPoint*>(helper.init(target, vertexStride, 1));
vertices->setRectFan(0.f, 0.f, 1.f, 1.f, vertexStride);
helper.recordDraw(target, gp.get(),
- target->makePipeline(0, GrProcessorSet::MakeEmptySet()));
+ target->makePipeline(0, GrProcessorSet::MakeEmptySet(),
+ target->detachAppliedClip()));
}
int fNumAttribs;