aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-03-29 12:09:15 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-29 16:46:07 +0000
commite7d30484ea8a5677a9403ccd23a9c0961df62ccd (patch)
tree140df99fdbf67a023fa0b31223b9c5169774f29f
parent4a24e10a0b805af6106dd8f7225c10a703696245 (diff)
Remove GrPipelineOptimizations computation from GrPipeline::init and nest in GrMeshDrawOp.
Change-Id: I4a702c83857606c1cb050294c408922eef5769ea Reviewed-on: https://skia-review.googlesource.com/10414 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
-rw-r--r--src/gpu/GrPipeline.cpp17
-rw-r--r--src/gpu/GrPipeline.h3
-rw-r--r--src/gpu/GrPrimitiveProcessor.h57
-rw-r--r--src/gpu/GrProgramDesc.cpp4
-rw-r--r--src/gpu/ops/GrAAConvexPathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrAAFillRectOp.cpp2
-rw-r--r--src/gpu/ops/GrAAHairLinePathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrAAStrokeRectOp.cpp4
-rw-r--r--src/gpu/ops/GrAnalyticRectOp.cpp2
-rw-r--r--src/gpu/ops/GrAtlasTextOp.cpp2
-rw-r--r--src/gpu/ops/GrAtlasTextOp.h2
-rw-r--r--src/gpu/ops/GrDashOp.cpp2
-rw-r--r--src/gpu/ops/GrDefaultPathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrDrawAtlasOp.cpp2
-rw-r--r--src/gpu/ops/GrDrawAtlasOp.h2
-rw-r--r--src/gpu/ops/GrDrawPathOp.cpp9
-rw-r--r--src/gpu/ops/GrDrawPathOp.h2
-rw-r--r--src/gpu/ops/GrDrawVerticesOp.cpp2
-rw-r--r--src/gpu/ops/GrDrawVerticesOp.h2
-rw-r--r--src/gpu/ops/GrLatticeOp.cpp2
-rw-r--r--src/gpu/ops/GrMSAAPathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrMeshDrawOp.h61
-rw-r--r--src/gpu/ops/GrNonAAFillRectOp.cpp2
-rw-r--r--src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp2
-rw-r--r--src/gpu/ops/GrNonAAStrokeRectOp.cpp2
-rw-r--r--src/gpu/ops/GrOvalOpFactory.cpp10
-rw-r--r--src/gpu/ops/GrRegionOp.cpp2
-rw-r--r--src/gpu/ops/GrShadowRRectOp.cpp4
-rw-r--r--src/gpu/ops/GrSmallPathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrTessellatingPathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrTestMeshDrawOp.h2
-rw-r--r--tests/GrPorterDuffTest.cpp2
-rw-r--r--tests/PreFlushCallbackTest.cpp2
-rw-r--r--tests/PrimitiveProcessorTest.cpp2
35 files changed, 101 insertions, 120 deletions
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index d8f7fbdbf8..0a4a36c817 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -18,7 +18,7 @@
#include "ops/GrOp.h"
-GrPipelineOptimizations GrPipeline::init(const InitArgs& args) {
+void GrPipeline::init(const InitArgs& args) {
SkASSERT(args.fAnalysis);
SkASSERT(args.fRenderTarget);
@@ -106,21 +106,6 @@ GrPipelineOptimizations GrPipeline::init(const InitArgs& args) {
fFragmentProcessors[currFPIdx].reset(fp);
}
}
-
- // Setup info we need to pass to GrPrimitiveProcessors that are used with this GrPipeline.
- GrPipelineOptimizations optimizations;
- optimizations.fFlags = 0;
- if (GrColor_ILLEGAL != overrideColor) {
- optimizations.fFlags |= GrPipelineOptimizations::kUseOverrideColor_Flag;
- optimizations.fOverrideColor = overrideColor;
- }
- if (args.fAnalysis->usesLocalCoords()) {
- optimizations.fFlags |= GrPipelineOptimizations::kReadsLocalCoords_Flag;
- }
- if (args.fAnalysis->isCompatibleWithCoverageAsAlpha()) {
- optimizations.fFlags |= GrPipelineOptimizations::kCanTweakAlphaForCoverage_Flag;
- }
- return optimizations;
}
static void add_dependencies_for_processor(const GrFragmentProcessor* proc, GrRenderTarget* rt) {
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index 21693426f1..7c861b2c1e 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -12,7 +12,6 @@
#include "GrFragmentProcessor.h"
#include "GrNonAtomicRef.h"
#include "GrPendingProgramElement.h"
-#include "GrPrimitiveProcessor.h"
#include "GrProcessorSet.h"
#include "GrProgramDesc.h"
#include "GrScissorState.h"
@@ -79,7 +78,7 @@ public:
GrPipeline(GrRenderTarget*, SkBlendMode);
/** (Re)initializes a pipeline. After initialization the pipeline can be used. */
- GrPipelineOptimizations init(const InitArgs&);
+ void init(const InitArgs&);
/** True if the pipeline has been initialized. */
bool isInitialized() const { return SkToBool(fRenderTarget.get()); }
diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h
index 4c439433f5..17e49c7d0c 100644
--- a/src/gpu/GrPrimitiveProcessor.h
+++ b/src/gpu/GrPrimitiveProcessor.h
@@ -33,63 +33,6 @@
class GrGLSLPrimitiveProcessor;
-struct GrInitInvariantOutput;
-
-/*
- * This class allows the GrPipeline to communicate information about the pipeline to a GrOp which
- * inform its decisions for GrPrimitiveProcessor setup. These are not properly part of the pipeline
- * because they reflect the specific inputs that the op provided to perform the analysis (e.g. that
- * the GrGeometryProcessor would output an opaque color).
- *
- * The pipeline analysis that produced this may have decided to elide some GrProcessors. However,
- * those elisions may depend upon changing the color output by the GrGeometryProcessor used by the
- * GrDrawOp. The op must check getOverrideColorIfSet() for this.
- */
-class GrPipelineOptimizations {
-public:
- /** Does the pipeline require access to (implicit or explicit) local coordinates? */
- bool readsLocalCoords() const {
- return SkToBool(kReadsLocalCoords_Flag & fFlags);
- }
-
- /** Does the pipeline allow the GrPrimitiveProcessor to combine color and coverage into one
- color output ? */
- bool canTweakAlphaForCoverage() const {
- return SkToBool(kCanTweakAlphaForCoverage_Flag & fFlags);
- }
-
- /** Does the pipeline require the GrPrimitiveProcessor to specify a specific color (and if
- so get the color)? */
- bool getOverrideColorIfSet(GrColor* overrideColor) const {
- if (SkToBool(kUseOverrideColor_Flag & fFlags)) {
- if (overrideColor) {
- *overrideColor = fOverrideColor;
- }
- return true;
- }
- return false;
- }
-
-private:
- enum {
- // If this is not set the primitive processor need not produce local coordinates
- kReadsLocalCoords_Flag = 0x1,
-
- // If this flag is set then the primitive processor may produce color*coverage as
- // its color output (and not output a separate coverage).
- kCanTweakAlphaForCoverage_Flag = 0x2,
-
- // If this flag is set the GrPrimitiveProcessor must produce fOverrideColor as its
- // output color. If not set fOverrideColor is to be ignored.
- kUseOverrideColor_Flag = 0x4,
- };
-
- uint32_t fFlags;
- GrColor fOverrideColor;
-
- friend class GrPipeline; // To initialize this
-};
-
/*
* GrPrimitiveProcessor defines an interface which all subclasses must implement. All
* GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh color / coverage
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index d17c187033..0e40a852c4 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -5,9 +5,9 @@
* found in the LICENSE file.
*/
#include "GrProgramDesc.h"
-
-#include "GrProcessor.h"
#include "GrPipeline.h"
+#include "GrPrimitiveProcessor.h"
+#include "GrProcessor.h"
#include "GrRenderTargetPriv.h"
#include "GrShaderCaps.h"
#include "GrTexturePriv.h"
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 79259b4aea..09d8267b25 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -753,7 +753,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
fUsesLocalCoords = optimizations.readsLocalCoords();
diff --git a/src/gpu/ops/GrAAFillRectOp.cpp b/src/gpu/ops/GrAAFillRectOp.cpp
index c6aadb92ed..991912923e 100644
--- a/src/gpu/ops/GrAAFillRectOp.cpp
+++ b/src/gpu/ops/GrAAFillRectOp.cpp
@@ -193,7 +193,7 @@ public:
return str;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
GrColor color;
if (optimizations.getOverrideColorIfSet(&color)) {
this->first()->setColor(color);
diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
index 494138d7b0..a243228298 100644
--- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
@@ -716,7 +716,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
fUsesLocalCoords = optimizations.readsLocalCoords();
}
diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
index c9add9d3e9..a62a41c911 100644
--- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
@@ -178,7 +178,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fPaths[0].fColor);
fUsesLocalCoords = optimizations.readsLocalCoords();
fCanTweakAlphaForCoverage = optimizations.canTweakAlphaForCoverage();
diff --git a/src/gpu/ops/GrAAStrokeRectOp.cpp b/src/gpu/ops/GrAAStrokeRectOp.cpp
index 89739e6116..5866b0d1f3 100644
--- a/src/gpu/ops/GrAAStrokeRectOp.cpp
+++ b/src/gpu/ops/GrAAStrokeRectOp.cpp
@@ -179,7 +179,7 @@ private:
color->setToConstant(fRects[0].fColor);
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations&) override;
+ void applyPipelineOptimizations(const PipelineOptimizations&) override;
void onPrepareDraws(Target*) const override;
static const int kMiterIndexCnt = 3 * 24;
@@ -230,7 +230,7 @@ private:
typedef GrMeshDrawOp INHERITED;
};
-void AAStrokeRectOp::applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) {
+void AAStrokeRectOp::applyPipelineOptimizations(const PipelineOptimizations& optimizations) {
optimizations.getOverrideColorIfSet(&fRects[0].fColor);
fUsesLocalCoords = optimizations.readsLocalCoords();
diff --git a/src/gpu/ops/GrAnalyticRectOp.cpp b/src/gpu/ops/GrAnalyticRectOp.cpp
index 87922cc60c..618414445c 100644
--- a/src/gpu/ops/GrAnalyticRectOp.cpp
+++ b/src/gpu/ops/GrAnalyticRectOp.cpp
@@ -275,7 +275,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fGeoData[0].fColor);
if (!optimizations.readsLocalCoords()) {
fViewMatrixIfUsingLocalCoords.reset();
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index f8c5443854..903382add7 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -68,7 +68,7 @@ void GrAtlasTextOp::getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor*
}
}
-void GrAtlasTextOp::applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) {
+void GrAtlasTextOp::applyPipelineOptimizations(const PipelineOptimizations& optimizations) {
optimizations.getOverrideColorIfSet(&fGeoData[0].fColor);
fColor = fGeoData[0].fColor;
diff --git a/src/gpu/ops/GrAtlasTextOp.h b/src/gpu/ops/GrAtlasTextOp.h
index 8c08544f7b..9dc5631c76 100644
--- a/src/gpu/ops/GrAtlasTextOp.h
+++ b/src/gpu/ops/GrAtlasTextOp.h
@@ -101,7 +101,7 @@ public:
private:
void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor*,
GrPipelineAnalysisCoverage*) const override;
- void applyPipelineOptimizations(const GrPipelineOptimizations&) override;
+ void applyPipelineOptimizations(const PipelineOptimizations&) override;
struct FlushInfo {
sk_sp<const GrBuffer> fVertexBuffer;
diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp
index 9dfacded7f..e623007f8d 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -302,7 +302,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
fUsesLocalCoords = optimizations.readsLocalCoords();
diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp
index 62c9d45439..79ad4843bd 100644
--- a/src/gpu/ops/GrDefaultPathRenderer.cpp
+++ b/src/gpu/ops/GrDefaultPathRenderer.cpp
@@ -139,7 +139,7 @@ private:
: GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
fUsesLocalCoords = optimizations.readsLocalCoords();
}
diff --git a/src/gpu/ops/GrDrawAtlasOp.cpp b/src/gpu/ops/GrDrawAtlasOp.cpp
index 7ef7e06317..36131e12c3 100644
--- a/src/gpu/ops/GrDrawAtlasOp.cpp
+++ b/src/gpu/ops/GrDrawAtlasOp.cpp
@@ -12,7 +12,7 @@
#include "SkRSXform.h"
#include "SkRandom.h"
-void GrDrawAtlasOp::applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) {
+void GrDrawAtlasOp::applyPipelineOptimizations(const PipelineOptimizations& optimizations) {
SkASSERT(fGeoData.count() == 1);
if (optimizations.getOverrideColorIfSet(&fGeoData[0].fColor) && fHasColors) {
size_t vertexStride =
diff --git a/src/gpu/ops/GrDrawAtlasOp.h b/src/gpu/ops/GrDrawAtlasOp.h
index a39a7a92f2..1094db0c4d 100644
--- a/src/gpu/ops/GrDrawAtlasOp.h
+++ b/src/gpu/ops/GrDrawAtlasOp.h
@@ -51,7 +51,7 @@ private:
void onPrepareDraws(Target*) const override;
- void applyPipelineOptimizations(const GrPipelineOptimizations&) override;
+ void applyPipelineOptimizations(const PipelineOptimizations&) override;
GrColor color() const { return fColor; }
const SkMatrix& viewMatrix() const { return fViewMatrix; }
diff --git a/src/gpu/ops/GrDrawPathOp.cpp b/src/gpu/ops/GrDrawPathOp.cpp
index 0a3df45cae..8a989b0abf 100644
--- a/src/gpu/ops/GrDrawPathOp.cpp
+++ b/src/gpu/ops/GrDrawPathOp.cpp
@@ -27,8 +27,7 @@ SkString GrDrawPathOp::dumpInfo() const {
return string;
}
-GrPipelineOptimizations GrDrawPathOpBase::initPipeline(const GrOpFlushState& state,
- GrPipeline* pipeline) {
+void GrDrawPathOpBase::initPipeline(const GrOpFlushState& state, GrPipeline* pipeline) {
static constexpr GrUserStencilSettings kCoverPass{
GrUserStencilSettings::StaticInit<
0x0000,
@@ -65,11 +64,9 @@ void init_stencil_pass_settings(const GrOpFlushState& flushState,
//////////////////////////////////////////////////////////////////////////////
void GrDrawPathOp::onExecute(GrOpFlushState* state) {
- GrColor color = this->color();
GrPipeline pipeline;
- GrPipelineOptimizations optimizations = this->initPipeline(*state, &pipeline);
- optimizations.getOverrideColorIfSet(&color);
- sk_sp<GrPathProcessor> pathProc(GrPathProcessor::Create(color, this->viewMatrix()));
+ this->initPipeline(*state, &pipeline);
+ sk_sp<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color(), this->viewMatrix()));
GrStencilSettings stencil;
init_stencil_pass_settings(*state, this->fillType(), &stencil);
diff --git a/src/gpu/ops/GrDrawPathOp.h b/src/gpu/ops/GrDrawPathOp.h
index 5650b888ba..78ed035bbe 100644
--- a/src/gpu/ops/GrDrawPathOp.h
+++ b/src/gpu/ops/GrDrawPathOp.h
@@ -39,7 +39,7 @@ protected:
GrColor color() const { return fAnalysis.inputColor(); }
GrPathRendering::FillType fillType() const { return fFillType; }
const GrProcessorSet& processors() const { return fProcessorSet; }
- GrPipelineOptimizations initPipeline(const GrOpFlushState&, GrPipeline*);
+ void initPipeline(const GrOpFlushState&, GrPipeline*);
const GrProcessorSet::FragmentProcessorAnalysis& doFragmentProcessorAnalysis(
const GrCaps& caps, const GrAppliedClip* clip) {
fProcessorSet.analyzeAndEliminateFragmentProcessors(
diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp
index d8f91fe946..6751009d37 100644
--- a/src/gpu/ops/GrDrawVerticesOp.cpp
+++ b/src/gpu/ops/GrDrawVerticesOp.cpp
@@ -84,7 +84,7 @@ void GrDrawVerticesOp::getFragmentProcessorAnalysisInputs(
*coverage = GrPipelineAnalysisCoverage::kNone;
}
-void GrDrawVerticesOp::applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) {
+void GrDrawVerticesOp::applyPipelineOptimizations(const PipelineOptimizations& optimizations) {
SkASSERT(fMeshes.count() == 1);
GrColor overrideColor;
if (optimizations.getOverrideColorIfSet(&overrideColor)) {
diff --git a/src/gpu/ops/GrDrawVerticesOp.h b/src/gpu/ops/GrDrawVerticesOp.h
index 176b552e09..17e54b705a 100644
--- a/src/gpu/ops/GrDrawVerticesOp.h
+++ b/src/gpu/ops/GrDrawVerticesOp.h
@@ -72,7 +72,7 @@ private:
void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color,
GrPipelineAnalysisCoverage* coverage) const override;
- void applyPipelineOptimizations(const GrPipelineOptimizations&) override;
+ void applyPipelineOptimizations(const PipelineOptimizations&) override;
void onPrepareDraws(Target*) const override;
sk_sp<GrGeometryProcessor> makeGP(bool* hasColorAttribute, bool* hasLocalCoordAttribute) const;
diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp
index 598a83907d..85ddd9d612 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -67,7 +67,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kNone;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& analysioptimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& analysioptimizations) override {
analysioptimizations.getOverrideColorIfSet(&fPatches[0].fColor);
}
diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp
index 4e7f0361bf..9f20808119 100644
--- a/src/gpu/ops/GrMSAAPathRenderer.cpp
+++ b/src/gpu/ops/GrMSAAPathRenderer.cpp
@@ -265,7 +265,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kNone;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fPaths[0].fColor);
}
diff --git a/src/gpu/ops/GrMeshDrawOp.h b/src/gpu/ops/GrMeshDrawOp.h
index cbf1f62eb7..2632feb3b7 100644
--- a/src/gpu/ops/GrMeshDrawOp.h
+++ b/src/gpu/ops/GrMeshDrawOp.h
@@ -40,7 +40,8 @@ public:
}
void initPipeline(const GrPipeline::InitArgs& args) {
- this->applyPipelineOptimizations(fPipeline.init(args));
+ fPipeline.init(args);
+ this->applyPipelineOptimizations(PipelineOptimizations(*args.fAnalysis));
}
/**
@@ -58,6 +59,62 @@ public:
protected:
GrMeshDrawOp(uint32_t classID);
+ /**
+ * This is a legacy class only used by GrMeshDrawOp and will be removed. It presents some
+ * aspects of GrProcessorSet::FragmentProcessorAnalysis to GrMeshDrawOp subclasses.
+ */
+ class PipelineOptimizations {
+ public:
+ PipelineOptimizations(const GrProcessorSet::FragmentProcessorAnalysis& analysis) {
+ fFlags = 0;
+ if (analysis.getInputColorOverrideAndColorProcessorEliminationCount(&fOverrideColor) >=
+ 0) {
+ fFlags |= kUseOverrideColor_Flag;
+ }
+ if (analysis.usesLocalCoords()) {
+ fFlags |= kReadsLocalCoords_Flag;
+ }
+ if (analysis.isCompatibleWithCoverageAsAlpha()) {
+ fFlags |= kCanTweakAlphaForCoverage_Flag;
+ }
+ }
+
+ /** Does the pipeline require access to (implicit or explicit) local coordinates? */
+ bool readsLocalCoords() const { return SkToBool(kReadsLocalCoords_Flag & fFlags); }
+
+ /** Does the pipeline allow the GrPrimitiveProcessor to combine color and coverage into one
+ color output ? */
+ bool canTweakAlphaForCoverage() const {
+ return SkToBool(kCanTweakAlphaForCoverage_Flag & fFlags);
+ }
+
+ /** Does the pipeline require the GrPrimitiveProcessor to specify a specific color (and if
+ so get the color)? */
+ bool getOverrideColorIfSet(GrColor* overrideColor) const {
+ if (SkToBool(kUseOverrideColor_Flag & fFlags)) {
+ if (overrideColor) {
+ *overrideColor = fOverrideColor;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private:
+ enum {
+ // If this is not set the primitive processor need not produce local coordinates
+ kReadsLocalCoords_Flag = 0x1,
+ // If this flag is set then the primitive processor may produce color*coverage as
+ // its color output (and not output a separate coverage).
+ kCanTweakAlphaForCoverage_Flag = 0x2,
+ // If this flag is set the GrPrimitiveProcessor must produce fOverrideColor as its
+ // output color. If not set fOverrideColor is to be ignored.
+ kUseOverrideColor_Flag = 0x4,
+ };
+
+ uint32_t fFlags;
+ GrColor fOverrideColor;
+ };
/** Helper for rendering instances using an instanced index index buffer. This class creates the
space for the vertices and flushes the draws to the GrMeshDrawOp::Target. */
@@ -111,7 +168,7 @@ private:
* After GrPipeline analysis is complete this is called so that the op can use the analysis
* results when constructing its GrPrimitiveProcessor.
*/
- virtual void applyPipelineOptimizations(const GrPipelineOptimizations&) = 0;
+ virtual void applyPipelineOptimizations(const PipelineOptimizations&) = 0;
void onPrepare(GrOpFlushState* state) final;
void onExecute(GrOpFlushState* state) final;
diff --git a/src/gpu/ops/GrNonAAFillRectOp.cpp b/src/gpu/ops/GrNonAAFillRectOp.cpp
index ce4b21fada..66a85156ba 100644
--- a/src/gpu/ops/GrNonAAFillRectOp.cpp
+++ b/src/gpu/ops/GrNonAAFillRectOp.cpp
@@ -116,7 +116,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kNone;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fRects[0].fColor);
}
diff --git a/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp b/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp
index 324ea43ccf..9ccc743ef0 100644
--- a/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp
+++ b/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp
@@ -136,7 +136,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kNone;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fRects[0].fColor);
}
diff --git a/src/gpu/ops/GrNonAAStrokeRectOp.cpp b/src/gpu/ops/GrNonAAStrokeRectOp.cpp
index 2f63d96327..940afee780 100644
--- a/src/gpu/ops/GrNonAAStrokeRectOp.cpp
+++ b/src/gpu/ops/GrNonAAStrokeRectOp.cpp
@@ -161,7 +161,7 @@ private:
target->draw(gp.get(), mesh);
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
fNeedsLocalCoords = optimizations.readsLocalCoords();
}
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 83e783ff2f..de4e4ea2f7 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -811,7 +811,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fGeoData[0].fColor);
if (!optimizations.readsLocalCoords()) {
fViewMatrixIfUsingLocalCoords.reset();
@@ -1263,7 +1263,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
if (!optimizations.readsLocalCoords()) {
fViewMatrixIfUsingLocalCoords.reset();
}
@@ -1478,7 +1478,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fGeoData[0].fColor);
fUsesLocalCoords = optimizations.readsLocalCoords();
}
@@ -1794,7 +1794,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fGeoData[0].fColor);
if (!optimizations.readsLocalCoords()) {
fViewMatrixIfUsingLocalCoords.reset();
@@ -2158,7 +2158,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fGeoData[0].fColor);
if (!optimizations.readsLocalCoords()) {
fViewMatrixIfUsingLocalCoords.reset();
diff --git a/src/gpu/ops/GrRegionOp.cpp b/src/gpu/ops/GrRegionOp.cpp
index 0ebec98e8f..88f96bf40c 100644
--- a/src/gpu/ops/GrRegionOp.cpp
+++ b/src/gpu/ops/GrRegionOp.cpp
@@ -83,7 +83,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kNone;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fRegions[0].fColor);
}
diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp
index bc1a4cca0a..56855a1324 100644
--- a/src/gpu/ops/GrShadowRRectOp.cpp
+++ b/src/gpu/ops/GrShadowRRectOp.cpp
@@ -148,7 +148,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fCircles[0].fColor);
if (!optimizations.readsLocalCoords()) {
fViewMatrixIfUsingLocalCoords.reset();
@@ -569,7 +569,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fGeoData[0].fColor);
if (!optimizations.readsLocalCoords()) {
fViewMatrixIfUsingLocalCoords.reset();
diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp
index 8d3f7b73ef..408bcfefe7 100644
--- a/src/gpu/ops/GrSmallPathRenderer.cpp
+++ b/src/gpu/ops/GrSmallPathRenderer.cpp
@@ -205,7 +205,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fShapes[0].fColor);
fUsesLocalCoords = optimizations.readsLocalCoords();
}
diff --git a/src/gpu/ops/GrTessellatingPathRenderer.cpp b/src/gpu/ops/GrTessellatingPathRenderer.cpp
index 914998878c..96fe8ab251 100644
--- a/src/gpu/ops/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp
@@ -186,7 +186,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
fCanTweakAlphaForCoverage = optimizations.canTweakAlphaForCoverage();
fNeedsLocalCoords = optimizations.readsLocalCoords();
diff --git a/src/gpu/ops/GrTestMeshDrawOp.h b/src/gpu/ops/GrTestMeshDrawOp.h
index a4bf066a34..8273abaed8 100644
--- a/src/gpu/ops/GrTestMeshDrawOp.h
+++ b/src/gpu/ops/GrTestMeshDrawOp.h
@@ -39,7 +39,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
fUsesLocalCoords = optimizations.readsLocalCoords();
}
diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp
index 46f9f6e27a..0170488158 100644
--- a/tests/GrPorterDuffTest.cpp
+++ b/tests/GrPorterDuffTest.cpp
@@ -1003,7 +1003,7 @@ static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const
*coverage = GrPipelineAnalysisCoverage::kLCD;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations&) override {}
+ void applyPipelineOptimizations(const PipelineOptimizations&) override {}
bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; }
void onPrepareDraws(Target*) const override {}
diff --git a/tests/PreFlushCallbackTest.cpp b/tests/PreFlushCallbackTest.cpp
index e008009efd..7c4092cca2 100644
--- a/tests/PreFlushCallbackTest.cpp
+++ b/tests/PreFlushCallbackTest.cpp
@@ -70,7 +70,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+ void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
}
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index 0a9d0021f0..2b4e3494a8 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -46,7 +46,7 @@ private:
*coverage = GrPipelineAnalysisCoverage::kSingleChannel;
}
- void applyPipelineOptimizations(const GrPipelineOptimizations&) override {}
+ void applyPipelineOptimizations(const PipelineOptimizations&) override {}
bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; }
void onPrepareDraws(Target* target) const override {
class GP : public GrGeometryProcessor {