aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/gradients
diff options
context:
space:
mode:
Diffstat (limited to 'src/effects/gradients')
-rw-r--r--src/effects/gradients/SkGradientShader.cpp2
-rw-r--r--src/effects/gradients/SkGradientShaderPriv.h10
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;