diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-11 21:08:55 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-11 21:08:55 +0000 |
commit | 371e105da5d9fdfff3b4242b37ff6fc09214c8c8 (patch) | |
tree | cfcca4200f2b8eb016f6ea3643f2602bc4076909 /src/effects/gradients | |
parent | 95146ebc43175ae0c1cd3a116509d92aa1a445ab (diff) |
Add GrEffect::updateKnownColorComponents(). It is used to determine whether the output of an effect has a constant output value for r,g,b, or a.
Review URL: https://codereview.appspot.com/7064057
git-svn-id: http://skia.googlecode.com/svn/trunk@7144 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects/gradients')
-rw-r--r-- | src/effects/gradients/SkGradientShader.cpp | 2 | ||||
-rw-r--r-- | src/effects/gradients/SkGradientShaderPriv.h | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index 8521bdbf61..7d779708f6 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -753,6 +753,8 @@ GrGradientEffect::GrGradientEffect(GrContext* ctx, SkBitmap bitmap; shader.getGradientTableBitmap(&bitmap); + fIsOpaque = shader.isOpaque(); + GrTextureStripAtlas::Desc desc; desc.fWidth = bitmap.width(); desc.fHeight = 32; diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h index 552013efa5..b2b8c47a1c 100644 --- a/src/effects/gradients/SkGradientShaderPriv.h +++ b/src/effects/gradients/SkGradientShaderPriv.h @@ -243,6 +243,15 @@ public: fYCoord == s.getYCoord() && fMatrix.cheapEqualTo(s.getMatrix()); } + virtual void getConstantColorComponents(GrColor* color, + uint32_t* validFlags) const SK_OVERRIDE { + if (fIsOpaque && (kA_ValidComponentFlag & *validFlags) && 0xff == GrColorUnpackA(*color)) { + *validFlags = kA_ValidComponentFlag; + } else { + *validFlags = 0; + } + } + protected: /** Populates a pair of arrays with colors and stop info to construct a random gradient. @@ -264,6 +273,7 @@ private: GrTextureStripAtlas* fAtlas; int fRow; SkMatrix fMatrix; + bool fIsOpaque; typedef GrEffect INHERITED; |