aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-07-22 11:04:53 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-22 11:04:53 -0700
commit839345d63466a4209a0985654ec033624821fd78 (patch)
tree71590a11b99b3b554a4c80096f36c759b5d68ced /src/core
parent8a8accbcd1958c1646246b9b994fb47a3b5a6021 (diff)
Bundle SkShader::asFragmentProcessor arguments in a struct
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
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBitmapProcShader.cpp17
-rw-r--r--src/core/SkBitmapProcShader.h4
-rw-r--r--src/core/SkColorFilterShader.cpp14
-rw-r--r--src/core/SkColorFilterShader.h6
-rw-r--r--src/core/SkColorShader.cpp10
-rw-r--r--src/core/SkColorShader.h8
-rw-r--r--src/core/SkComposeShader.cpp17
-rw-r--r--src/core/SkComposeShader.h6
-rw-r--r--src/core/SkLightingShader.cpp20
-rw-r--r--src/core/SkLocalMatrixShader.cpp12
-rw-r--r--src/core/SkLocalMatrixShader.h5
-rw-r--r--src/core/SkNormalSource.cpp27
-rw-r--r--src/core/SkNormalSource.h7
-rw-r--r--src/core/SkPictureShader.cpp16
-rw-r--r--src/core/SkPictureShader.h6
-rw-r--r--src/core/SkShader.cpp4
16 files changed, 48 insertions, 131 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 8fad0b1fcc..406cc6f000 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -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,
diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h
index a4591c7355..f21e3d6adc 100644
--- a/src/core/SkBitmapProcShader.h
+++ b/src/core/SkBitmapProcShader.h
@@ -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:
diff --git a/src/core/SkColorFilterShader.cpp b/src/core/SkColorFilterShader.cpp
index 6f9fc97819..8bf82b8b18 100644
--- a/src/core/SkColorFilterShader.cpp
+++ b/src/core/SkColorFilterShader.cpp
@@ -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;
}
diff --git a/src/core/SkColorFilterShader.h b/src/core/SkColorFilterShader.h
index 39a62ab066..035acd8397 100644
--- a/src/core/SkColorFilterShader.h
+++ b/src/core/SkColorFilterShader.h
@@ -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 {
diff --git a/src/core/SkColorShader.cpp b/src/core/SkColorShader.cpp
index c61081603d..d8c9f29327 100644
--- a/src/core/SkColorShader.cpp
+++ b/src/core/SkColorShader.cpp
@@ -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);
diff --git a/src/core/SkColorShader.h b/src/core/SkColorShader.h
index 9e0c542ce8..0bd2702223 100644
--- a/src/core/SkColorShader.h
+++ b/src/core/SkColorShader.h
@@ -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()
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp
index e9f3f4c618..7696e1632e 100644
--- a/src/core/SkComposeShader.cpp
+++ b/src/core/SkComposeShader.cpp
@@ -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;
}
diff --git a/src/core/SkComposeShader.h b/src/core/SkComposeShader.h
index dcd43d3ab7..d1b095ec3f 100644
--- a/src/core/SkComposeShader.h
+++ b/src/core/SkComposeShader.h
@@ -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 {
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index b6b54967d5..b478ee7eca 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -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]) {
diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp
index cb85019827..4f74138b9c 100644
--- a/src/core/SkLocalMatrixShader.cpp
+++ b/src/core/SkLocalMatrixShader.cpp
@@ -12,15 +12,13 @@
#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
diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h
index ea784190b4..786ccec788 100644
--- a/src/core/SkLocalMatrixShader.h
+++ b/src/core/SkLocalMatrixShader.h
@@ -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 {
diff --git a/src/core/SkNormalSource.cpp b/src/core/SkNormalSource.cpp
index c082d843c1..c282a124e0 100644
--- a/src/core/SkNormalSource.cpp
+++ b/src/core/SkNormalSource.cpp
@@ -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>();
}
diff --git a/src/core/SkNormalSource.h b/src/core/SkNormalSource.h
index e46e2dae34..f8db496103 100644
--- a/src/core/SkNormalSource.h
+++ b/src/core/SkNormalSource.h
@@ -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 {
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index a6186e6c7d..1b1189c20d 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -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
diff --git a/src/core/SkPictureShader.h b/src/core/SkPictureShader.h
index 11bec1afc7..f2927a0321 100644
--- a/src/core/SkPictureShader.h
+++ b/src/core/SkPictureShader.h
@@ -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:
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 1ab4ea7ed2..5fa5ec239c 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -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