Cleanup ops that are storing GrPipelineOptimizations.
authorBrian Salomon <bsalomon@google.com>
Wed, 4 Jan 2017 18:25:17 +0000 (13:25 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 5 Jan 2017 20:01:26 +0000 (20:01 +0000)
This is being stored and passed in places where it is unneeded or only 1 or 2 of its flags are needed.

Change-Id: Ifded9e645c0380e792708064ad69449653668acf
Reviewed-on: https://skia-review.googlesource.com/6583
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>

src/gpu/GrPathProcessor.cpp
src/gpu/GrPathProcessor.h
src/gpu/ops/GrAAFillRectOp.cpp
src/gpu/ops/GrDrawPathOp.cpp
src/gpu/ops/GrDrawPathOp.h
src/gpu/ops/GrLatticeOp.cpp
src/gpu/ops/GrNonAAFillRectOp.cpp
src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp
src/gpu/ops/GrNonAAStrokeRectOp.cpp
src/gpu/ops/GrRegionOp.cpp
src/gpu/ops/GrTessellatingPathRenderer.cpp

index 910c3c9..39d418b 100644 (file)
@@ -114,13 +114,11 @@ private:
 };
 
 GrPathProcessor::GrPathProcessor(GrColor color,
-                                 const GrPipelineOptimizations& optimizations,
                                  const SkMatrix& viewMatrix,
                                  const SkMatrix& localMatrix)
         : fColor(color)
         , fViewMatrix(viewMatrix)
-        , fLocalMatrix(localMatrix)
-        , fOptimizations(optimizations) {
+        , fLocalMatrix(localMatrix) {
     this->initClassID<GrPathProcessor>();
 }
 
index fe29d03..581bd50 100644 (file)
 class GrPathProcessor : public GrPrimitiveProcessor {
 public:
     static GrPathProcessor* Create(GrColor color,
-                                   const GrPipelineOptimizations& optimizations,
                                    const SkMatrix& viewMatrix = SkMatrix::I(),
                                    const SkMatrix& localMatrix = SkMatrix::I()) {
-        return new GrPathProcessor(color, optimizations, viewMatrix, localMatrix);
+        return new GrPathProcessor(color, viewMatrix, localMatrix);
     }
 
     const char* name() const override { return "PathProcessor"; }
@@ -36,20 +35,16 @@ public:
 
     virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
 
-    const GrPipelineOptimizations& optimizations() const { return fOptimizations; }
-
     virtual bool isPathRendering() const override { return true; }
 
 private:
-    GrPathProcessor(GrColor, const GrPipelineOptimizations&, const SkMatrix& viewMatrix,
-                    const SkMatrix& localMatrix);
+    GrPathProcessor(GrColor, const SkMatrix& viewMatrix, const SkMatrix& localMatrix);
 
     bool hasExplicitLocalCoords() const override { return false; }
 
     GrColor fColor;
     const SkMatrix fViewMatrix;
     const SkMatrix fLocalMatrix;
-    GrPipelineOptimizations fOptimizations;
 
     typedef GrPrimitiveProcessor INHERITED;
 };
index 6ef48cb..5c585bf 100644 (file)
@@ -52,7 +52,7 @@ static void generate_aa_fill_rect_geometry(intptr_t verts,
                                            const SkMatrix& viewMatrix,
                                            const SkRect& rect,
                                            const SkRect& devRect,
-                                           const GrPipelineOptimizations& optimizations,
+                                           bool tweakAlphaForCoverage,
                                            const SkMatrix* localMatrix) {
     SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
     SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vertexStride);
@@ -115,8 +115,6 @@ static void generate_aa_fill_rect_geometry(intptr_t verts,
         localCoordMatrix.mapPointsWithStride(fan0Loc, fan0Pos, vertexStride, 8);
     }
 
-    bool tweakAlphaForCoverage = optimizations.canTweakAlphaForCoverage();
-
     // Make verts point to vertex color and then set all the color and coverage vertex attrs
     // values.
     verts += sizeof(SkPoint);
@@ -200,7 +198,8 @@ public:
         if (optimizations.getOverrideColorIfSet(&color)) {
             this->first()->setColor(color);
         }
-        fOptimizations = optimizations;
+        fCanTweakAlphaForCoverage = optimizations.canTweakAlphaForCoverage();
+        fNeedsLocalCoords = optimizations.readsLocalCoords();
     }
 
 private:
@@ -210,18 +209,17 @@ private:
     }
 
     void onPrepareDraws(Target* target) const override {
-        bool needLocalCoords = fOptimizations.readsLocalCoords();
         using namespace GrDefaultGeoProcFactory;
 
         Color color(Color::kAttribute_Type);
         Coverage::Type coverageType;
-        if (fOptimizations.canTweakAlphaForCoverage()) {
+        if (fCanTweakAlphaForCoverage) {
             coverageType = Coverage::kSolid_Type;
         } else {
             coverageType = Coverage::kAttribute_Type;
         }
         LocalCoords lc =
-                needLocalCoords ? LocalCoords::kHasExplicit_Type : LocalCoords::kUnused_Type;
+                fNeedsLocalCoords ? LocalCoords::kHasExplicit_Type : LocalCoords::kUnused_Type;
         sk_sp<GrGeometryProcessor> gp =
                 GrDefaultGeoProcFactory::Make(color, coverageType, lc, SkMatrix::I());
         if (!gp) {
@@ -246,7 +244,7 @@ private:
         for (int i = 0; i < fRectCnt; i++) {
             intptr_t verts =
                     reinterpret_cast<intptr_t>(vertices) + i * kVertsPerAAFillRect * vertexStride;
-            if (needLocalCoords) {
+            if (fNeedsLocalCoords) {
                 if (info->hasLocalMatrix()) {
                     localMatrix = &static_cast<const RectWithLocalMatrixInfo*>(info)->localMatrix();
                 } else {
@@ -254,7 +252,7 @@ private:
                 }
             }
             generate_aa_fill_rect_geometry(verts, vertexStride, info->color(), info->viewMatrix(),
-                                           info->rect(), info->devRect(), fOptimizations,
+                                           info->rect(), info->devRect(), fCanTweakAlphaForCoverage,
                                            localMatrix);
             info = this->next(info);
         }
@@ -268,11 +266,12 @@ private:
             return false;
         }
 
+        SkASSERT(fNeedsLocalCoords == that->fNeedsLocalCoords);
+
         // In the event of two ops, one who can tweak, one who cannot, we just fall back to not
         // tweaking.
-        if (fOptimizations.canTweakAlphaForCoverage() &&
-            !that->fOptimizations.canTweakAlphaForCoverage()) {
-            fOptimizations = that->fOptimizations;
+        if (fCanTweakAlphaForCoverage && !that->fCanTweakAlphaForCoverage) {
+            fCanTweakAlphaForCoverage = false;
         }
 
         fRectData.push_back_n(that->fRectData.count(), that->fRectData.begin());
@@ -333,7 +332,8 @@ private:
         return reinterpret_cast<const RectInfo*>(next);
     }
 
-    GrPipelineOptimizations fOptimizations;
+    bool fNeedsLocalCoords;
+    bool fCanTweakAlphaForCoverage;
     SkSTArray<4 * sizeof(RectWithLocalMatrixInfo), uint8_t, true> fRectData;
     int fRectCnt;
 
index e60311b..a32d708 100644 (file)
@@ -31,7 +31,7 @@ void GrDrawPathOp::onExecute(GrOpFlushState* state, const SkRect& bounds) {
     GrProgramDesc desc;
 
     sk_sp<GrPathProcessor> pathProc(
-            GrPathProcessor::Create(this->color(), this->optimizations(), this->viewMatrix()));
+            GrPathProcessor::Create(this->color(), this->viewMatrix()));
     state->gpu()->pathRendering()->drawPath(*this->pipeline(), *pathProc,
                                             this->stencilPassSettings(), fPath.get());
 }
@@ -100,10 +100,10 @@ bool GrDrawPathRangeOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
     // combined. (Glyphs in the same font tend to wind the same direction so it works out OK.)
     if (GrPathRendering::kWinding_FillType != this->fillType() ||
         GrPathRendering::kWinding_FillType != that->fillType() ||
-        this->optimizations().willColorBlendWithDst()) {
+        this->blendsWithDst()) {
         return false;
     }
-    SkASSERT(!that->optimizations().willColorBlendWithDst());
+    SkASSERT(!that->blendsWithDst());
     fTotalPathCount += that->fTotalPathCount;
     while (Draw* head = that->fDraws.head()) {
         Draw* draw = fDraws.addToTail();
@@ -128,7 +128,7 @@ void GrDrawPathRangeOp::onExecute(GrOpFlushState* state, const SkRect& bounds) {
     localMatrix.preTranslate(head.fX, head.fY);
 
     sk_sp<GrPathProcessor> pathProc(
-            GrPathProcessor::Create(this->color(), this->optimizations(), drawMatrix, localMatrix));
+            GrPathProcessor::Create(this->color(), drawMatrix, localMatrix));
 
     if (fDraws.count() == 1) {
         const InstanceData& instances = *head.fInstanceData;
index b34f15e..a18a351 100644 (file)
@@ -30,10 +30,10 @@ protected:
     }
 
 protected:
-    const GrPipelineOptimizations& optimizations() const { return fOptimizations; }
     const SkMatrix& viewMatrix() const { return fViewMatrix; }
     GrColor color() const { return fColor; }
     GrPathRendering::FillType fillType() const { return fFillType; }
+    bool blendsWithDst() const { return fBlendsWithDst; }
 
 private:
     void getPipelineAnalysisInput(GrPipelineAnalysisDrawOpInput* input) const override {
@@ -43,7 +43,7 @@ private:
 
     void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
         optimizations.getOverrideColorIfSet(&fColor);
-        fOptimizations = optimizations;
+        fBlendsWithDst = optimizations.willColorBlendWithDst();
     }
 
     void onPrepare(GrOpFlushState*) override;  // Initializes fStencilPassSettings.
@@ -52,7 +52,7 @@ private:
     GrColor fColor;
     GrPathRendering::FillType fFillType;
     GrStencilSettings fStencilPassSettings;
-    GrPipelineOptimizations fOptimizations;
+    bool fBlendsWithDst;
 
     typedef GrDrawOp INHERITED;
 };
index 9141b34..93c6f0f 100644 (file)
@@ -68,7 +68,6 @@ private:
 
     void applyPipelineOptimizations(const GrPipelineOptimizations& analysioptimizations) override {
         analysioptimizations.getOverrideColorIfSet(&fPatches[0].fColor);
-        fOptimizations = analysioptimizations;
     }
 
     void onPrepareDraws(Target* target) const override {
@@ -146,13 +145,6 @@ private:
         SkASSERT(this->fImageWidth == that->fImageWidth &&
                  this->fImageHeight == that->fImageHeight);
 
-        // In the event of two ops, one who can tweak, one who cannot, we just fall back to not
-        // tweaking.
-        if (fOptimizations.canTweakAlphaForCoverage() &&
-            !that->fOptimizations.canTweakAlphaForCoverage()) {
-            fOptimizations = that->fOptimizations;
-        }
-
         fPatches.move_back_n(that->fPatches.count(), that->fPatches.begin());
         this->joinBounds(*that);
         return true;
@@ -165,7 +157,6 @@ private:
         GrColor fColor;
     };
 
-    GrPipelineOptimizations fOptimizations;
     int fImageWidth;
     int fImageHeight;
     SkSTArray<1, Patch, true> fPatches;
index 1e4fde4..eb2143d 100644 (file)
@@ -117,7 +117,6 @@ private:
 
     void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
         optimizations.getOverrideColorIfSet(&fRects[0].fColor);
-        fOptimizations = optimizations;
     }
 
     void onPrepareDraws(Target* target) const override {
@@ -158,13 +157,6 @@ private:
             return false;
         }
 
-        // In the event of two ops, one who can tweak, one who cannot, we just fall back to not
-        // tweaking.
-        if (fOptimizations.canTweakAlphaForCoverage() &&
-            !that->fOptimizations.canTweakAlphaForCoverage()) {
-            fOptimizations = that->fOptimizations;
-        }
-
         fRects.push_back_n(that->fRects.count(), that->fRects.begin());
         this->joinBounds(*that);
         return true;
@@ -177,7 +169,6 @@ private:
         GrQuad fLocalQuad;
     };
 
-    GrPipelineOptimizations fOptimizations;
     SkSTArray<1, RectInfo, true> fRects;
 
     typedef GrMeshDrawOp INHERITED;
index 284556b..b919a0d 100644 (file)
@@ -136,7 +136,6 @@ private:
 
     void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
         optimizations.getOverrideColorIfSet(&fRects[0].fColor);
-        fOptimizations = optimizations;
     }
 
     void onPrepareDraws(Target* target) const override {
@@ -198,13 +197,6 @@ private:
             return false;
         }
 
-        // In the event of two ops, one who can tweak, one who cannot, we just fall back to not
-        // tweaking.
-        if (fOptimizations.canTweakAlphaForCoverage() &&
-            !that->fOptimizations.canTweakAlphaForCoverage()) {
-            fOptimizations = that->fOptimizations;
-        }
-
         fRects.push_back_n(that->fRects.count(), that->fRects.begin());
         this->joinBounds(*that);
         return true;
@@ -216,7 +208,6 @@ private:
         SkRect fLocalRect;
     };
 
-    GrPipelineOptimizations fOptimizations;
     SkSTArray<1, RectInfo, true> fRects;
     bool fHasLocalMatrix;
     bool fHasLocalRect;
index 0732e4e..417d76e 100644 (file)
@@ -111,7 +111,7 @@ private:
         {
             using namespace GrDefaultGeoProcFactory;
             Color color(fColor);
-            LocalCoords::Type localCoordsType = fOptimizations.readsLocalCoords()
+            LocalCoords::Type localCoordsType = fNeedsLocalCoords
                                                         ? LocalCoords::kUsePosition_Type
                                                         : LocalCoords::kUnused_Type;
             gp = GrDefaultGeoProcFactory::Make(color, Coverage::kSolid_Type, localCoordsType,
@@ -161,7 +161,7 @@ private:
 
     void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
         optimizations.getOverrideColorIfSet(&fColor);
-        fOptimizations = optimizations;
+        fNeedsLocalCoords = optimizations.readsLocalCoords();
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps&) override {
@@ -174,7 +174,7 @@ private:
     SkMatrix fViewMatrix;
     SkRect fRect;
     SkScalar fStrokeWidth;
-    GrPipelineOptimizations fOptimizations;
+    bool fNeedsLocalCoords;
 
     const static int kVertsPerHairlineRect = 5;
     const static int kVertsPerStrokeRect = 10;
index ea0af73..32a8150 100644 (file)
@@ -84,7 +84,6 @@ private:
 
     void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
         optimizations.getOverrideColorIfSet(&fRegions[0].fColor);
-        fOptimizations = optimizations;
     }
 
     void onPrepareDraws(Target* target) const override {
@@ -143,7 +142,6 @@ private:
     };
 
     SkMatrix fViewMatrix;
-    GrPipelineOptimizations fOptimizations;
     SkSTArray<1, RegionInfo, true> fRegions;
 
     typedef GrMeshDrawOp INHERITED;
index 183ab31..a40127a 100644 (file)
@@ -187,7 +187,8 @@ private:
 
     void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
         optimizations.getOverrideColorIfSet(&fColor);
-        fOptimizations = optimizations;
+        fCanTweakAlphaForCoverage = optimizations.canTweakAlphaForCoverage();
+        fNeedsLocalCoords = optimizations.readsLocalCoords();
     }
 
     SkPath getPath() const {
@@ -259,9 +260,8 @@ private:
         SkScalar tol = GrPathUtils::kDefaultTolerance;
         bool isLinear;
         DynamicVertexAllocator allocator(gp->getVertexStride(), target);
-        bool canTweakAlphaForCoverage = fOptimizations.canTweakAlphaForCoverage();
         int count = GrTessellator::PathToTriangles(path, tol, clipBounds, &allocator,
-                                                   true, fColor, canTweakAlphaForCoverage,
+                                                   true, fColor, fCanTweakAlphaForCoverage,
                                                    &isLinear);
         if (count == 0) {
             return;
@@ -275,13 +275,13 @@ private:
             using namespace GrDefaultGeoProcFactory;
 
             Color color(fColor);
-            LocalCoords::Type localCoordsType = fOptimizations.readsLocalCoords()
+            LocalCoords::Type localCoordsType = fNeedsLocalCoords
                                                         ? LocalCoords::kUsePosition_Type
                                                         : LocalCoords::kUnused_Type;
             Coverage::Type coverageType;
             if (fAntiAlias) {
                 color = Color(Color::kAttribute_Type);
-                if (fOptimizations.canTweakAlphaForCoverage()) {
+                if (fCanTweakAlphaForCoverage) {
                     coverageType = Coverage::kSolid_Type;
                 } else {
                     coverageType = Coverage::kAttribute_Type;
@@ -341,7 +341,8 @@ private:
     SkMatrix                fViewMatrix;
     SkIRect                 fDevClipBounds;
     bool                    fAntiAlias;
-    GrPipelineOptimizations fOptimizations;
+    bool                    fCanTweakAlphaForCoverage;
+    bool                    fNeedsLocalCoords;
 
     typedef GrMeshDrawOp INHERITED;
 };