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
diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp
index 14f5b64..2cf8347 100644
--- a/src/gpu/effects/GrSingleTextureEffect.cpp
+++ b/src/gpu/effects/GrSingleTextureEffect.cpp
@@ -98,6 +98,17 @@
GrSingleTextureEffect::~GrSingleTextureEffect() {
}
+void GrSingleTextureEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
+ // If the input alpha is 0xff and the texture has no alpha channel, then the output alpha is
+ // 0xff
+ if ((*validFlags & kA_ValidComponentFlag) && 0xFF == GrColorUnpackA(*color) &&
+ GrPixelConfigIsOpaque(fTextureAccess.getTexture()->config())) {
+ *validFlags = kA_ValidComponentFlag;
+ } else {
+ *validFlags = 0;
+ }
+}
+
const GrBackendEffectFactory& GrSingleTextureEffect::getFactory() const {
return GrTBackendEffectFactory<GrSingleTextureEffect>::getInstance();
}