Bundle SkShader::asFragmentProcessor arguments in a struct
authorbrianosman <brianosman@google.com>
Fri, 22 Jul 2016 18:04:53 +0000 (11:04 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 22 Jul 2016 18:04:53 +0000 (11:04 -0700)
The signature of this thing keeps changing (and is about to change again).
This just makes maintenance much easier.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2175563003

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

34 files changed:
experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h
gm/dcshader.cpp
include/core/SkShader.h
include/effects/SkPerlinNoiseShader.h
src/core/SkBitmapProcShader.cpp
src/core/SkBitmapProcShader.h
src/core/SkColorFilterShader.cpp
src/core/SkColorFilterShader.h
src/core/SkColorShader.cpp
src/core/SkColorShader.h
src/core/SkComposeShader.cpp
src/core/SkComposeShader.h
src/core/SkLightingShader.cpp
src/core/SkLocalMatrixShader.cpp
src/core/SkLocalMatrixShader.h
src/core/SkNormalSource.cpp
src/core/SkNormalSource.h
src/core/SkPictureShader.cpp
src/core/SkPictureShader.h
src/core/SkShader.cpp
src/effects/SkPerlinNoiseShader.cpp
src/effects/gradients/SkLinearGradient.cpp
src/effects/gradients/SkLinearGradient.h
src/effects/gradients/SkRadialGradient.cpp
src/effects/gradients/SkRadialGradient.h
src/effects/gradients/SkSweepGradient.cpp
src/effects/gradients/SkSweepGradient.h
src/effects/gradients/SkTwoPointConicalGradient.cpp
src/effects/gradients/SkTwoPointConicalGradient.h
src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
src/gpu/SkGr.cpp
src/image/SkImageShader.cpp
src/image/SkImageShader.h

index b0c60f7..ac34492 100644 (file)
@@ -728,9 +728,10 @@ sk_sp<GrFragmentProcessor> GrPerlinNoise2Effect::TestCreate(GrProcessorTestData*
                                              stitchTiles ? &tileSize : nullptr));
 
     GrPaint grPaint;
-    return shader->asFragmentProcessor(d->fContext,
-                                       GrTest::TestMatrix(d->fRandom), nullptr,
-                                       kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect);
+    SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
+    return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
+                                                          kNone_SkFilterQuality,
+                                                          SkSourceGammaTreatment::kRespect));
 }
 
 void GrGLPerlinNoise2::emitCode(EmitArgs& args) {
@@ -1135,9 +1136,10 @@ sk_sp<GrFragmentProcessor> GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTe
                                                                    z));
 
     GrPaint grPaint;
-    return shader->asFragmentProcessor(d->fContext,
-                                       GrTest::TestMatrix(d->fRandom), nullptr,
-                                       kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect);
+    SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
+    return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
+                                                          kNone_SkFilterQuality,
+                                                          SkSourceGammaTreatment::kRespect));
 }
 
 void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
@@ -1301,20 +1303,15 @@ void GrGLImprovedPerlinNoise::onSetData(const GrGLSLProgramDataManager& pdman,
 }
 
 /////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(
-                                                    GrContext* context,
-                                                    const SkMatrix& viewM,
-                                                    const SkMatrix* externalLocalMatrix,
-                                                    SkFilterQuality,
-                                                    SkSourceGammaTreatment gammaTreatment) const {
-    SkASSERT(context);
+sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(const AsFPArgs& args) const {
+    SkASSERT(args.fContext);
 
     SkMatrix localMatrix = this->getLocalMatrix();
-    if (externalLocalMatrix) {
-        localMatrix.preConcat(*externalLocalMatrix);
+    if (args.fLocalMatrix) {
+        localMatrix.preConcat(*args.fLocalMatrix);
     }
 
-    SkMatrix matrix = viewM;
+    SkMatrix matrix = *args.fViewMatrix;
     matrix.preConcat(localMatrix);
 
     // Either we don't stitch tiles, either we have a valid tile size
@@ -1323,7 +1320,7 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(
     SkPerlinNoiseShader2::PaintingData* paintingData =
             new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
 
-    SkMatrix m = viewM;
+    SkMatrix m = *args.fViewMatrix;
     m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
     m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
 
@@ -1331,11 +1328,11 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(
         GrTextureParams textureParams(SkShader::TileMode::kRepeat_TileMode, 
                                       GrTextureParams::FilterMode::kNone_FilterMode);
         SkAutoTUnref<GrTexture> permutationsTexture(
-            GrRefCachedBitmapTexture(context, paintingData->getImprovedPermutationsBitmap(),
-                                     textureParams, gammaTreatment));
+            GrRefCachedBitmapTexture(args.fContext, paintingData->getImprovedPermutationsBitmap(),
+                                     textureParams, args.fGammaTreatment));
         SkAutoTUnref<GrTexture> gradientTexture(
-            GrRefCachedBitmapTexture(context, paintingData->getGradientBitmap(),
-                                     textureParams, gammaTreatment));
+            GrRefCachedBitmapTexture(args.fContext, paintingData->getGradientBitmap(),
+                                     textureParams, args.fGammaTreatment));
         return GrImprovedPerlinNoiseEffect::Make(fNumOctaves, fSeed, paintingData,
                                                    permutationsTexture, gradientTexture, m);
     }
@@ -1353,11 +1350,11 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(
     }
 
     SkAutoTUnref<GrTexture> permutationsTexture(
-        GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(),
-                                 GrTextureParams::ClampNoFilter(), gammaTreatment));
+        GrRefCachedBitmapTexture(args.fContext, paintingData->getPermutationsBitmap(),
+                                 GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
     SkAutoTUnref<GrTexture> noiseTexture(
-        GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(),
-                                 GrTextureParams::ClampNoFilter(), gammaTreatment));
+        GrRefCachedBitmapTexture(args.fContext, paintingData->getNoiseBitmap(),
+                                 GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
 
     if ((permutationsTexture) && (noiseTexture)) {
         sk_sp<GrFragmentProcessor> inner(
index 196d384..e4c71ac 100644 (file)
@@ -106,9 +106,7 @@ public:
     };
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
-                                                   const SkMatrix*, SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()
index 3ed6dc1..e97ab47 100644 (file)
@@ -36,11 +36,7 @@ public:
         buf.writeMatrix(fDeviceMatrix);
     }
 
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                   const SkMatrix& viewM,
-                                                   const SkMatrix* localMatrix,
-                                                   SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 
 #ifndef SK_IGNORE_TO_STRING
     void toString(SkString* str) const override {
@@ -100,11 +96,7 @@ private:
     GrCoordTransform fDeviceTransform;
 };
 
-sk_sp<GrFragmentProcessor> DCShader::asFragmentProcessor(GrContext*,
-                                                         const SkMatrix& viewM,
-                                                         const SkMatrix* localMatrix,
-                                                         SkFilterQuality,
-                                                         SkSourceGammaTreatment) const {
+sk_sp<GrFragmentProcessor> DCShader::asFragmentProcessor(const AsFPArgs&) const {
     sk_sp<GrFragmentProcessor> inner(new DCFP(fDeviceMatrix));
     return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
 }
index 1f80ea1..5301f46 100644 (file)
@@ -311,6 +311,25 @@ public:
     virtual bool asACompose(ComposeRec*) const { return false; }
 
 #if SK_SUPPORT_GPU
+    struct AsFPArgs {
+        AsFPArgs(GrContext* context,
+                 const SkMatrix* viewMatrix,
+                 const SkMatrix* localMatrix,
+                 SkFilterQuality filterQuality,
+                 SkSourceGammaTreatment gammaTreatment)
+            : fContext(context)
+            , fViewMatrix(viewMatrix)
+            , fLocalMatrix(localMatrix)
+            , fFilterQuality(filterQuality)
+            , fGammaTreatment(gammaTreatment) {}
+
+        GrContext*             fContext;
+        const SkMatrix*        fViewMatrix;
+        const SkMatrix*        fLocalMatrix;
+        SkFilterQuality        fFilterQuality;
+        SkSourceGammaTreatment fGammaTreatment;
+    };
+
     /**
      *  Returns a GrFragmentProcessor that implements the shader for the GPU backend. NULL is
      *  returned if there is no GPU implementation.
@@ -324,11 +343,7 @@ public:
      *  The returned GrFragmentProcessor should expect an unpremultiplied input color and
      *  produce a premultiplied output.
      */
-    virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                           const SkMatrix& viewMatrix,
-                                                           const SkMatrix* localMatrix,
-                                                           SkFilterQuality,
-                                                           SkSourceGammaTreatment) const;
+    virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const;
 #endif
 
     /**
index ed706c1..60dc53a 100644 (file)
@@ -102,9 +102,7 @@ public:
     };
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
-                                                   const SkMatrix*, SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()
index 8fad0b1..406cc6f 100644 (file)
@@ -418,10 +418,7 @@ void SkBitmapProcShader::toString(SkString* str) const {
 #include "SkGr.h"
 #include "effects/GrSimpleTextureEffect.h"
 
-sk_sp<GrFragmentProcessor> SkBitmapProcShader::asFragmentProcessor(GrContext* context,
-                                             const SkMatrix& viewM, const SkMatrix* localMatrix,
-                                             SkFilterQuality filterQuality,
-                                             SkSourceGammaTreatment gammaTreatment) const {
+sk_sp<GrFragmentProcessor> SkBitmapProcShader::asFragmentProcessor(const AsFPArgs& args) const {
     SkMatrix matrix;
     matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height());
 
@@ -429,9 +426,9 @@ sk_sp<GrFragmentProcessor> SkBitmapProcShader::asFragmentProcessor(GrContext* co
     if (!this->getLocalMatrix().invert(&lmInverse)) {
         return nullptr;
     }
-    if (localMatrix) {
+    if (args.fLocalMatrix) {
         SkMatrix inv;
-        if (!localMatrix->invert(&inv)) {
+        if (!args.fLocalMatrix->invert(&inv)) {
             return nullptr;
         }
         lmInverse.postConcat(inv);
@@ -449,11 +446,11 @@ sk_sp<GrFragmentProcessor> SkBitmapProcShader::asFragmentProcessor(GrContext* co
     // are provided by the caller.
     bool doBicubic;
     GrTextureParams::FilterMode textureFilterMode =
-            GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix(),
-                                            &doBicubic);
+            GrSkFilterQualityToGrFilterMode(args.fFilterQuality, *args.fViewMatrix,
+                                            this->getLocalMatrix(), &doBicubic);
     GrTextureParams params(tm, textureFilterMode);
-    SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap, params,
-                                                             gammaTreatment));
+    SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(args.fContext, fRawBitmap, params,
+                                                             args.fGammaTreatment));
 
     if (!texture) {
         SkErrorInternals::SetError( kInternalError_SkError,
index a4591c7..f21e3d6 100644 (file)
@@ -30,9 +30,7 @@ public:
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
-                                                   const SkMatrix*, SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
 protected:
index 6f9fc97..8bf82b8 100644 (file)
@@ -97,20 +97,14 @@ void SkColorFilterShader::FilterShaderContext::shadeSpan4f(int x, int y, SkPM4f
 #if SK_SUPPORT_GPU
 /////////////////////////////////////////////////////////////////////
 
-sk_sp<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(
-                                                     GrContext* context,
-                                                     const SkMatrix& viewM,
-                                                     const SkMatrix* localMatrix,
-                                                     SkFilterQuality fq,
-                                                     SkSourceGammaTreatment gammaTreatment) const {
-
-    sk_sp<GrFragmentProcessor> fp1(fShader->asFragmentProcessor(context, viewM, localMatrix, fq,
-                                                                gammaTreatment));
+sk_sp<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(const AsFPArgs& args) const {
+
+    sk_sp<GrFragmentProcessor> fp1(fShader->asFragmentProcessor(args));
     if (!fp1) {
         return nullptr;
     }
 
-    sk_sp<GrFragmentProcessor> fp2(fFilter->asFragmentProcessor(context));
+    sk_sp<GrFragmentProcessor> fp2(fFilter->asFragmentProcessor(args.fContext));
     if (!fp2) {
         return fp1;
     }
index 39a62ab..035acd8 100644 (file)
@@ -16,11 +16,7 @@ public:
     SkColorFilterShader(sk_sp<SkShader> shader, sk_sp<SkColorFilter> filter);
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                   const SkMatrix& viewM,
-                                                   const SkMatrix* localMatrix,
-                                                   SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
     class FilterShaderContext : public SkShader::Context {
index c610816..d8c9f29 100644 (file)
@@ -89,10 +89,7 @@ SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const {
 
 #include "SkGr.h"
 #include "effects/GrConstColorProcessor.h"
-sk_sp<GrFragmentProcessor> SkColorShader::asFragmentProcessor(GrContext*, const SkMatrix&,
-                                                              const SkMatrix*,
-                                                              SkFilterQuality,
-                                                              SkSourceGammaTreatment) const {
+sk_sp<GrFragmentProcessor> SkColorShader::asFragmentProcessor(const AsFPArgs&) const {
     GrColor color = SkColorToPremulGrColor(fColor);
     return GrConstColorProcessor::Make(color, GrConstColorProcessor::kModulateA_InputMode);
 }
@@ -217,10 +214,7 @@ SkShader::GradientType SkColor4Shader::asAGradient(GradientInfo* info) const {
 
 #include "SkGr.h"
 #include "effects/GrConstColorProcessor.h"
-sk_sp<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(GrContext*, const SkMatrix&,
-                                                               const SkMatrix*,
-                                                               SkFilterQuality,
-                                                               SkSourceGammaTreatment) const {
+sk_sp<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(const AsFPArgs&) const {
     // TODO: how to communicate color4f to Gr
     GrColor color = SkColorToPremulGrColor(fCachedByteColor);
     return GrConstColorProcessor::Make(color, GrConstColorProcessor::kModulateA_InputMode);
index 9e0c542..0bd2702 100644 (file)
@@ -49,9 +49,7 @@ public:
     GradientType asAGradient(GradientInfo* info) const override;
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
-                                                   const SkMatrix*, SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()
@@ -104,9 +102,7 @@ public:
     GradientType asAGradient(GradientInfo* info) const override;
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
-                                                   const SkMatrix*, SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()
index e9f3f4c..7696e16 100644 (file)
@@ -183,12 +183,7 @@ void SkComposeShader::ComposeShaderContext::shadeSpan(int x, int y, SkPMColor re
 
 /////////////////////////////////////////////////////////////////////
 
-sk_sp<GrFragmentProcessor> SkComposeShader::asFragmentProcessor(
-                                                     GrContext* context,
-                                                     const SkMatrix& viewM,
-                                                     const SkMatrix* localMatrix,
-                                                     SkFilterQuality fq,
-                                                     SkSourceGammaTreatment gammaTreatment) const {
+sk_sp<GrFragmentProcessor> SkComposeShader::asFragmentProcessor(const AsFPArgs& args) const {
     // Fragment processor will only support SkXfermode::Mode modes currently.
     SkXfermode::Mode mode;
     if (!(SkXfermode::AsMode(fMode, &mode))) {
@@ -201,19 +196,17 @@ sk_sp<GrFragmentProcessor> SkComposeShader::asFragmentProcessor(
                                                GrConstColorProcessor::kIgnore_InputMode);
             break;
         case SkXfermode::kSrc_Mode:
-            return fShaderB->asFragmentProcessor(context, viewM, localMatrix, fq, gammaTreatment);
+            return fShaderB->asFragmentProcessor(args);
             break;
         case SkXfermode::kDst_Mode:
-            return fShaderA->asFragmentProcessor(context, viewM, localMatrix, fq, gammaTreatment);
+            return fShaderA->asFragmentProcessor(args);
             break;
         default:
-            sk_sp<GrFragmentProcessor> fpA(fShaderA->asFragmentProcessor(context,
-                                           viewM, localMatrix, fq, gammaTreatment));
+            sk_sp<GrFragmentProcessor> fpA(fShaderA->asFragmentProcessor(args));
             if (!fpA) {
                 return nullptr;
             }
-            sk_sp<GrFragmentProcessor> fpB(fShaderB->asFragmentProcessor(context,
-                                           viewM, localMatrix, fq, gammaTreatment));
+            sk_sp<GrFragmentProcessor> fpB(fShaderB->asFragmentProcessor(args));
             if (!fpB) {
                 return nullptr;
             }
index dcd43d3..d1b095e 100644 (file)
@@ -35,11 +35,7 @@ public:
     {}
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                   const SkMatrix& viewM,
-                                                   const SkMatrix* localMatrix,
-                                                   SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
     class ComposeShaderContext : public SkShader::Context {
index b6b5496..b478ee7 100644 (file)
@@ -53,11 +53,7 @@ public:
     bool isOpaque() const override;
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                   const SkMatrix& viewM,
-                                                   const SkMatrix* localMatrix,
-                                                   SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
     class LightingShaderContext : public SkShader::Context {
@@ -265,23 +261,15 @@ private:
 
 ////////////////////////////////////////////////////////////////////////////
 
-sk_sp<GrFragmentProcessor> SkLightingShaderImpl::asFragmentProcessor(
-                                                     GrContext* context,
-                                                     const SkMatrix& viewM,
-                                                     const SkMatrix* localMatrix,
-                                                     SkFilterQuality filterQuality,
-                                                     SkSourceGammaTreatment gammaTreatment) const {
-    sk_sp<GrFragmentProcessor> normalFP(
-            fNormalSource->asFragmentProcessor(context, viewM, localMatrix, filterQuality,
-                                               gammaTreatment));
+sk_sp<GrFragmentProcessor> SkLightingShaderImpl::asFragmentProcessor(const AsFPArgs& args) const {
+    sk_sp<GrFragmentProcessor> normalFP(fNormalSource->asFragmentProcessor(args));
     if (!normalFP) {
         return nullptr;
     }
 
     if (fDiffuseShader) {
         sk_sp<GrFragmentProcessor> fpPipeline[] = {
-            fDiffuseShader->asFragmentProcessor(context, viewM, localMatrix, filterQuality,
-                                                gammaTreatment),
+            fDiffuseShader->asFragmentProcessor(args),
             sk_make_sp<LightingFP>(std::move(normalFP), fLights)
         };
         if(!fpPipeline[0]) {
index cb85019..4f74138 100644 (file)
 #endif
 
 #if SK_SUPPORT_GPU
-sk_sp<GrFragmentProcessor> SkLocalMatrixShader::asFragmentProcessor(
-                                        GrContext* context, const SkMatrix& viewM,
-                                        const SkMatrix* localMatrix, SkFilterQuality fq,
-                                        SkSourceGammaTreatment gammaTreatment) const {
+sk_sp<GrFragmentProcessor> SkLocalMatrixShader::asFragmentProcessor(const AsFPArgs& args) const {
     SkMatrix tmp = this->getLocalMatrix();
-    if (localMatrix) {
-        tmp.preConcat(*localMatrix);
+    if (args.fLocalMatrix) {
+        tmp.preConcat(*args.fLocalMatrix);
     }
-    return fProxyShader->asFragmentProcessor(context, viewM, &tmp, fq, gammaTreatment);
+    return fProxyShader->asFragmentProcessor(AsFPArgs(
+        args.fContext, args.fViewMatrix, &tmp, args.fFilterQuality, args.fGammaTreatment));
 }
 #endif
 
index ea78419..786ccec 100644 (file)
@@ -26,10 +26,7 @@ public:
     }
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(
-                                            GrContext* context, const SkMatrix& viewM,
-                                            const SkMatrix* localMatrix, SkFilterQuality fq,
-                                            SkSourceGammaTreatment gammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
     SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const override {
index c082d84..c282a12 100644 (file)
@@ -26,11 +26,7 @@ public:
         , fInvCTM(invCTM) {}
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                   const SkMatrix& viewM,
-                                                   const SkMatrix* localMatrix,
-                                                   SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShader::AsFPArgs&) const override;
 #endif
 
     SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec,
@@ -178,13 +174,8 @@ private:
 };
 
 sk_sp<GrFragmentProcessor> NormalMapSourceImpl::asFragmentProcessor(
-                                                     GrContext *context,
-                                                     const SkMatrix &viewM,
-                                                     const SkMatrix *localMatrix,
-                                                     SkFilterQuality filterQuality,
-                                                     SkSourceGammaTreatment gammaTreatment) const {
-    sk_sp<GrFragmentProcessor> mapFP = fMapShader->asFragmentProcessor(context, viewM,
-            localMatrix, filterQuality, gammaTreatment);
+        const SkShader::AsFPArgs& args) const {
+    sk_sp<GrFragmentProcessor> mapFP = fMapShader->asFragmentProcessor(args);
     if (!mapFP) {
         return nullptr;
     }
@@ -336,11 +327,7 @@ public:
     NormalFlatSourceImpl(){}
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                   const SkMatrix& viewM,
-                                                   const SkMatrix* localMatrix,
-                                                   SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShader::AsFPArgs&) const override;
 #endif
 
     SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec,
@@ -418,11 +405,7 @@ private:
 };
 
 sk_sp<GrFragmentProcessor> NormalFlatSourceImpl::asFragmentProcessor(
-                                                     GrContext *context,
-                                                     const SkMatrix &viewM,
-                                                     const SkMatrix *localMatrix,
-                                                     SkFilterQuality filterQuality,
-                                                     SkSourceGammaTreatment gammaTreatment) const {
+        const SkShader::AsFPArgs&) const {
 
     return sk_make_sp<NormalFlatFP>();
 }
index e46e2da..f8db496 100644 (file)
@@ -20,12 +20,7 @@ public:
     /** Returns a fragment processor that takes no input and outputs a normal (already rotated)
         as its output color. To be used as a child fragment processor.
     */
-    virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(
-            GrContext* context,
-            const SkMatrix& viewM,
-            const SkMatrix* localMatrix,
-            SkFilterQuality filterQuality,
-            SkSourceGammaTreatment gammaTreatment) const = 0;
+    virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShader::AsFPArgs&) const = 0;
 #endif
 
     class Provider {
index a6186e6..1b1189c 100644 (file)
@@ -318,19 +318,17 @@ void SkPictureShader::toString(SkString* str) const {
 #endif
 
 #if SK_SUPPORT_GPU
-sk_sp<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(
-                                                     GrContext* context, const SkMatrix& viewM,
-                                                     const SkMatrix* localMatrix,
-                                                     SkFilterQuality fq,
-                                                     SkSourceGammaTreatment gammaTreatment) const {
+sk_sp<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(const AsFPArgs& args) const {
     int maxTextureSize = 0;
-    if (context) {
-        maxTextureSize = context->caps()->maxTextureSize();
+    if (args.fContext) {
+        maxTextureSize = args.fContext->caps()->maxTextureSize();
     }
-    sk_sp<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix, maxTextureSize));
+    sk_sp<SkShader> bitmapShader(this->refBitmapShader(*args.fViewMatrix, args.fLocalMatrix,
+                                                       maxTextureSize));
     if (!bitmapShader) {
         return nullptr;
     }
-    return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq, gammaTreatment);
+    return bitmapShader->asFragmentProcessor(SkShader::AsFPArgs(
+        args.fContext, args.fViewMatrix, nullptr, args.fFilterQuality, args.fGammaTreatment));
 }
 #endif
index 11bec1a..f2927a0 100644 (file)
@@ -28,11 +28,7 @@ public:
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader)
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                   const SkMatrix& viewM,
-                                                   const SkMatrix*,
-                                                   SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
 protected:
index 1ab4ea7..5fa5ec2 100644 (file)
@@ -225,9 +225,7 @@ SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const {
 }
 
 #if SK_SUPPORT_GPU
-sk_sp<GrFragmentProcessor> SkShader::asFragmentProcessor(GrContext*, const SkMatrix&,
-                                                         const SkMatrix*, SkFilterQuality,
-                                                         SkSourceGammaTreatment) const {
+sk_sp<GrFragmentProcessor> SkShader::asFragmentProcessor(const AsFPArgs&) const {
     return nullptr;
 }
 #endif
index 2268d4e..e7b7fa3 100644 (file)
@@ -592,9 +592,10 @@ sk_sp<GrFragmentProcessor> GrPerlinNoiseEffect::TestCreate(GrProcessorTestData*
         SkPerlinNoiseShader::MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed,
                                             stitchTiles ? &tileSize : nullptr));
 
-    return shader->asFragmentProcessor(d->fContext,
-                                       GrTest::TestMatrix(d->fRandom), nullptr,
-                                       kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect);
+    SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
+    return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
+                                                          kNone_SkFilterQuality,
+                                                          SkSourceGammaTreatment::kRespect));
 }
 
 void GrGLPerlinNoise::emitCode(EmitArgs& args) {
@@ -893,20 +894,15 @@ void GrGLPerlinNoise::onSetData(const GrGLSLProgramDataManager& pdman,
 }
 
 /////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(
-                                                     GrContext* context,
-                                                     const SkMatrix& viewM,
-                                                     const SkMatrix* externalLocalMatrix,
-                                                     SkFilterQuality,
-                                                     SkSourceGammaTreatment gammaTreatment) const {
-    SkASSERT(context);
+sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(const AsFPArgs& args) const {
+    SkASSERT(args.fContext);
 
     SkMatrix localMatrix = this->getLocalMatrix();
-    if (externalLocalMatrix) {
-        localMatrix.preConcat(*externalLocalMatrix);
+    if (args.fLocalMatrix) {
+        localMatrix.preConcat(*args.fLocalMatrix);
     }
 
-    SkMatrix matrix = viewM;
+    SkMatrix matrix = *args.fViewMatrix;
     matrix.preConcat(localMatrix);
 
     if (0 == fNumOctaves) {
@@ -927,13 +923,13 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(
     SkPerlinNoiseShader::PaintingData* paintingData =
             new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
     SkAutoTUnref<GrTexture> permutationsTexture(
-        GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(),
-                                 GrTextureParams::ClampNoFilter(), gammaTreatment));
+        GrRefCachedBitmapTexture(args.fContext, paintingData->getPermutationsBitmap(),
+                                 GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
     SkAutoTUnref<GrTexture> noiseTexture(
-        GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(),
-                                 GrTextureParams::ClampNoFilter(), gammaTreatment));
+        GrRefCachedBitmapTexture(args.fContext, paintingData->getNoiseBitmap(),
+                                 GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
 
-    SkMatrix m = viewM;
+    SkMatrix m = *args.fViewMatrix;
     m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
     m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
     if ((permutationsTexture) && (noiseTexture)) {
index 40340fe..f1a9eaf 100644 (file)
@@ -418,9 +418,9 @@ sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d)
     SkShader::TileMode tm;
     int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
     auto shader = SkGradientShader::MakeLinear(points, colors, stops, colorCount, tm);
-    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
-        GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
-        SkSourceGammaTreatment::kRespect);
+    SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
+        d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
     GrAlwaysAssert(fp);
     return fp;
 }
@@ -443,28 +443,24 @@ void GrGLLinearGradient::emitCode(EmitArgs& args) {
 
 /////////////////////////////////////////////////////////////////////
 
-sk_sp<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(
-                                                 GrContext* context,
-                                                 const SkMatrix& viewm,
-                                                 const SkMatrix* localMatrix,
-                                                 SkFilterQuality,
-                                                 SkSourceGammaTreatment) const {
-    SkASSERT(context);
+sk_sp<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(const AsFPArgs& args) const {
+    SkASSERT(args.fContext);
 
     SkMatrix matrix;
     if (!this->getLocalMatrix().invert(&matrix)) {
         return nullptr;
     }
-    if (localMatrix) {
+    if (args.fLocalMatrix) {
         SkMatrix inv;
-        if (!localMatrix->invert(&inv)) {
+        if (!args.fLocalMatrix->invert(&inv)) {
             return nullptr;
         }
         matrix.postConcat(inv);
     }
     matrix.postConcat(fPtsToUnit);
 
-    sk_sp<GrFragmentProcessor> inner(GrLinearGradient::Make(context, *this, matrix, fTileMode));
+    sk_sp<GrFragmentProcessor> inner(
+        GrLinearGradient::Make(args.fContext, *this, matrix, fTileMode));
     return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
 }
 
index 5800e57..7a85b88 100644 (file)
@@ -57,11 +57,7 @@ public:
 
     GradientType asAGradient(GradientInfo* info) const override;
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                   const SkMatrix& viewM,
-                                                   const SkMatrix*,
-                                                   SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()
index c7e6656..bcedb7f 100644 (file)
@@ -312,9 +312,9 @@ sk_sp<GrFragmentProcessor> GrRadialGradient::TestCreate(GrProcessorTestData* d)
     SkShader::TileMode tm;
     int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
     auto shader = SkGradientShader::MakeRadial(center, radius, colors, stops, colorCount, tm);
-    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
-        GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
-        SkSourceGammaTreatment::kRespect);
+    SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
+        d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
     GrAlwaysAssert(fp);
     return fp;
 }
@@ -338,27 +338,23 @@ void GrGLRadialGradient::emitCode(EmitArgs& args) {
 
 /////////////////////////////////////////////////////////////////////
 
-sk_sp<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(
-                                                 GrContext* context,
-                                                 const SkMatrix& viewM,
-                                                 const SkMatrix* localMatrix,
-                                                 SkFilterQuality,
-                                                 SkSourceGammaTreatment) const {
-    SkASSERT(context);
+sk_sp<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(const AsFPArgs& args) const {
+    SkASSERT(args.fContext);
 
     SkMatrix matrix;
     if (!this->getLocalMatrix().invert(&matrix)) {
         return nullptr;
     }
-    if (localMatrix) {
+    if (args.fLocalMatrix) {
         SkMatrix inv;
-        if (!localMatrix->invert(&inv)) {
+        if (!args.fLocalMatrix->invert(&inv)) {
             return nullptr;
         }
         matrix.postConcat(inv);
     }
     matrix.postConcat(fPtsToUnit);
-    sk_sp<GrFragmentProcessor> inner(GrRadialGradient::Make(context, *this, matrix, fTileMode));
+    sk_sp<GrFragmentProcessor> inner(
+        GrRadialGradient::Make(args.fContext, *this, matrix, fTileMode));
     return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
 }
 
index dfa6823..0b23903 100644 (file)
@@ -26,11 +26,7 @@ public:
 
     GradientType asAGradient(GradientInfo* info) const override;
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                   const SkMatrix& viewM,
-                                                   const SkMatrix*,
-                                                   SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()
index 9e2b909..31f4816 100644 (file)
@@ -191,10 +191,9 @@ sk_sp<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
     int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tmIgnored);
     sk_sp<SkShader> shader(SkGradientShader::MakeSweep(center.fX, center.fY,  colors, stops,
                                                        colorCount));
-    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
-                                                                GrTest::TestMatrix(d->fRandom),
-                                                                NULL, kNone_SkFilterQuality,
-                                                                SkSourceGammaTreatment::kRespect);
+    SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
+        d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
     GrAlwaysAssert(fp);
     return fp;
 }
@@ -227,27 +226,22 @@ void GrGLSweepGradient::emitCode(EmitArgs& args) {
 
 /////////////////////////////////////////////////////////////////////
 
-sk_sp<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(
-                                                    GrContext* context,
-                                                    const SkMatrix& viewM,
-                                                    const SkMatrix* localMatrix,
-                                                    SkFilterQuality,
-                                                    SkSourceGammaTreatment) const {
+sk_sp<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(const AsFPArgs& args) const {
 
     SkMatrix matrix;
     if (!this->getLocalMatrix().invert(&matrix)) {
         return nullptr;
     }
-    if (localMatrix) {
+    if (args.fLocalMatrix) {
         SkMatrix inv;
-        if (!localMatrix->invert(&inv)) {
+        if (!args.fLocalMatrix->invert(&inv)) {
             return nullptr;
         }
         matrix.postConcat(inv);
     }
     matrix.postConcat(fPtsToUnit);
 
-    sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make(context, *this, matrix));
+    sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make(args.fContext, *this, matrix));
     return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
 }
 
index 0812a58..f132118 100644 (file)
@@ -27,11 +27,7 @@ public:
     GradientType asAGradient(GradientInfo* info) const override;
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                   const SkMatrix& viewM,
-                                                   const SkMatrix*,
-                                                   SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()
index afc77fe..359ff9e 100644 (file)
@@ -357,15 +357,11 @@ void SkTwoPointConicalGradient::flatten(SkWriteBuffer& buffer) const {
 #include "SkGr.h"
 
 sk_sp<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProcessor(
-                                                  GrContext* context,
-                                                  const SkMatrix& viewM,
-                                                  const SkMatrix* localMatrix,
-                                                  SkFilterQuality,
-                                                  SkSourceGammaTreatment) const {
-    SkASSERT(context);
+                                                                  const AsFPArgs& args) const {
+    SkASSERT(args.fContext);
     SkASSERT(fPtsToUnit.isIdentity());
     sk_sp<GrFragmentProcessor> inner(
-        Gr2PtConicalGradientEffect::Make(context, *this, fTileMode, localMatrix));
+        Gr2PtConicalGradientEffect::Make(args.fContext, *this, fTileMode, args.fLocalMatrix));
     return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
 }
 
index f2102c1..d16e4bc 100644 (file)
@@ -57,11 +57,7 @@ public:
 
     SkShader::GradientType asAGradient(GradientInfo* info) const  override;
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
-                                                   const SkMatrix&,
-                                                   const SkMatrix*,
-                                                   SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
     bool isOpaque() const override;
 
index 91b0a93..438b1b5 100644 (file)
@@ -208,9 +208,9 @@ sk_sp<GrFragmentProcessor> Edge2PtConicalEffect::TestCreate(GrProcessorTestData*
     int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
     auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
                                                         colors, stops, colorCount, tm);
-    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
-        GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
-        SkSourceGammaTreatment::kRespect);
+    SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
+        d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
     GrAlwaysAssert(fp);
     return fp;
 }
@@ -485,9 +485,9 @@ sk_sp<GrFragmentProcessor> FocalOutside2PtConicalEffect::TestCreate(GrProcessorT
     int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
     auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
                                                         colors, stops, colorCount, tm);
-    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
-        GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
-        SkSourceGammaTreatment::kRespect);
+    SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
+        d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
     GrAlwaysAssert(fp);
     return fp;
 }
@@ -693,9 +693,9 @@ sk_sp<GrFragmentProcessor> FocalInside2PtConicalEffect::TestCreate(GrProcessorTe
     int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
     auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
                                                         colors, stops, colorCount, tm);
-    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
-        GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
-        SkSourceGammaTreatment::kRespect);
+    SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
+        d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
     GrAlwaysAssert(fp);
     return fp;
 }
@@ -941,9 +941,9 @@ sk_sp<GrFragmentProcessor> CircleInside2PtConicalEffect::TestCreate(GrProcessorT
     int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
     auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
                                                         colors, stops, colorCount, tm);
-    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext,
-        GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
-        SkSourceGammaTreatment::kRespect);
+    SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
+        d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
     GrAlwaysAssert(fp);
     return fp;
 }
@@ -1174,9 +1174,9 @@ sk_sp<GrFragmentProcessor> CircleOutside2PtConicalEffect::TestCreate(GrProcessor
     int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
     auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
                                                         colors, stops, colorCount, tm);
-    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(
-        d->fContext,GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
-        SkSourceGammaTreatment::kRespect);
+    SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
+        d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
     GrAlwaysAssert(fp);
     return fp;
 }
index 452218f..15c3892 100644 (file)
@@ -541,8 +541,9 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
         } else if (const SkShader* shader = skPaint.getShader()) {
             SkSourceGammaTreatment gammaTreatment = allowSRGBInputs
                 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
-            shaderFP = shader->asFragmentProcessor(context, viewM, nullptr,
-                                                   skPaint.getFilterQuality(), gammaTreatment);
+            shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context, &viewM, nullptr,
+                                                                      skPaint.getFilterQuality(),
+                                                                      gammaTreatment));
             if (!shaderFP) {
                 return false;
             }
@@ -710,11 +711,11 @@ bool SkPaintToGrPaintWithTexture(GrContext* context,
         if (const SkShader* shader = paint.getShader()) {
             SkSourceGammaTreatment gammaTreatment = allowSRGBInputs
                 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
-            shaderFP = shader->asFragmentProcessor(context,
-                                                   viewM,
-                                                   nullptr,
-                                                   paint.getFilterQuality(),
-                                                   gammaTreatment);
+            shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context,
+                                                                      &viewM,
+                                                                      nullptr,
+                                                                      paint.getFilterQuality(),
+                                                                      gammaTreatment));
             if (!shaderFP) {
                 return false;
             }
index 77639b2..e7a8433 100644 (file)
@@ -83,12 +83,7 @@ void SkImageShader::toString(SkString* str) const {
 #include "effects/GrBicubicEffect.h"
 #include "effects/GrSimpleTextureEffect.h"
 
-sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
-                                                     GrContext* context,
-                                                     const SkMatrix& viewM,
-                                                     const SkMatrix* localMatrix,
-                                                     SkFilterQuality filterQuality,
-                                                     SkSourceGammaTreatment gammaTreatment) const {
+sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(const AsFPArgs& args) const {
     SkMatrix matrix;
     matrix.setIDiv(fImage->width(), fImage->height());
 
@@ -96,9 +91,9 @@ sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
     if (!this->getLocalMatrix().invert(&lmInverse)) {
         return nullptr;
     }
-    if (localMatrix) {
+    if (args.fLocalMatrix) {
         SkMatrix inv;
-        if (!localMatrix->invert(&inv)) {
+        if (!args.fLocalMatrix->invert(&inv)) {
             return nullptr;
         }
         lmInverse.postConcat(inv);
@@ -113,9 +108,11 @@ sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
     // are provided by the caller.
     bool doBicubic;
     GrTextureParams::FilterMode textureFilterMode =
-    GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix(), &doBicubic);
+    GrSkFilterQualityToGrFilterMode(args.fFilterQuality, *args.fViewMatrix, this->getLocalMatrix(),
+                                    &doBicubic);
     GrTextureParams params(tm, textureFilterMode);
-    SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, params, gammaTreatment));
+    SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(args.fContext, params,
+                                                                args.fGammaTreatment));
     if (!texture) {
         return nullptr;
     }
index c0d9589..10200e9 100644 (file)
@@ -22,9 +22,7 @@ public:
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageShader)
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
-                                                   const SkMatrix*, SkFilterQuality,
-                                                   SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
 protected: