Revert of Bundle common arguments to GrGradientEffect creation (patchset #2 id:20001...
authordjsollen <djsollen@google.com>
Thu, 15 Sep 2016 02:57:59 +0000 (19:57 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 15 Sep 2016 02:57:59 +0000 (19:57 -0700)
Reason for revert:
This seems to be causing the autoroll into Chromium to fail.

https://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/builds/69618/steps/compile/logs/stdio

Original issue's description:
> Bundle common arguments to GrGradientEffect creation
>
> I'm going to be adding more (to deal with color spaces), so trying to fix
> this before it gets out of control.
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2332213007
>
> Committed: https://skia.googlesource.com/skia/+/f605c16a030d791a37f589e6bddd7158ba5d62cd

TBR=bsalomon@google.com,robertphillips@google.com,brianosman@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review-Url: https://codereview.chromium.org/2343703003

src/effects/gradients/SkGradientShader.cpp
src/effects/gradients/SkGradientShaderPriv.h
src/effects/gradients/SkLinearGradient.cpp
src/effects/gradients/SkRadialGradient.cpp
src/effects/gradients/SkSweepGradient.cpp
src/effects/gradients/SkTwoPointConicalGradient.cpp
src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
src/effects/gradients/SkTwoPointConicalGradient_gpu.h

index 14e6784..eccc21a 100644 (file)
@@ -1332,8 +1332,10 @@ void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBui
 
 /////////////////////////////////////////////////////////////////////
 
-GrGradientEffect::GrGradientEffect(const CreateArgs& args) {
-    const SkGradientShaderBase& shader(*args.fShader);
+GrGradientEffect::GrGradientEffect(GrContext* ctx,
+                                   const SkGradientShaderBase& shader,
+                                   const SkMatrix& matrix,
+                                   SkShader::TileMode tileMode) {
 
     fIsOpaque = shader.isOpaque();
 
@@ -1352,7 +1354,7 @@ GrGradientEffect::GrGradientEffect(const CreateArgs& args) {
     }
 
 #if GR_GL_USE_ACCURATE_HARD_STOP_GRADIENTS
-    fTileMode = args.fTileMode;
+    fTileMode = tileMode;
 #endif
 
     switch (fColorType) {
@@ -1372,7 +1374,7 @@ GrGradientEffect::GrGradientEffect(const CreateArgs& args) {
                 fPremulType = kAfterInterp_PremulType;
             }
 
-            fCoordTransform.reset(kCoordSet, *args.fMatrix);
+            fCoordTransform.reset(kCoordSet, matrix);
 
             break;
         case kTexture_ColorType:
@@ -1387,8 +1389,8 @@ GrGradientEffect::GrGradientEffect(const CreateArgs& args) {
             desc.fWidth  = bitmap.width();
             desc.fHeight = 32;
             desc.fRowHeight = bitmap.height();
-            desc.fContext = args.fContext;
-            desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *args.fContext->caps());
+            desc.fContext = ctx;
+            desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *ctx->caps());
             fAtlas = GrTextureStripAtlas::GetAtlas(desc);
             SkASSERT(fAtlas);
 
@@ -1396,22 +1398,21 @@ GrGradientEffect::GrGradientEffect(const CreateArgs& args) {
             // y-clamp.
             GrTextureParams params;
             params.setFilterMode(GrTextureParams::kBilerp_FilterMode);
-            params.setTileModeX(args.fTileMode);
+            params.setTileModeX(tileMode);
 
             fRow = fAtlas->lockRow(bitmap);
             if (-1 != fRow) {
                 fYCoord = fAtlas->getYOffset(fRow)+SK_ScalarHalf*fAtlas->getNormalizedTexelHeight();
-                fCoordTransform.reset(kCoordSet, *args.fMatrix, fAtlas->getTexture(),
-                                      params.filterMode());
+                fCoordTransform.reset(kCoordSet, matrix, fAtlas->getTexture(), params.filterMode());
                 fTextureAccess.reset(fAtlas->getTexture(), params);
             } else {
                 SkAutoTUnref<GrTexture> texture(
-                    GrRefCachedBitmapTexture(args.fContext, bitmap, params,
+                    GrRefCachedBitmapTexture(ctx, bitmap, params,
                                              SkSourceGammaTreatment::kRespect));
                 if (!texture) {
                     return;
                 }
-                fCoordTransform.reset(kCoordSet, *args.fMatrix, texture, params.filterMode());
+                fCoordTransform.reset(kCoordSet, matrix, texture, params.filterMode());
                 fTextureAccess.reset(texture, params);
                 fYCoord = SK_ScalarHalf;
             }
index ec70929..ee30c9b 100644 (file)
@@ -323,25 +323,12 @@ class GrInvariantOutput;
 // Base class for Gr gradient effects
 class GrGradientEffect : public GrFragmentProcessor {
 public:
-    struct CreateArgs {
-        CreateArgs(GrContext* context,
-                   const SkGradientShaderBase* shader,
-                   const SkMatrix* matrix,
-                   SkShader::TileMode tileMode)
-            : fContext(context)
-            , fShader(shader)
-            , fMatrix(matrix)
-            , fTileMode(tileMode) {}
-
-        GrContext*                  fContext;
-        const SkGradientShaderBase* fShader;
-        const SkMatrix*             fMatrix;
-        SkShader::TileMode          fTileMode;
-    };
-
     class GLSLProcessor;
 
-    GrGradientEffect(const CreateArgs&);
+    GrGradientEffect(GrContext* ctx,
+                     const SkGradientShaderBase& shader,
+                     const SkMatrix& matrix,
+                     SkShader::TileMode tileMode);
 
     virtual ~GrGradientEffect();
 
index a93235d..98b621e 100644 (file)
@@ -351,8 +351,11 @@ class GrLinearGradient : public GrGradientEffect {
 public:
     class GLSLLinearProcessor;
 
-    static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) {
-        return sk_sp<GrFragmentProcessor>(new GrLinearGradient(args));
+    static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+                                           const SkLinearGradient& shader,
+                                           const SkMatrix& matrix,
+                                           SkShader::TileMode tm) {
+        return sk_sp<GrFragmentProcessor>(new GrLinearGradient(ctx, shader, matrix, tm));
     }
 
     virtual ~GrLinearGradient() { }
@@ -360,8 +363,11 @@ public:
     const char* name() const override { return "Linear Gradient"; }
 
 private:
-    GrLinearGradient(const CreateArgs& args)
-        : INHERITED(args) {
+    GrLinearGradient(GrContext* ctx,
+                     const SkLinearGradient& shader,
+                     const SkMatrix& matrix,
+                     SkShader::TileMode tm)
+        : INHERITED(ctx, shader, matrix, tm) {
         this->initClassID<GrLinearGradient>();
     }
 
@@ -461,8 +467,8 @@ sk_sp<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(const AsFPArgs&
     }
     matrix.postConcat(fPtsToUnit);
 
-    sk_sp<GrFragmentProcessor> inner(GrLinearGradient::Make(
-        GrGradientEffect::CreateArgs(args.fContext, this, &matrix, fTileMode)));
+    sk_sp<GrFragmentProcessor> inner(
+        GrLinearGradient::Make(args.fContext, *this, matrix, fTileMode));
     return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
 }
 
index 5691188..1fbd171 100644 (file)
@@ -246,8 +246,11 @@ class GrRadialGradient : public GrGradientEffect {
 public:
     class GLSLRadialProcessor;
 
-    static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) {
-        return sk_sp<GrFragmentProcessor>(new GrRadialGradient(args));
+    static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+                                           const SkRadialGradient& shader,
+                                           const SkMatrix& matrix,
+                                           SkShader::TileMode tm) {
+        return sk_sp<GrFragmentProcessor>(new GrRadialGradient(ctx, shader, matrix, tm));
     }
 
     virtual ~GrRadialGradient() { }
@@ -255,8 +258,11 @@ public:
     const char* name() const override { return "Radial Gradient"; }
 
 private:
-    GrRadialGradient(const CreateArgs& args)
-        : INHERITED(args) {
+    GrRadialGradient(GrContext* ctx,
+                     const SkRadialGradient& shader,
+                     const SkMatrix& matrix,
+                     SkShader::TileMode tm)
+        : INHERITED(ctx, shader, matrix, tm) {
         this->initClassID<GrRadialGradient>();
     }
 
@@ -355,8 +361,8 @@ sk_sp<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(const AsFPArgs&
         matrix.postConcat(inv);
     }
     matrix.postConcat(fPtsToUnit);
-    sk_sp<GrFragmentProcessor> inner(GrRadialGradient::Make(
-        GrGradientEffect::CreateArgs(args.fContext, this, &matrix, fTileMode)));
+    sk_sp<GrFragmentProcessor> inner(
+        GrRadialGradient::Make(args.fContext, *this, matrix, fTileMode));
     return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
 }
 
index 0789237..bdb0e1c 100644 (file)
@@ -129,16 +129,19 @@ class GrSweepGradient : public GrGradientEffect {
 public:
     class GLSLSweepProcessor;
 
-    static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) {
-        return sk_sp<GrFragmentProcessor>(new GrSweepGradient(args));
+    static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, const SkSweepGradient& shader,
+                                           const SkMatrix& m) {
+        return sk_sp<GrFragmentProcessor>(new GrSweepGradient(ctx, shader, m));
     }
     virtual ~GrSweepGradient() { }
 
     const char* name() const override { return "Sweep Gradient"; }
 
 private:
-    GrSweepGradient(const CreateArgs& args)
-    : INHERITED(args) {
+    GrSweepGradient(GrContext* ctx,
+                    const SkSweepGradient& shader,
+                    const SkMatrix& matrix)
+    : INHERITED(ctx, shader, matrix, SkShader::kClamp_TileMode) {
         this->initClassID<GrSweepGradient>();
     }
 
@@ -247,8 +250,7 @@ sk_sp<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(const AsFPArgs&
     }
     matrix.postConcat(fPtsToUnit);
 
-    sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make(
-        GrGradientEffect::CreateArgs(args.fContext, this, &matrix, SkShader::kClamp_TileMode)));
+    sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make(args.fContext, *this, matrix));
     return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
 }
 
index 84f1ae8..9c09701 100644 (file)
@@ -360,8 +360,8 @@ sk_sp<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProcessor(
         const AsFPArgs& args) const {
     SkASSERT(args.fContext);
     SkASSERT(fPtsToUnit.isIdentity());
-    sk_sp<GrFragmentProcessor> inner(Gr2PtConicalGradientEffect::Make(
-        GrGradientEffect::CreateArgs(args.fContext, this, args.fLocalMatrix, fTileMode)));
+    sk_sp<GrFragmentProcessor> inner(
+        Gr2PtConicalGradientEffect::Make(args.fContext, *this, fTileMode, args.fLocalMatrix));
     return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
 }
 
index a581321..e89193f 100644 (file)
@@ -62,8 +62,11 @@ class Edge2PtConicalEffect : public GrGradientEffect {
 public:
     class GLSLEdge2PtConicalProcessor;
 
-    static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) {
-        return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(args));
+    static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+                                           const SkTwoPointConicalGradient& shader,
+                                           const SkMatrix& matrix,
+                                           SkShader::TileMode tm) {
+        return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(ctx, shader, matrix, tm));
     }
 
     virtual ~Edge2PtConicalEffect() {}
@@ -90,13 +93,14 @@ private:
                 this->fDiffRadius == s.fDiffRadius);
     }
 
-    Edge2PtConicalEffect(const CreateArgs& args)
-        : INHERITED(args) {
-        const SkTwoPointConicalGradient& shader =
-            *static_cast<const SkTwoPointConicalGradient*>(args.fShader);
-        fCenterX1 = shader.getCenterX1();
-        fRadius0 = shader.getStartRadius();
-        fDiffRadius = shader.getDiffRadius();
+    Edge2PtConicalEffect(GrContext* ctx,
+                         const SkTwoPointConicalGradient& shader,
+                         const SkMatrix& matrix,
+                         SkShader::TileMode tm)
+        : INHERITED(ctx, shader, matrix, tm),
+        fCenterX1(shader.getCenterX1()),
+        fRadius0(shader.getStartRadius()),
+        fDiffRadius(shader.getDiffRadius()){
         this->initClassID<Edge2PtConicalEffect>();
         // We should only be calling this shader if we are degenerate case with touching circles
         // When deciding if we are in edge case, we scaled by the end radius for cases when the
@@ -372,9 +376,13 @@ class FocalOutside2PtConicalEffect : public GrGradientEffect {
 public:
     class GLSLFocalOutside2PtConicalProcessor;
 
-    static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar focalX) {
+    static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+                                           const SkTwoPointConicalGradient& shader,
+                                           const SkMatrix& matrix,
+                                           SkShader::TileMode tm,
+                                           SkScalar focalX) {
         return sk_sp<GrFragmentProcessor>(
-            new FocalOutside2PtConicalEffect(args, focalX));
+            new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX));
     }
 
     virtual ~FocalOutside2PtConicalEffect() { }
@@ -398,10 +406,14 @@ private:
                 this->fIsFlipped == s.fIsFlipped);
     }
 
-    FocalOutside2PtConicalEffect(const CreateArgs& args, SkScalar focalX)
-    : INHERITED(args)
+    FocalOutside2PtConicalEffect(GrContext* ctx,
+                                 const SkTwoPointConicalGradient& shader,
+                                 const SkMatrix& matrix,
+                                 SkShader::TileMode tm,
+                                 SkScalar focalX)
+    : INHERITED(ctx, shader, matrix, tm)
     , fFocalX(focalX)
-    , fIsFlipped(static_cast<const SkTwoPointConicalGradient*>(args.fShader)->isFlippedGrad()) {
+    , fIsFlipped(shader.isFlippedGrad()) {
         this->initClassID<FocalOutside2PtConicalEffect>();
     }
 
@@ -579,9 +591,13 @@ class FocalInside2PtConicalEffect : public GrGradientEffect {
 public:
     class GLSLFocalInside2PtConicalProcessor;
 
-    static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar focalX) {
+    static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+                                           const SkTwoPointConicalGradient& shader,
+                                           const SkMatrix& matrix,
+                                           SkShader::TileMode tm,
+                                           SkScalar focalX) {
         return sk_sp<GrFragmentProcessor>(
-            new FocalInside2PtConicalEffect(args, focalX));
+            new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX));
     }
 
     virtual ~FocalInside2PtConicalEffect() {}
@@ -605,8 +621,12 @@ private:
                 this->fFocalX == s.fFocalX);
     }
 
-    FocalInside2PtConicalEffect(const CreateArgs& args, SkScalar focalX)
-        : INHERITED(args), fFocalX(focalX) {
+    FocalInside2PtConicalEffect(GrContext* ctx,
+                                const SkTwoPointConicalGradient& shader,
+                                const SkMatrix& matrix,
+                                SkShader::TileMode tm,
+                                SkScalar focalX)
+        : INHERITED(ctx, shader, matrix, tm), fFocalX(focalX) {
         this->initClassID<FocalInside2PtConicalEffect>();
     }
 
@@ -817,9 +837,13 @@ class CircleInside2PtConicalEffect : public GrGradientEffect {
 public:
     class GLSLCircleInside2PtConicalProcessor;
 
-    static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, const CircleConicalInfo& info) {
+    static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+                                           const SkTwoPointConicalGradient& shader,
+                                           const SkMatrix& matrix,
+                                           SkShader::TileMode tm,
+                                           const CircleConicalInfo& info) {
         return sk_sp<GrFragmentProcessor>(
-            new CircleInside2PtConicalEffect(args, info));
+            new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info));
     }
 
     virtual ~CircleInside2PtConicalEffect() {}
@@ -847,8 +871,12 @@ private:
                 this->fInfo.fC == s.fInfo.fC);
     }
 
-    CircleInside2PtConicalEffect(const CreateArgs& args, const CircleConicalInfo& info)
-        : INHERITED(args), fInfo(info) {
+    CircleInside2PtConicalEffect(GrContext* ctx,
+                                 const SkTwoPointConicalGradient& shader,
+                                 const SkMatrix& matrix,
+                                 SkShader::TileMode tm,
+                                 const CircleConicalInfo& info)
+        : INHERITED(ctx, shader, matrix, tm), fInfo(info) {
         this->initClassID<CircleInside2PtConicalEffect>();
     }
 
@@ -1032,9 +1060,13 @@ class CircleOutside2PtConicalEffect : public GrGradientEffect {
 public:
     class GLSLCircleOutside2PtConicalProcessor;
 
-    static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, const CircleConicalInfo& info) {
+    static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
+                                           const SkTwoPointConicalGradient& shader,
+                                           const SkMatrix& matrix,
+                                           SkShader::TileMode tm,
+                                           const CircleConicalInfo& info) {
         return sk_sp<GrFragmentProcessor>(
-            new CircleOutside2PtConicalEffect(args, info));
+            new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info));
     }
 
     virtual ~CircleOutside2PtConicalEffect() {}
@@ -1065,11 +1097,13 @@ private:
                 this->fIsFlipped == s.fIsFlipped);
     }
 
-    CircleOutside2PtConicalEffect(const CreateArgs& args, const CircleConicalInfo& info)
-        : INHERITED(args), fInfo(info) {
+    CircleOutside2PtConicalEffect(GrContext* ctx,
+                                  const SkTwoPointConicalGradient& shader,
+                                  const SkMatrix& matrix,
+                                  SkShader::TileMode tm,
+                                  const CircleConicalInfo& info)
+        : INHERITED(ctx, shader, matrix, tm), fInfo(info) {
         this->initClassID<CircleOutside2PtConicalEffect>();
-        const SkTwoPointConicalGradient& shader =
-            *static_cast<const SkTwoPointConicalGradient*>(args.fShader);
         if (shader.getStartRadius() != shader.getEndRadius()) {
             fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shader.getEndRadius());
         } else {
@@ -1288,35 +1322,32 @@ void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey
 
 //////////////////////////////////////////////////////////////////////////////
 
-sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(
-                                                         const GrGradientEffect::CreateArgs& args) {
-    const SkTwoPointConicalGradient& shader =
-        *static_cast<const SkTwoPointConicalGradient*>(args.fShader);
-
+sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(GrContext* ctx,
+                                                            const SkTwoPointConicalGradient& shader,
+                                                            SkShader::TileMode tm,
+                                                            const SkMatrix* localMatrix) {
     SkMatrix matrix;
     if (!shader.getLocalMatrix().invert(&matrix)) {
         return nullptr;
     }
-    if (args.fMatrix) {
+    if (localMatrix) {
         SkMatrix inv;
-        if (!args.fMatrix->invert(&inv)) {
+        if (!localMatrix->invert(&inv)) {
             return nullptr;
         }
         matrix.postConcat(inv);
     }
 
-    GrGradientEffect::CreateArgs newArgs(args.fContext, args.fShader, &matrix, args.fTileMode);
-
     if (shader.getStartRadius() < kErrorTol) {
         SkScalar focalX;
         ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX);
         if (type == kInside_ConicalType) {
-            return FocalInside2PtConicalEffect::Make(newArgs, focalX);
+            return FocalInside2PtConicalEffect::Make(ctx, shader, matrix, tm, focalX);
         } else if(type == kEdge_ConicalType) {
             set_matrix_edge_conical(shader, &matrix);
-            return Edge2PtConicalEffect::Make(newArgs);
+            return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm);
         } else {
-            return FocalOutside2PtConicalEffect::Make(newArgs, focalX);
+            return FocalOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, focalX);
         }
     }
 
@@ -1324,12 +1355,12 @@ sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(
     ConicalType type = set_matrix_circle_conical(shader, &matrix, &info);
 
     if (type == kInside_ConicalType) {
-        return CircleInside2PtConicalEffect::Make(newArgs, info);
+        return CircleInside2PtConicalEffect::Make(ctx, shader, matrix, tm, info);
     } else if (type == kEdge_ConicalType) {
         set_matrix_edge_conical(shader, &matrix);
-        return Edge2PtConicalEffect::Make(newArgs);
+        return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm);
     } else {
-        return CircleOutside2PtConicalEffect::Make(newArgs, info);
+        return CircleOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, info);
     }
 }
 
index 46edb1f..9dd058d 100644 (file)
@@ -18,7 +18,8 @@ namespace Gr2PtConicalGradientEffect {
      * Creates an effect that produces a two point conical gradient based on the
      * shader passed in.
      */
-    sk_sp<GrFragmentProcessor> Make(const GrGradientEffect::CreateArgs& args);
+    sk_sp<GrFragmentProcessor> Make(GrContext* ctx,  const SkTwoPointConicalGradient& shader,
+                                    SkShader::TileMode tm, const SkMatrix* localMatrix);
 };
 
 #endif