diff options
author | egdaniel <egdaniel@google.com> | 2014-10-02 09:57:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-02 09:57:48 -0700 |
commit | 3b8af078281a5a20f951b9fd84f38d92b8f6217b (patch) | |
tree | 92c250b9011e2ee5e0e1a2517e7c7ee550853ddc /src/effects | |
parent | 8f8c25eabb97da8eda488895f04f2d12cb5ea4cf (diff) |
Add isSingleComponent bool to getConstantColorComponent
Initial step to allowing effects to use/output 1 or 4 color/coverage components. This cl doesn't change any current logic and all effects still assume they are working with 4 components.
BUG=skia:
Review URL: https://codereview.chromium.org/608253002
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkAlphaThresholdFilter.cpp | 14 | ||||
-rw-r--r-- | src/effects/SkArithmeticMode.cpp | 9 | ||||
-rw-r--r-- | src/effects/SkBlurMaskFilter.cpp | 19 | ||||
-rw-r--r-- | src/effects/SkColorFilters.cpp | 15 | ||||
-rw-r--r-- | src/effects/SkColorMatrixFilter.cpp | 90 | ||||
-rw-r--r-- | src/effects/SkDisplacementMapEffect.cpp | 10 | ||||
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 12 | ||||
-rw-r--r-- | src/effects/SkLumaColorFilter.cpp | 14 | ||||
-rw-r--r-- | src/effects/SkMagnifierImageFilter.cpp | 9 | ||||
-rw-r--r-- | src/effects/SkMorphologyImageFilter.cpp | 8 | ||||
-rw-r--r-- | src/effects/SkPerlinNoiseShader.cpp | 9 | ||||
-rw-r--r-- | src/effects/SkTableColorFilter.cpp | 17 | ||||
-rw-r--r-- | src/effects/gradients/SkGradientShader.cpp | 9 | ||||
-rw-r--r-- | src/effects/gradients/SkGradientShaderPriv.h | 4 |
14 files changed, 124 insertions, 115 deletions
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index 09cc61851c..462cfec55e 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -76,8 +76,6 @@ public: static const char* Name() { return "Alpha Threshold"; } virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; - float innerThreshold() const { return fInnerThreshold; } float outerThreshold() const { return fOuterThreshold; } @@ -104,6 +102,8 @@ private: virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE; + GR_DECLARE_FRAGMENT_PROCESSOR_TEST; float fInnerThreshold; @@ -228,13 +228,13 @@ bool AlphaThresholdEffect::onIsEqual(const GrProcessor& sBase) const { this->fOuterThreshold == s.fOuterThreshold); } -void AlphaThresholdEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { - if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color) && - GrPixelConfigIsOpaque(this->texture(0)->config())) { - *validFlags = kA_GrColorComponentFlag; +void AlphaThresholdEffect::onComputeInvariantOutput(InvariantOutput* inout) const { + if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config())) { + inout->fValidFlags = kA_GrColorComponentFlag; } else { - *validFlags = 0; + inout->fValidFlags = 0; } + inout->fIsSingleComponent = false; } #endif diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp index 85af19cf55..b62b33db9a 100644 --- a/src/effects/SkArithmeticMode.cpp +++ b/src/effects/SkArithmeticMode.cpp @@ -289,8 +289,6 @@ public: static const char* Name() { return "Arithmetic"; } GrTexture* backgroundTexture() const { return fBackgroundAccess.getTexture(); } - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; - float k1() const { return fK1; } float k2() const { return fK2; } float k3() const { return fK3; } @@ -300,6 +298,8 @@ public: private: virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE; + GrArithmeticEffect(float k1, float k2, float k3, float k4, bool enforcePMColor, GrTexture* background); float fK1, fK2, fK3, fK4; @@ -344,9 +344,10 @@ const GrBackendFragmentProcessorFactory& GrArithmeticEffect::getFactory() const return GrTBackendFragmentProcessorFactory<GrArithmeticEffect>::getInstance(); } -void GrArithmeticEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { +void GrArithmeticEffect::onComputeInvariantOutput(InvariantOutput* inout) const { // TODO: optimize this - *validFlags = 0; + inout->fValidFlags = 0; + inout->fIsSingleComponent = false; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 123b9d28e5..251398ca5b 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -563,8 +563,6 @@ public: typedef GrGLRectBlurEffect GLProcessor; virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; - /** * Create a simple filter effect with custom bicubic coefficients. */ @@ -594,6 +592,8 @@ private: GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile); virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE; + static bool CreateBlurProfileTexture(GrContext *context, float sigma, GrTexture **blurProfileTexture); @@ -765,9 +765,9 @@ bool GrRectBlurEffect::onIsEqual(const GrProcessor& sBase) const { return this->getSigma() == s.getSigma() && this->getRect() == s.getRect(); } -void GrRectBlurEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { - *validFlags = 0; - return; +void GrRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const { + inout->fValidFlags = 0; + inout->fIsSingleComponent = false; } GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect); @@ -837,8 +837,6 @@ public: typedef GrGLRRectBlurEffect GLProcessor; - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; private: @@ -846,6 +844,8 @@ private: virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE; + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE; + SkRRect fRRect; float fSigma; GrTextureAccess fNinePatchAccess; @@ -929,8 +929,9 @@ GrFragmentProcessor* GrRRectBlurEffect::Create(GrContext* context, float sigma, return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture)); } -void GrRRectBlurEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { - *validFlags = 0; +void GrRRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const { + inout->fValidFlags = 0; + inout->fIsSingleComponent = false; } const GrBackendFragmentProcessorFactory& GrRRectBlurEffect::getFactory() const { diff --git a/src/effects/SkColorFilters.cpp b/src/effects/SkColorFilters.cpp index bd0d2aa6c8..ba62817f56 100644 --- a/src/effects/SkColorFilters.cpp +++ b/src/effects/SkColorFilters.cpp @@ -195,8 +195,6 @@ public: return SkNEW_ARGS(ModeColorFilterEffect, (c, mode)); } - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; - bool willUseFilterColor() const { SkXfermode::Coeff dstCoeff; SkXfermode::Coeff srcCoeff; @@ -293,6 +291,8 @@ private: return fMode == s.fMode && fColor == s.fColor; } + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE; + SkXfermode::Mode fMode; GrColor fColor; @@ -382,18 +382,19 @@ private: } -void ModeColorFilterEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { +void ModeColorFilterEffect::onComputeInvariantOutput(InvariantOutput* inout) const { float inputColor[4]; - GrColorToRGBAFloat(*color, inputColor); + GrColorToRGBAFloat(inout->fColor, inputColor); float filterColor[4]; GrColorToRGBAFloat(fColor, filterColor); MaskedColorExpr result = color_filter_expression(fMode, MaskedColorExpr(filterColor, kRGBA_GrColorComponentFlags), - MaskedColorExpr(inputColor, *validFlags)); + MaskedColorExpr(inputColor, inout->fValidFlags)); - *color = result.getColor(); - *validFlags = result.getValidComponents(); + inout->fColor = result.getColor(); + inout->fValidFlags = result.getValidComponents(); + inout->fIsSingleComponent = false; } GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ModeColorFilterEffect); diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index 5ac455253e..8549fd72e1 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -349,51 +349,6 @@ public: return GrTBackendFragmentProcessorFactory<ColorMatrixEffect>::getInstance(); } - virtual void getConstantColorComponents(GrColor* color, - uint32_t* validFlags) const SK_OVERRIDE { - // We only bother to check whether the alpha channel will be constant. If SkColorMatrix had - // type flags it might be worth checking the other components. - - // The matrix is defined such the 4th row determines the output alpha. The first four - // columns of that row multiply the input r, g, b, and a, respectively, and the last column - // is the "translation". - static const uint32_t kRGBAFlags[] = { - kR_GrColorComponentFlag, - kG_GrColorComponentFlag, - kB_GrColorComponentFlag, - kA_GrColorComponentFlag - }; - static const int kShifts[] = { - GrColor_SHIFT_R, GrColor_SHIFT_G, GrColor_SHIFT_B, GrColor_SHIFT_A, - }; - enum { - kAlphaRowStartIdx = 15, - kAlphaRowTranslateIdx = 19, - }; - - SkScalar outputA = 0; - for (int i = 0; i < 4; ++i) { - // If any relevant component of the color to be passed through the matrix is non-const - // then we can't know the final result. - if (0 != fMatrix.fMat[kAlphaRowStartIdx + i]) { - if (!(*validFlags & kRGBAFlags[i])) { - *validFlags = 0; - return; - } else { - uint32_t component = (*color >> kShifts[i]) & 0xFF; - outputA += fMatrix.fMat[kAlphaRowStartIdx + i] * component; - } - } - } - outputA += fMatrix.fMat[kAlphaRowTranslateIdx]; - *validFlags = kA_GrColorComponentFlag; - // We pin the color to [0,1]. This would happen to the *final* color output from the frag - // shader but currently the effect does not pin its own output. So in the case of over/ - // underflow this may deviate from the actual result. Maybe the effect should pin its - // result if the matrix could over/underflow for any component? - *color = static_cast<uint8_t>(SkScalarPin(outputA, 0, 255)) << GrColor_SHIFT_A; - } - GR_DECLARE_FRAGMENT_PROCESSOR_TEST; class GLProcessor : public GrGLFragmentProcessor { @@ -471,6 +426,51 @@ private: return cme.fMatrix == fMatrix; } + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE { + // We only bother to check whether the alpha channel will be constant. If SkColorMatrix had + // type flags it might be worth checking the other components. + + // The matrix is defined such the 4th row determines the output alpha. The first four + // columns of that row multiply the input r, g, b, and a, respectively, and the last column + // is the "translation". + static const uint32_t kRGBAFlags[] = { + kR_GrColorComponentFlag, + kG_GrColorComponentFlag, + kB_GrColorComponentFlag, + kA_GrColorComponentFlag + }; + static const int kShifts[] = { + GrColor_SHIFT_R, GrColor_SHIFT_G, GrColor_SHIFT_B, GrColor_SHIFT_A, + }; + enum { + kAlphaRowStartIdx = 15, + kAlphaRowTranslateIdx = 19, + }; + + SkScalar outputA = 0; + for (int i = 0; i < 4; ++i) { + // If any relevant component of the color to be passed through the matrix is non-const + // then we can't know the final result. + if (0 != fMatrix.fMat[kAlphaRowStartIdx + i]) { + if (!(inout->fValidFlags & kRGBAFlags[i])) { + inout->fValidFlags = 0; + return; + } else { + uint32_t component = (inout->fColor >> kShifts[i]) & 0xFF; + outputA += fMatrix.fMat[kAlphaRowStartIdx + i] * component; + } + } + } + outputA += fMatrix.fMat[kAlphaRowTranslateIdx]; + inout->fValidFlags = kA_GrColorComponentFlag; + // We pin the color to [0,1]. This would happen to the *final* color output from the frag + // shader but currently the effect does not pin its own output. So in the case of over/ + // underflow this may deviate from the actual result. Maybe the effect should pin its + // result if the matrix could over/underflow for any component? + inout->fColor = static_cast<uint8_t>(SkScalarPin(outputA, 0, 255)) << GrColor_SHIFT_A; + inout->fIsSingleComponent = false; + } + SkColorMatrix fMatrix; typedef GrFragmentProcessor INHERITED; diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index 474d9a7dc8..ace9e02866 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -351,11 +351,11 @@ public: typedef GrGLDisplacementMapEffect GLProcessor; static const char* Name() { return "DisplacementMap"; } - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; - private: virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE; + GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector, SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, const SkVector& scale, @@ -491,14 +491,14 @@ const GrBackendFragmentProcessorFactory& GrDisplacementMapEffect::getFactory() c return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInstance(); } -void GrDisplacementMapEffect::getConstantColorComponents(GrColor*, - uint32_t* validFlags) const { +void GrDisplacementMapEffect::onComputeInvariantOutput(InvariantOutput* inout) const { // Any displacement offset bringing a pixel out of bounds will output a color of (0,0,0,0), // so the only way we'd get a constant alpha is if the input color image has a constant alpha // and no displacement offset push any texture coordinates out of bounds OR if the constant // alpha is 0. Since this isn't trivial to compute at this point, let's assume the output is // not of constant color when a displacement effect is applied. - *validFlags = 0; + inout->fValidFlags = 0; + inout->fIsSingleComponent = false; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index f766562128..ce787c6ab8 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -350,15 +350,15 @@ public: SkScalar surfaceScale() const { return fSurfaceScale; } const SkMatrix& filterMatrix() const { return fFilterMatrix; } - virtual void getConstantColorComponents(GrColor* color, - uint32_t* validFlags) const SK_OVERRIDE { - // lighting shaders are complicated. We just throw up our hands. - *validFlags = 0; - } - protected: virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE { + // lighting shaders are complicated. We just throw up our hands. + inout->fValidFlags = 0; + inout->fIsSingleComponent = false; + } + private: typedef GrSingleTextureEffect INHERITED; const SkLight* fLight; diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp index ee2bfa654c..616bcde891 100644 --- a/src/effects/SkLumaColorFilter.cpp +++ b/src/effects/SkLumaColorFilter.cpp @@ -73,13 +73,6 @@ public: return GrTBackendFragmentProcessorFactory<LumaColorFilterEffect>::getInstance(); } - virtual void getConstantColorComponents(GrColor* color, - uint32_t* validFlags) const SK_OVERRIDE { - // The output is always black. - *color = GrColorPackRGBA(0, 0, 0, GrColorUnpackA(*color)); - *validFlags = kRGB_GrColorComponentFlags; - } - class GLProcessor : public GrGLFragmentProcessor { public: GLProcessor(const GrBackendProcessorFactory& factory, @@ -119,6 +112,13 @@ private: virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE { return true; } + + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE { + // The output is always black. + inout->fColor = GrColorPackRGBA(0, 0, 0, GrColorUnpackA(inout->fColor)); + inout->fValidFlags = kRGB_GrColorComponentFlags; + inout->fIsSingleComponent = false; + } }; GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) const { diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index 9d7b918365..d6a8e783b9 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -47,8 +47,6 @@ public: static const char* Name() { return "Magnifier"; } virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; - float x_offset() const { return fXOffset; } float y_offset() const { return fYOffset; } float x_inv_zoom() const { return fXInvZoom; } @@ -76,6 +74,8 @@ private: virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE; + GR_DECLARE_FRAGMENT_PROCESSOR_TEST; float fXOffset; @@ -227,8 +227,9 @@ bool GrMagnifierEffect::onIsEqual(const GrProcessor& sBase) const { this->fYInvInset == s.fYInvInset); } -void GrMagnifierEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { - this->updateConstantColorComponentsForModulation(color, validFlags); +void GrMagnifierEffect::onComputeInvariantOutput(InvariantOutput* inout) const { + this->updateInvariantOutputForModulation(inout); + inout->fIsSingleComponent = false; } #endif diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 397e43193e..4c7f62482c 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -309,7 +309,6 @@ public: typedef GrGLMorphologyEffect GLProcessor; virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; protected: @@ -318,6 +317,8 @@ protected: private: virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE; + GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType); GR_DECLARE_FRAGMENT_PROCESSOR_TEST; @@ -455,10 +456,11 @@ bool GrMorphologyEffect::onIsEqual(const GrProcessor& sBase) const { this->type() == s.type()); } -void GrMorphologyEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { +void GrMorphologyEffect::onComputeInvariantOutput(InvariantOutput* inout) const { // This is valid because the color components of the result of the kernel all come // exactly from existing values in the source texture. - this->updateConstantColorComponentsForModulation(color, validFlags); + this->updateInvariantOutputForModulation(inout); + inout->fIsSingleComponent = false; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index 88e6caddb9..43197dedf2 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -586,6 +586,11 @@ private: fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit; } + void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE { + inout->fValidFlags = 0; // This is noise. Nothing is constant. + inout->fIsSingleComponent = false; + } + GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type, int numOctaves, bool stitchTiles, SkPerlinNoiseShader::PaintingData* paintingData, @@ -616,10 +621,6 @@ private: GrTextureAccess fNoiseAccess; SkPerlinNoiseShader::PaintingData *fPaintingData; - void getConstantColorComponents(GrColor*, uint32_t* validFlags) const SK_OVERRIDE { - *validFlags = 0; // This is noise. Nothing is constant. - } - private: typedef GrFragmentProcessor INHERITED; }; diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index 4853f73e5c..f6726ca078 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -294,20 +294,20 @@ public: static const char* Name() { return "ColorTable"; } virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; - typedef GLColorTableEffect GLProcessor; private: virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE; + explicit ColorTableEffect(GrTexture* texture, unsigned flags); GR_DECLARE_FRAGMENT_PROCESSOR_TEST; GrTextureAccess fTextureAccess; unsigned fFlags; // currently not used in shader code, just to assist - // getConstantColorComponents(). + // onComputeInvariantOutput(). typedef GrFragmentProcessor INHERITED; }; @@ -401,21 +401,22 @@ bool ColorTableEffect::onIsEqual(const GrProcessor& sBase) const { return this->texture(0) == sBase.texture(0); } -void ColorTableEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { +void ColorTableEffect::onComputeInvariantOutput(InvariantOutput* inout) const { // If we kept the table in the effect then we could actually run known inputs through the // table. if (fFlags & SkTable_ColorFilter::kR_Flag) { - *validFlags &= ~kR_GrColorComponentFlag; + inout->fValidFlags &= ~kR_GrColorComponentFlag; } if (fFlags & SkTable_ColorFilter::kG_Flag) { - *validFlags &= ~kG_GrColorComponentFlag; + inout->fValidFlags &= ~kG_GrColorComponentFlag; } if (fFlags & SkTable_ColorFilter::kB_Flag) { - *validFlags &= ~kB_GrColorComponentFlag; + inout->fValidFlags &= ~kB_GrColorComponentFlag; } if (fFlags & SkTable_ColorFilter::kA_Flag) { - *validFlags &= ~kA_GrColorComponentFlag; + inout->fValidFlags &= ~kA_GrColorComponentFlag; } + inout->fIsSingleComponent = false; } diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index d25873b438..89b323a701 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -1217,12 +1217,13 @@ bool GrGradientEffect::onIsEqual(const GrProcessor& processor) const { return false; } -void GrGradientEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { - if (fIsOpaque && (kA_GrColorComponentFlag & *validFlags) && 0xff == GrColorUnpackA(*color)) { - *validFlags = kA_GrColorComponentFlag; +void GrGradientEffect::onComputeInvariantOutput(InvariantOutput* inout) const { + if (fIsOpaque && inout->isOpaque()) { + inout->fValidFlags = kA_GrColorComponentFlag; } else { - *validFlags = 0; + inout->fValidFlags = 0; } + inout->fIsSingleComponent = false; } int GrGradientEffect::RandomGradientParams(SkRandom* random, diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h index b81b5626ba..33d8adde05 100644 --- a/src/effects/gradients/SkGradientShaderPriv.h +++ b/src/effects/gradients/SkGradientShaderPriv.h @@ -342,8 +342,6 @@ public: bool useAtlas() const { return SkToBool(-1 != fRow); } SkScalar getYCoord() const { return fYCoord; }; - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; - SkGradientShaderBase::GpuColorType getColorType() const { return fColorType; } enum PremulType { @@ -376,6 +374,8 @@ protected: virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; + virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE; + const GrCoordTransform& getCoordTransform() const { return fCoordTransform; } private: |