Simplify parameters passed to path renderers
authorrobertphillips <robertphillips@google.com>
Thu, 13 Aug 2015 14:57:10 +0000 (07:57 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 13 Aug 2015 14:57:10 +0000 (07:57 -0700)
It appears that CanDrawPathArgs::fTarget was only ever used to access the shaderCaps and no instances of onGetStencilSupport ever used the drawTarget and pipelineBuilder parameters.

Review URL: https://codereview.chromium.org/1291803006

15 files changed:
src/gpu/GrAAConvexPathRenderer.cpp
src/gpu/GrAADistanceFieldPathRenderer.cpp
src/gpu/GrAADistanceFieldPathRenderer.h
src/gpu/GrAAHairLinePathRenderer.cpp
src/gpu/GrDashLinePathRenderer.h
src/gpu/GrDefaultPathRenderer.cpp
src/gpu/GrDefaultPathRenderer.h
src/gpu/GrPathRenderer.h
src/gpu/GrPathRendererChain.cpp
src/gpu/GrSoftwarePathRenderer.cpp
src/gpu/GrSoftwarePathRenderer.h
src/gpu/GrStencilAndCoverPathRenderer.cpp
src/gpu/GrStencilAndCoverPathRenderer.h
src/gpu/GrTessellatingPathRenderer.cpp
src/gpu/GrTessellatingPathRenderer.h

index 3d2ff456d71f3c570a943c7f843ef7f9017e5a7a..b5bea9f5533ae273db2eba0e9eaa8bb9f63d6c7a 100644 (file)
@@ -679,7 +679,7 @@ GrGeometryProcessor* QuadEdgeEffect::TestCreate(GrProcessorTestData* d) {
 ///////////////////////////////////////////////////////////////////////////////
 
 bool GrAAConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
-    return (args.fTarget->caps()->shaderCaps()->shaderDerivativeSupport() && args.fAntiAlias &&
+    return (args.fShaderCaps->shaderDerivativeSupport() && args.fAntiAlias &&
             args.fStroke->isFillStyle() && !args.fPath->isInverseFillType() &&
             args.fPath->isConvex());
 }
index 0428373a893c54038b97a048fc30c84dfdeb90b4..50116dd3cb3255a7b16fe41bfcb668616f1b9bd8 100755 (executable)
@@ -85,7 +85,7 @@ bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c
     
     // TODO: Support inverse fill
     // TODO: Support strokes
-    if (!args.fTarget->caps()->shaderCaps()->shaderDerivativeSupport() || !args.fAntiAlias ||
+    if (!args.fShaderCaps->shaderDerivativeSupport() || !args.fAntiAlias ||
         args.fPath->isInverseFillType() || args.fPath->isVolatile() ||
         !args.fStroke->isFillStyle()) {
         return false;
@@ -104,14 +104,6 @@ bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c
     return maxDim < 64.f && maxDim * maxScale < 256.f;
 }
 
-GrPathRenderer::StencilSupport
-GrAADistanceFieldPathRenderer::onGetStencilSupport(const GrDrawTarget*,
-                                                   const GrPipelineBuilder*,
-                                                   const SkPath&,
-                                                   const GrStrokeInfo&) const {
-    return GrPathRenderer::kNoSupport_StencilSupport;
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 
 // padding around path bounds to allow for antialiased pixels
index 30846e433ee2982fc3803138f7832bf3f9eaf5ad..469aeeb981241bce1dd4a34e7440f5ef59d17988 100755 (executable)
@@ -24,10 +24,9 @@ public:
     virtual ~GrAADistanceFieldPathRenderer();
 
 private:
-    StencilSupport onGetStencilSupport(const GrDrawTarget*,
-                                       const GrPipelineBuilder*,
-                                       const SkPath&,
-                                       const GrStrokeInfo&) const override;
+    StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override {
+        return GrPathRenderer::kNoSupport_StencilSupport;
+    }
 
     bool onCanDrawPath(const CanDrawPathArgs&) const override;
 
index df0095eaba6e07cc390fdad29affdb3a5fa77fdf..bfdff8dd864c75abb24aab2d8804abbac4530533 100644 (file)
@@ -627,7 +627,7 @@ bool GrAAHairLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const
     }
 
     if (SkPath::kLine_SegmentMask == args.fPath->getSegmentMasks() ||
-        args.fTarget->caps()->shaderCaps()->shaderDerivativeSupport()) {
+        args.fShaderCaps->shaderDerivativeSupport()) {
         return true;
     }
     return false;
index 2e37665e518602c3cfcaea453cc18e67b8d01df6..f21c73b688fa0f22adb710af7d43a8967164d0d8 100644 (file)
@@ -15,11 +15,8 @@ class GrDashLinePathRenderer : public GrPathRenderer {
 private:
     bool onCanDrawPath(const CanDrawPathArgs&) const override;
 
-    StencilSupport onGetStencilSupport(const GrDrawTarget*,
-                                       const GrPipelineBuilder*,
-                                       const SkPath&,
-                                       const GrStrokeInfo&) const override {
-      return kNoSupport_StencilSupport;
+    StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override {
+        return kNoSupport_StencilSupport;
     }
 
     bool onDrawPath(const DrawPathArgs&) override;
index 50fd20ac79c2ed06e3e4d3617a1243b030164f50..1dd9deb891dfa8aef546b4dc85b7c589b9187ec8 100644 (file)
@@ -169,10 +169,7 @@ static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& strok
 }
 
 GrPathRenderer::StencilSupport
-GrDefaultPathRenderer::onGetStencilSupport(const GrDrawTarget*,
-                                           const GrPipelineBuilder*,
-                                           const SkPath& path,
-                                           const GrStrokeInfo& stroke) const {
+GrDefaultPathRenderer::onGetStencilSupport(const SkPath& path, const GrStrokeInfo& stroke) const {
     if (single_pass_path(path, stroke)) {
         return GrPathRenderer::kNoRestriction_StencilSupport;
     } else {
index 2c1545ff700dfc3273f40976ee56e430fd1d20f4..8f82f25b09b5f720aa575a53aeb754075e243c0e 100644 (file)
@@ -21,10 +21,7 @@ public:
 
 private:
 
-    virtual StencilSupport onGetStencilSupport(const GrDrawTarget*,
-                                               const GrPipelineBuilder*,
-                                               const SkPath&,
-                                               const GrStrokeInfo&) const override;
+    StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override;
 
     bool onCanDrawPath(const CanDrawPathArgs&) const override;
 
index e353d6876fc1669129a646864fea4adcfeef8f95..50cf7483029e13f72bae86b29a5fd091edce3f36 100644 (file)
@@ -77,21 +77,17 @@ public:
      * This function is to get the stencil support for a particular path. The path's fill must
      * not be an inverse type.
      *
-     * @param target    target that the path will be rendered to
      * @param path      the path that will be drawn
      * @param stroke    the stroke information (width, join, cap).
      */
-    StencilSupport getStencilSupport(const GrDrawTarget* target,
-                                     const GrPipelineBuilder* pipelineBuilder,
-                                     const SkPath& path,
-                                     const GrStrokeInfo& stroke) const {
+    StencilSupport getStencilSupport(const SkPath& path, const GrStrokeInfo& stroke) const {
         SkASSERT(!path.isInverseFillType());
-        return this->onGetStencilSupport(target, pipelineBuilder, path, stroke);
+        return this->onGetStencilSupport(path, stroke);
     }
 
     /** Args to canDrawPath()
      *
-     * fTarget           The target that the path will be rendered to
+     * fShaderCaps       The shader caps
      * fPipelineBuilder  The pipelineBuilder
      * fViewMatrix       The viewMatrix
      * fPath             The path to draw
@@ -99,12 +95,21 @@ public:
      * fAntiAlias        True if anti-aliasing is required.
      */
     struct CanDrawPathArgs {
-        const GrDrawTarget*         fTarget;
-        const GrPipelineBuilder*    fPipelineBuilder;
+        const GrShaderCaps*         fShaderCaps;
+        const GrPipelineBuilder*    fPipelineBuilder;// only used by GrStencilAndCoverPathRenderer
         const SkMatrix*             fViewMatrix;
         const SkPath*               fPath;
         const GrStrokeInfo*         fStroke;
         bool                        fAntiAlias;
+
+        void validate() const {
+            SkASSERT(fShaderCaps);
+            SkASSERT(fPipelineBuilder);
+            SkASSERT(fViewMatrix);
+            SkASSERT(fPath);
+            SkASSERT(fStroke);
+            SkASSERT(!fPath->isEmpty());
+        }
     };
 
     /**
@@ -115,12 +120,7 @@ public:
      * @return  true if the path can be drawn by this object, false otherwise.
      */
     bool canDrawPath(const CanDrawPathArgs& args) const {
-        SkASSERT(args.fTarget);
-        SkASSERT(args.fPipelineBuilder);
-        SkASSERT(args.fViewMatrix);
-        SkASSERT(args.fPath);
-        SkASSERT(args.fStroke);
-        SkASSERT(!args.fPath->isEmpty());
+        SkDEBUGCODE(args.validate();)
         return this->onCanDrawPath(args);
     }
 
@@ -144,6 +144,16 @@ public:
         const SkPath*               fPath;
         const GrStrokeInfo*         fStroke;
         bool                        fAntiAlias;
+
+        void validate() const {
+            SkASSERT(fTarget);
+            SkASSERT(fResourceProvider);
+            SkASSERT(fPipelineBuilder);
+            SkASSERT(fViewMatrix);
+            SkASSERT(fPath);
+            SkASSERT(fStroke);
+            SkASSERT(!fPath->isEmpty());
+        }
     };
 
     /**
@@ -151,16 +161,10 @@ public:
      * the subclass must respect the stencil settings of the GrPipelineBuilder.
      */
     bool drawPath(const DrawPathArgs& args) {
-        SkASSERT(args.fTarget);
-        SkASSERT(args.fPipelineBuilder);
-        SkASSERT(args.fViewMatrix);
-        SkASSERT(args.fPath);
-        SkASSERT(args.fStroke);
-
-        SkASSERT(!args.fPath->isEmpty());
+        SkDEBUGCODE(args.validate();)
 #ifdef SK_DEBUG
         CanDrawPathArgs canArgs;
-        canArgs.fTarget = args.fTarget;
+        canArgs.fShaderCaps = args.fTarget->caps()->shaderCaps();
         canArgs.fPipelineBuilder = args.fPipelineBuilder;
         canArgs.fViewMatrix = args.fViewMatrix;
         canArgs.fPath = args.fPath;
@@ -168,9 +172,7 @@ public:
         canArgs.fAntiAlias = args.fAntiAlias;
         SkASSERT(this->canDrawPath(canArgs));
         SkASSERT(args.fPipelineBuilder->getStencil().isDisabled() ||
-                 kNoRestriction_StencilSupport == this->getStencilSupport(args.fTarget,
-                                                                          args.fPipelineBuilder,
-                                                                          *args.fPath,
+                 kNoRestriction_StencilSupport == this->getStencilSupport(*args.fPath,
                                                                           *args.fStroke));
 #endif
         return this->onDrawPath(args);
@@ -179,6 +181,7 @@ public:
     /* Args to stencilPath().
      *
      * fTarget                The target that the path will be rendered to.
+     * fResourceProvider      The resource provider for creating gpu resources to render the path
      * fPipelineBuilder       The pipeline builder.
      * fViewMatrix            Matrix applied to the path.
      * fPath                  The path to draw.
@@ -186,11 +189,21 @@ public:
      */
     struct StencilPathArgs {
         GrDrawTarget*       fTarget;
-        GrPipelineBuilder*  fPipelineBuilder;
         GrResourceProvider* fResourceProvider;
+        GrPipelineBuilder*  fPipelineBuilder;
         const SkMatrix*     fViewMatrix;
         const SkPath*       fPath;
         const GrStrokeInfo* fStroke;
+
+        void validate() const {
+            SkASSERT(fTarget);
+            SkASSERT(fResourceProvider);
+            SkASSERT(fPipelineBuilder);
+            SkASSERT(fViewMatrix);
+            SkASSERT(fPath);
+            SkASSERT(fStroke);
+            SkASSERT(!fPath->isEmpty());
+        }
     };
 
     /**
@@ -199,16 +212,9 @@ public:
      *
      */
     void stencilPath(const StencilPathArgs& args) {
-        SkASSERT(args.fTarget);
-        SkASSERT(args.fPipelineBuilder);
-        SkASSERT(args.fResourceProvider);
-        SkASSERT(args.fViewMatrix);
-        SkASSERT(args.fPath);
-        SkASSERT(args.fStroke);
-        SkASSERT(!args.fPath->isEmpty());
-        SkASSERT(kNoSupport_StencilSupport !=
-                 this->getStencilSupport(args.fTarget, args.fPipelineBuilder, *args.fPath,
-                                         *args.fStroke));
+        SkDEBUGCODE(args.validate();)
+        SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(*args.fPath, *args.fStroke));
+
         this->onStencilPath(args);
     }
 
@@ -250,10 +256,7 @@ private:
     /**
      * Subclass overrides if it has any limitations of stenciling support.
      */
-    virtual StencilSupport onGetStencilSupport(const GrDrawTarget*,
-                                               const GrPipelineBuilder*,
-                                               const SkPath&,
-                                               const GrStrokeInfo&) const {
+    virtual StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const {
         return kNoRestriction_StencilSupport;
     }
 
index 9bfa752e21fc1fc22d53a7fb846faa62e9921588..f5788511bdb2139c549c64016bf7a54af66eabdf 100644 (file)
@@ -61,7 +61,7 @@ GrPathRenderer* GrPathRendererChain::getPathRenderer(const GrDrawTarget* target,
 
     for (int i = 0; i < fChain.count(); ++i) {
         GrPathRenderer::CanDrawPathArgs args;
-        args.fTarget = target;
+        args.fShaderCaps = target->caps()->shaderCaps();
         args.fPipelineBuilder = pipelineBuilder;
         args.fViewMatrix = &viewMatrix;
         args.fPath = &path;
@@ -70,7 +70,7 @@ GrPathRenderer* GrPathRendererChain::getPathRenderer(const GrDrawTarget* target,
         if (fChain[i]->canDrawPath(args)) {
             if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport) {
                 GrPathRenderer::StencilSupport support =
-                    fChain[i]->getStencilSupport(target, pipelineBuilder, path, stroke);
+                                                       fChain[i]->getStencilSupport(path, stroke);
                 if (support < minStencilSupport) {
                     continue;
                 } else if (stencilSupport) {
index 401246ea5c6f7e0c3afb1f3298124d2d46a5061e..6e2babc259c68018450a6d33019db09f67997cba 100644 (file)
@@ -22,14 +22,6 @@ bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
     return true;
 }
 
-GrPathRenderer::StencilSupport
-GrSoftwarePathRenderer::onGetStencilSupport(const GrDrawTarget*,
-                                            const GrPipelineBuilder*,
-                                            const SkPath&,
-                                            const GrStrokeInfo&) const {
-    return GrPathRenderer::kNoSupport_StencilSupport;
-}
-
 namespace {
 
 ////////////////////////////////////////////////////////////////////////////////
index d7991b84a38715be47dd8f89a0f30e9d2fe942ad..72a95152e29bd1460a88394477381c9050b8ba5b 100644 (file)
@@ -23,10 +23,9 @@ public:
         : fContext(context) {
     }
 private:
-    virtual StencilSupport onGetStencilSupport(const GrDrawTarget*,
-                                               const GrPipelineBuilder*,
-                                               const SkPath&,
-                                               const GrStrokeInfo&) const override;
+    StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override {
+        return GrPathRenderer::kNoSupport_StencilSupport;
+    }
     
     bool onCanDrawPath(const CanDrawPathArgs&) const override;
 
index 4d92fb20c23ccc16da35b4e4f89a42e66ff1da7c..f871c3da7328b23b163ea8fda8231f9bb38b7f7e 100644 (file)
@@ -59,14 +59,6 @@ bool GrStencilAndCoverPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c
     }
 }
 
-GrPathRenderer::StencilSupport
-GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*,
-                                                   const GrPipelineBuilder*,
-                                                   const SkPath&,
-                                                   const GrStrokeInfo&) const {
-    return GrPathRenderer::kStencilOnly_StencilSupport;
-}
-
 static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const SkPath& skPath,
                            const GrStrokeInfo& stroke) {
     GrUniqueKey key;
index 5b6ce41dd8b4e11989cf397b7cf6f8f0c227e69a..bb8cdb0dd7724602ad608d17c5f8f113d5315b90 100644 (file)
@@ -25,10 +25,9 @@ public:
 
 
 private:
-    StencilSupport onGetStencilSupport(const GrDrawTarget*,
-                                       const GrPipelineBuilder*,
-                                       const SkPath&,
-                                       const GrStrokeInfo&) const override;
+    StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override {
+        return GrPathRenderer::kStencilOnly_StencilSupport;
+    }
 
     bool onCanDrawPath(const CanDrawPathArgs&) const override;
 
index 480952119bbb893a8115a626242f85540d906f56..9459cc55d1ec3e69cef56f3cf8017569edf8c0b1 100644 (file)
@@ -1360,14 +1360,6 @@ bool cache_match(GrVertexBuffer* vertexBuffer, SkScalar tol, int* actualCount) {
 GrTessellatingPathRenderer::GrTessellatingPathRenderer() {
 }
 
-GrPathRenderer::StencilSupport GrTessellatingPathRenderer::onGetStencilSupport(
-                                                            const GrDrawTarget*,
-                                                            const GrPipelineBuilder*,
-                                                            const SkPath&,
-                                                            const GrStrokeInfo&) const {
-    return GrPathRenderer::kNoSupport_StencilSupport;
-}
-
 namespace {
 
 // When the SkPathRef genID changes, invalidate a corresponding GrResource described by key.
index aa7be77168c88806bb43c379af6505d86fad69ac..7598ceb065a7995530ddb99e41d847203ea81276 100644 (file)
@@ -21,10 +21,9 @@ public:
 private:
     bool onCanDrawPath(const CanDrawPathArgs& ) const override;
 
-    StencilSupport onGetStencilSupport(const GrDrawTarget*,
-                                       const GrPipelineBuilder*,
-                                       const SkPath&,
-                                       const GrStrokeInfo&) const override;
+    StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override {
+        return GrPathRenderer::kNoSupport_StencilSupport;
+    }
 
     bool onDrawPath(const DrawPathArgs&) override;