diff options
author | 2015-08-28 17:16:50 -0700 | |
---|---|---|
committer | 2015-08-28 17:16:50 -0700 | |
commit | a511e6ad1042093bea5b015c22a920313fc57c0b (patch) | |
tree | 1ca21761acf027f31f3b02da6cfb3a700fe8d5e8 /src/core | |
parent | ecfdc251be71f3d634e76afdd6375bf55fc061aa (diff) |
Revert of Change SkShader;asFragmentProcessor signature to no longer take skpaint\grcolor* (patchset #8 id:140001 of https://codereview.chromium.org/1316513002/ )
Reason for revert:
Primary suspect in failing DEPS rolls:
* https://codereview.chromium.org/1315753006
* https://codereview.chromium.org/1308323006
* https://codereview.chromium.org/1320903004
Primary suspect because the failing win bots did not fail in https://codereview.chromium.org/1315753005
Original issue's description:
> Change SkShader;asFragmentProcessor signature to no longer take skpaint\grcolor*
>
> Committed: https://skia.googlesource.com/skia/+/ecfdc251be71f3d634e76afdd6375bf55fc061aa
TBR=joshualitt@google.com,wangyix@google.com,robertphillips@google.com,bsalomon@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1313573005
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBitmapProcShader.cpp | 41 | ||||
-rw-r--r-- | src/core/SkBitmapProcShader.h | 9 | ||||
-rw-r--r-- | src/core/SkColorShader.h | 8 | ||||
-rw-r--r-- | src/core/SkLightingShader.cpp | 51 | ||||
-rw-r--r-- | src/core/SkLocalMatrixShader.h | 21 | ||||
-rw-r--r-- | src/core/SkPictureShader.cpp | 20 | ||||
-rw-r--r-- | src/core/SkPictureShader.h | 7 | ||||
-rw-r--r-- | src/core/SkShader.cpp | 32 |
8 files changed, 120 insertions, 69 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index c3b10184f4..e382d09c99 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -15,7 +15,6 @@ #if SK_SUPPORT_GPU #include "effects/GrBicubicEffect.h" -#include "effects/GrExtractAlphaFragmentProcessor.h" #include "effects/GrSimpleTextureEffect.h" #endif @@ -354,21 +353,22 @@ void SkBitmapProcShader::toString(SkString* str) const { #include "SkGr.h" #include "effects/GrSimpleTextureEffect.h" -const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* context, - const SkMatrix& viewM, const SkMatrix* localMatrix, - SkFilterQuality filterQuality, - GrProcessorDataManager* procDataManager) const { +bool SkBitmapProcShader::asFragmentProcessor(GrContext* context, const SkPaint& paint, + const SkMatrix& viewM, + const SkMatrix* localMatrix, GrColor* paintColor, + GrProcessorDataManager* procDataManager, + GrFragmentProcessor** fp) const { SkMatrix matrix; matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height()); SkMatrix lmInverse; if (!this->getLocalMatrix().invert(&lmInverse)) { - return nullptr; + return false; } if (localMatrix) { SkMatrix inv; if (!localMatrix->invert(&inv)) { - return nullptr; + return false; } lmInverse.postConcat(inv); } @@ -385,7 +385,7 @@ const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* co // are provided by the caller. bool doBicubic; GrTextureParams::FilterMode textureFilterMode = - GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix(), + GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), viewM, this->getLocalMatrix(), &doBicubic); GrTextureParams params(tm, textureFilterMode); SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap, ¶ms)); @@ -393,20 +393,29 @@ const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* co if (!texture) { SkErrorInternals::SetError( kInternalError_SkError, "Couldn't convert bitmap to texture."); - return nullptr; + return false; } - SkAutoTUnref<GrFragmentProcessor> inner; + *paintColor = (kAlpha_8_SkColorType == fRawBitmap.colorType()) ? + SkColor2GrColor(paint.getColor()) : + SkColor2GrColorJustAlpha(paint.getColor()); + if (doBicubic) { - inner.reset(GrBicubicEffect::Create(procDataManager, texture, matrix, tm)); + *fp = GrBicubicEffect::Create(procDataManager, texture, matrix, tm); } else { - inner.reset(GrSimpleTextureEffect::Create(procDataManager, texture, matrix, params)); + *fp = GrSimpleTextureEffect::Create(procDataManager, texture, matrix, params); } - if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { - return SkRef(inner.get()); - } - return GrExtractAlphaFragmentProcessor::Create(inner); + return true; +} + +#else + +bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&, + const SkMatrix*, GrColor*, GrProcessorDataManager*, + GrFragmentProcessor**) const { + SkDEBUGFAIL("Should not call in GPU-less build"); + return false; } #endif diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h index 4215b90efb..30f860a9bf 100644 --- a/src/core/SkBitmapProcShader.h +++ b/src/core/SkBitmapProcShader.h @@ -29,11 +29,10 @@ public: SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) -#if SK_SUPPORT_GPU - const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM, - const SkMatrix*, SkFilterQuality, - GrProcessorDataManager*) const override; -#endif + + bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM, const SkMatrix*, + GrColor*, GrProcessorDataManager*, + GrFragmentProcessor**) const override; class BitmapProcShaderContext : public SkShader::Context { public: diff --git a/src/core/SkColorShader.h b/src/core/SkColorShader.h index b5902b41e1..6702ef6085 100644 --- a/src/core/SkColorShader.h +++ b/src/core/SkColorShader.h @@ -49,11 +49,9 @@ public: GradientType asAGradient(GradientInfo* info) const override; -#if SK_SUPPORT_GPU - const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM, - const SkMatrix*, SkFilterQuality, - GrProcessorDataManager*) const override; -#endif + bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM, + const SkMatrix*, GrColor*, GrProcessorDataManager*, + GrFragmentProcessor**) const override; SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp index 212cdb65f9..a8d346ab1e 100644 --- a/src/core/SkLightingShader.cpp +++ b/src/core/SkLightingShader.cpp @@ -72,10 +72,9 @@ public: bool isOpaque() const override; -#if SK_SUPPORT_GPU - const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM, - const SkMatrix* localMatrix, SkFilterQuality, GrProcessorDataManager*) const override; -#endif + bool asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& viewM, + const SkMatrix* localMatrix, GrColor* color, + GrProcessorDataManager*, GrFragmentProcessor** fp) const override; size_t contextSize() const override; @@ -128,7 +127,6 @@ private: #include "GrCoordTransform.h" #include "GrFragmentProcessor.h" #include "GrTextureAccess.h" -#include "effects/GrExtractAlphaFragmentProcessor.h" #include "gl/GrGLProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" #include "SkGr.h" @@ -343,9 +341,10 @@ static bool make_mat(const SkBitmap& bm, return true; } -const GrFragmentProcessor* SkLightingShaderImpl::asFragmentProcessor(GrContext* context, - const SkMatrix& viewM, const SkMatrix* localMatrix, SkFilterQuality filterQuality, - GrProcessorDataManager* pdm) const { +bool SkLightingShaderImpl::asFragmentProcessor(GrContext* context, const SkPaint& paint, + const SkMatrix& viewM, const SkMatrix* localMatrix, + GrColor* color, GrProcessorDataManager* pdm, + GrFragmentProcessor** fp) const { // we assume diffuse and normal maps have same width and height // TODO: support different sizes SkASSERT(fDiffuseMap.width() == fNormalMap.width() && @@ -353,23 +352,23 @@ const GrFragmentProcessor* SkLightingShaderImpl::asFragmentProcessor(GrContext* SkMatrix diffM, normM; if (!make_mat(fDiffuseMap, this->getLocalMatrix(), localMatrix, &diffM)) { - return nullptr; + return false; } if (!make_mat(fNormalMap, fNormLocalMatrix, localMatrix, &normM)) { - return nullptr; + return false; } bool doBicubic; GrTextureParams::FilterMode diffFilterMode = GrSkFilterQualityToGrFilterMode( - SkTMin(filterQuality, kMedium_SkFilterQuality), + SkTMin(paint.getFilterQuality(), kMedium_SkFilterQuality), viewM, this->getLocalMatrix(), &doBicubic); SkASSERT(!doBicubic); GrTextureParams::FilterMode normFilterMode = GrSkFilterQualityToGrFilterMode( - SkTMin(filterQuality, kMedium_SkFilterQuality), + SkTMin(paint.getFilterQuality(), kMedium_SkFilterQuality), viewM, fNormLocalMatrix, &doBicubic); @@ -380,22 +379,34 @@ const GrFragmentProcessor* SkLightingShaderImpl::asFragmentProcessor(GrContext* SkAutoTUnref<GrTexture> diffuseTexture(GrRefCachedBitmapTexture(context, fDiffuseMap, &diffParams)); if (!diffuseTexture) { - SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bitmap to texture."); - return nullptr; + SkErrorInternals::SetError(kInternalError_SkError, + "Couldn't convert bitmap to texture."); + return false; } GrTextureParams normParams(kClamp_TileMode, normFilterMode); SkAutoTUnref<GrTexture> normalTexture(GrRefCachedBitmapTexture(context, fNormalMap, &normParams)); if (!normalTexture) { - SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bitmap to texture."); - return nullptr; + SkErrorInternals::SetError(kInternalError_SkError, + "Couldn't convert bitmap to texture."); + return false; } - SkAutoTUnref<const GrFragmentProcessor> inner ( - new LightingFP(pdm, diffuseTexture, normalTexture, diffM, normM, diffParams, normParams, - fLights, fInvNormRotation)); - return GrExtractAlphaFragmentProcessor::Create(inner); + *fp = new LightingFP(pdm, diffuseTexture, normalTexture, diffM, normM, diffParams, normParams, + fLights, fInvNormRotation); + + *color = GrColorPackA4(paint.getAlpha()); + return true; +} +#else + +bool SkLightingShaderImpl::asFragmentProcessor(GrContext* context, const SkPaint& paint, + const SkMatrix& viewM, const SkMatrix* localMatrix, + GrColor* color, GrProcessorDataManager*, + GrFragmentProcessor** fp) const { + SkDEBUGFAIL("Should not call in GPU-less build"); + return false; } #endif diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h index 9c6a526f7b..a145432a16 100644 --- a/src/core/SkLocalMatrixShader.h +++ b/src/core/SkLocalMatrixShader.h @@ -33,15 +33,28 @@ public: } #if SK_SUPPORT_GPU - const GrFragmentProcessor* asFragmentProcessor(GrContext* context, const SkMatrix& viewM, - const SkMatrix* localMatrix, SkFilterQuality fq, - GrProcessorDataManager* procDataManager) const override { + + virtual bool asFragmentProcessor(GrContext* context, const SkPaint& paint, + const SkMatrix& viewM, const SkMatrix* localMatrix, + GrColor* grColor, GrProcessorDataManager* procDataManager, + GrFragmentProcessor** fp) const override { SkMatrix tmp = this->getLocalMatrix(); if (localMatrix) { tmp.preConcat(*localMatrix); } - return fProxyShader->asFragmentProcessor(context, viewM, &tmp, fq, procDataManager); + return fProxyShader->asFragmentProcessor(context, paint, viewM, &tmp, grColor, + procDataManager, fp); } + +#else + + virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&, + const SkMatrix*, GrColor*, GrProcessorDataManager*, + GrFragmentProcessor**) const override { + SkDEBUGFAIL("Should not call in GPU-less build"); + return false; + } + #endif SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const override { diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp index f3ac638025..0b3c9e864b 100644 --- a/src/core/SkPictureShader.cpp +++ b/src/core/SkPictureShader.cpp @@ -336,17 +336,27 @@ void SkPictureShader::toString(SkString* str) const { #endif #if SK_SUPPORT_GPU -const GrFragmentProcessor* SkPictureShader::asFragmentProcessor(GrContext* context, - const SkMatrix& viewM, const SkMatrix* localMatrix, SkFilterQuality fq, - GrProcessorDataManager* procDataManager) const { +bool SkPictureShader::asFragmentProcessor(GrContext* context, const SkPaint& paint, + const SkMatrix& viewM, const SkMatrix* localMatrix, + GrColor* paintColor, + GrProcessorDataManager* procDataManager, + GrFragmentProcessor** fp) const { int maxTextureSize = 0; if (context) { maxTextureSize = context->caps()->maxTextureSize(); } SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix, maxTextureSize)); if (!bitmapShader) { - return nullptr; + return false; } - return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq, procDataManager); + return bitmapShader->asFragmentProcessor(context, paint, viewM, nullptr, paintColor, + procDataManager, fp); +} +#else +bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&, + const SkMatrix*, GrColor*, GrProcessorDataManager*, + GrFragmentProcessor**) const { + SkDEBUGFAIL("Should not call in GPU-less build"); + return false; } #endif diff --git a/src/core/SkPictureShader.h b/src/core/SkPictureShader.h index 6249e41e37..31a60fd9e2 100644 --- a/src/core/SkPictureShader.h +++ b/src/core/SkPictureShader.h @@ -30,10 +30,9 @@ public: SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader) -#if SK_SUPPORT_GPU - const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM, - const SkMatrix*, SkFilterQuality, GrProcessorDataManager*) const override; -#endif + bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM, const SkMatrix*, + GrColor*, GrProcessorDataManager*, + GrFragmentProcessor**) const override; protected: SkPictureShader(SkReadBuffer&); diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index b3edf47dfd..51a8017b5e 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -214,10 +214,10 @@ SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { return kNone_GradientType; } -const GrFragmentProcessor* SkShader::asFragmentProcessor(GrContext*, const SkMatrix&, - const SkMatrix*, SkFilterQuality, - GrProcessorDataManager*) const { - return nullptr; +bool SkShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&, const SkMatrix*, + GrColor*, GrProcessorDataManager*, + GrFragmentProcessor**) const { + return false; } SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { @@ -335,12 +335,24 @@ SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const { #if SK_SUPPORT_GPU #include "SkGr.h" -#include "effects/GrConstColorProcessor.h" -const GrFragmentProcessor* SkColorShader::asFragmentProcessor(GrContext*, const SkMatrix&, - const SkMatrix*, SkFilterQuality, - GrProcessorDataManager*) const { - GrColor color = SkColor2GrColor(fColor); - return GrConstColorProcessor::Create(color, GrConstColorProcessor::kModulateA_InputMode); + +bool SkColorShader::asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix&, + const SkMatrix*, GrColor* paintColor, + GrProcessorDataManager*, GrFragmentProcessor** fp) const { + *fp = nullptr; + SkColor skColor = fColor; + U8CPU newA = SkMulDiv255Round(SkColorGetA(fColor), paint.getAlpha()); + *paintColor = SkColor2GrColor(SkColorSetA(skColor, newA)); + return true; +} + +#else + +bool SkColorShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&, + const SkMatrix*, GrColor*, GrProcessorDataManager*, + GrFragmentProcessor**) const { + SkDEBUGFAIL("Should not call in GPU-less build"); + return false; } #endif |