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/include/gpu/GrEffect.h b/include/gpu/GrEffect.h
index b12a346..5fca4b2 100644
--- a/include/gpu/GrEffect.h
+++ b/include/gpu/GrEffect.h
@@ -8,9 +8,10 @@
 #ifndef GrEffect_DEFINED
 #define GrEffect_DEFINED
 
-#include "GrRefCnt.h"
-#include "GrNoncopyable.h"
+#include "GrColor.h"
 #include "GrEffectUnitTest.h"
+#include "GrNoncopyable.h"
+#include "GrRefCnt.h"
 #include "GrTexture.h"
 #include "GrTextureAccess.h"
 
@@ -31,9 +32,27 @@
     GrEffect() {};
     virtual ~GrEffect();
 
-    /** If given an input texture that is/is not opaque, is this effect guaranteed to produce an
-        opaque output? */
-    virtual bool isOpaque(bool inputTextureIsOpaque) const;
+    /**
+     * Flags for getConstantColorComponents. They are defined so that the bit order reflects the
+     * GrColor shift order.
+     */
+    enum ValidComponentFlags {
+        kR_ValidComponentFlag = 1 << (GrColor_SHIFT_R / 8),
+        kG_ValidComponentFlag = 1 << (GrColor_SHIFT_G / 8),
+        kB_ValidComponentFlag = 1 << (GrColor_SHIFT_B / 8),
+        kA_ValidComponentFlag = 1 << (GrColor_SHIFT_A / 8),
+
+        kAll_ValidComponentFlags = (kR_ValidComponentFlag | kG_ValidComponentFlag |
+                                    kB_ValidComponentFlag | kA_ValidComponentFlag)
+    };
+
+    /**
+     * This function is used to perform optimizations. When called the color and validFlags params
+     * indicate whether the input components to this effect in the FS will have known values. The
+     * function updates both params to indicate known values of its output. A component of the color
+     * param only has meaning if the corresponding bit in validFlags is set.
+     */
+    virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const = 0;
 
     /** This object, besides creating back-end-specific helper objects, is used for run-time-type-
         identification. The factory should be an instance of templated class,