Remove most modifiers of processors on GrPipelineBuilder
authorBrian Salomon <bsalomon@google.com>
Fri, 13 Jan 2017 17:11:36 +0000 (12:11 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Fri, 13 Jan 2017 20:08:16 +0000 (20:08 +0000)
Change-Id: I2fc12a97d694e5c0d86c9a4e0818a058905c8cf0
Reviewed-on: https://skia-review.googlesource.com/6993
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
include/gpu/GrPaint.h
src/gpu/GrPipelineBuilder.h
src/gpu/GrSWMaskHelper.cpp
src/gpu/ops/GrDefaultPathRenderer.cpp
src/gpu/ops/GrMSAAPathRenderer.cpp

index 0f3b525c1f6a3c8c83871ac4547e754da1b1c067..6897679e5d57036fe19163883859968005891e84 100644 (file)
@@ -199,7 +199,8 @@ public:
         }
     }
 
-    operator GrPaint&&() { return std::move(*fPaint); }
+    operator GrPaint&&() && { return std::move(*fPaint); }
+    GrPaint& paint() { return *fPaint; }
 
 private:
     SkTLazy<GrPaint> fStorage;
index 15af681c34d61bf29c1dc16a542db06363972ea0..66459ae9fdc11c4c2bc274e25792d79a214cb315 100644 (file)
@@ -61,41 +61,6 @@ public:
         return fCoverageFragmentProcessors[idx].get();
     }
 
-    void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
-        SkASSERT(processor);
-        fColorFragmentProcessors.push_back(std::move(processor));
-    }
-
-    void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
-        SkASSERT(processor);
-        fCoverageFragmentProcessors.push_back(std::move(processor));
-    }
-
-    /**
-     * Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
-     */
-    void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
-        this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, nullptr, matrix));
-    }
-
-    void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
-        this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, nullptr, matrix));
-    }
-
-    void addColorTextureProcessor(GrTexture* texture,
-                                  const SkMatrix& matrix,
-                                  const GrSamplerParams& params) {
-        this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, nullptr, matrix,
-                                                                    params));
-    }
-
-    void addCoverageTextureProcessor(GrTexture* texture,
-                                     const SkMatrix& matrix,
-                                     const GrSamplerParams& params) {
-        this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, nullptr, matrix,
-                                                                       params));
-    }
-
     /**
      * When this object is destroyed it will remove any color/coverage FPs from the pipeline builder
      * that were added after its constructor.
@@ -140,18 +105,6 @@ public:
     /// @name Blending
     ////
 
-    /**
-     * Installs a GrXPFactory. This object controls how src color, fractional pixel coverage,
-     * and the dst color are blended.
-     */
-    void setXPFactory(const GrXPFactory* xpFactory) { fXPFactory = xpFactory; }
-
-    /**
-     * Sets a GrXPFactory that disables color writes to the destination. This is useful when
-     * rendering to the stencil buffer.
-     */
-    void setDisableColorXPFactory() { fXPFactory = GrDisableColorXPFactory::Get(); }
-
     const GrXPFactory* getXPFactory() const { return fXPFactory; }
 
     /**
@@ -288,6 +241,13 @@ public:
     bool usePLSDstRead(const GrDrawOp*) const;
 
 private:
+    // This exists solely for AutoRestoreFragmentProcessor, which itself exists solely to install
+    // an applied clip's FP. This will be removed soon.
+    void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
+        SkASSERT(processor);
+        fCoverageFragmentProcessors.push_back(std::move(processor));
+    }
+
     // Some of the auto restore objects assume that no effects are removed during their lifetime.
     // This is used to assert that this condition holds.
     SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;)
index f85bbe6557feec507bd313958fa627dfbef4281a..240f9f9c3ca36419cbf79d2410eff3fdd0683b7d 100644 (file)
@@ -183,12 +183,9 @@ void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture,
     maskMatrix.preConcat(viewMatrix);
     std::unique_ptr<GrDrawOp> op = GrRectOpFactory::MakeNonAAFill(paint.getColor(), SkMatrix::I(),
                                                                   dstRect, nullptr, &invert);
+    paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(
+            texture, nullptr, maskMatrix, GrSamplerParams::kNone_FilterMode));
     GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone);
     pipelineBuilder.setUserStencil(&userStencilSettings);
-    pipelineBuilder.addCoverageFragmentProcessor(
-                         GrSimpleTextureEffect::Make(texture,
-                                                     nullptr,
-                                                     maskMatrix,
-                                                     GrSamplerParams::kNone_FilterMode));
     renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op));
 }
index 270dc09251cf0c21e3ffe8ae5badb4671d65fa89..e76ded3d5ac734de4cf6cc6f196aff84737b695a 100644 (file)
@@ -557,14 +557,15 @@ bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTarget
         } else {
             std::unique_ptr<GrDrawOp> op =
                     DefaultPathOp::Make(paint.getColor(), path, srcSpaceTol, newCoverage,
-
                                         viewMatrix, isHairline, devBounds);
-            GrPipelineBuilder pipelineBuilder(GrPaint::MoveOrNew(paint, lastPassIsBounds), aaType);
+            bool stencilPass = stencilOnly || passCount > 1;
+            GrPaint::MoveOrNew passPaint(paint, stencilPass);
+            if (stencilPass) {
+                passPaint.paint().setXPFactory(GrDisableColorXPFactory::Get());
+            }
+            GrPipelineBuilder pipelineBuilder(std::move(passPaint), aaType);
             pipelineBuilder.setDrawFace(drawFace[p]);
             pipelineBuilder.setUserStencil(passes[p]);
-            if (passCount > 1) {
-                pipelineBuilder.setDisableColorXPFactory();
-            }
             renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op));
         }
     }
index 5c1c110b0010ea5b7db98ce00ecec32965033957..26fdf5da82222943c715323f91b6161797bb87b2 100644 (file)
@@ -613,20 +613,25 @@ bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetCon
     SkRect devBounds;
     GetPathDevBounds(path, renderTargetContext->width(), renderTargetContext->height(), viewMatrix,
                      &devBounds);
-    SkASSERT(passes[0]);
 
-    std::unique_ptr<GrDrawOp> op = MSAAPathOp::Make(paint.getColor(), path, viewMatrix, devBounds);
-    if (!op) {
-        return false;
-    }
-    // If we have a cover pass then we ignore the paint in the first pass and apply it in the
-    // second.
-    GrPipelineBuilder pipelineBuilder(GrPaint::MoveOrNew(paint, passes[1]), aaType);
-    pipelineBuilder.setUserStencil(passes[0]);
-    if (passes[1]) {
-        pipelineBuilder.setDisableColorXPFactory();
+    SkASSERT(passes[0]);
+    {  // First pass
+        std::unique_ptr<GrDrawOp> op =
+                MSAAPathOp::Make(paint.getColor(), path, viewMatrix, devBounds);
+        if (!op) {
+            return false;
+        }
+        bool firstPassIsStencil = stencilOnly || passes[1];
+        // If we have a cover pass then we ignore the paint in the first pass and apply it in the
+        // second.
+        GrPaint::MoveOrNew firstPassPaint(paint, firstPassIsStencil);
+        if (firstPassIsStencil) {
+            firstPassPaint.paint().setXPFactory(GrDisableColorXPFactory::Get());
+        }
+        GrPipelineBuilder pipelineBuilder(std::move(firstPassPaint), aaType);
+        pipelineBuilder.setUserStencil(passes[0]);
+        renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op));
     }
-    renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op));
 
     if (passes[1]) {
         SkRect bounds;