Add functions for inspecting SkShader.

Add a function to inspect an SkShader to determine if it is an
SkComposeShader.

Add a virtual function for determining if an SkShader is a custom
shader, which returns a custom set of information. The
implementation is in Android, and this function is only defined
if SK_BUILD_FOR_ANDROID_FRAMEWORK.

BUG=b/10650594
R=reed@google.com, scroggo@google.com

Author: djsollen@google.com

Review URL: https://codereview.chromium.org/282733005

git-svn-id: http://skia.googlecode.com/svn/trunk@14716 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkComposeShader.h b/include/core/SkComposeShader.h
index cfb03b9..3a28e1e 100644
--- a/include/core/SkComposeShader.h
+++ b/include/core/SkComposeShader.h
@@ -62,6 +62,8 @@
     SkShader* getShaderB() { return fShaderB; }
 #endif
 
+    virtual bool asACompose(ComposeRec* rec) const SK_OVERRIDE;
+
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader)
 
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index ce5f003..bc83c32 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -17,6 +17,7 @@
 
 class SkPath;
 class SkPicture;
+class SkXfermode;
 class GrContext;
 class GrEffectRef;
 
@@ -356,6 +357,20 @@
     virtual GradientType asAGradient(GradientInfo* info) const;
 
     /**
+     *  If the shader subclass is composed of two shaders, return true, and if rec is not NULL,
+     *  fill it out with info about the shader.
+     */
+
+    struct ComposeRec {
+        const SkShader*     fShaderA;
+        const SkShader*     fShaderB;
+        const SkXfermode*   fMode;
+    };
+
+    virtual bool asACompose(ComposeRec* rec) const { return false; }
+
+
+    /**
      *  If the shader subclass has a GrEffect implementation, this resturns the effect to install.
      *  The incoming color to the effect has r=g=b=a all extracted from the SkPaint's alpha.
      *  The output color should be the computed SkShader premul color modulated by the incoming
@@ -365,6 +380,14 @@
     virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint,
                                      const SkMatrix* localMatrixOrNull) const;
 
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+    /**
+     *  If the shader is a custom shader which has data the caller might want, call this function
+     *  to get that data.
+     */
+    virtual bool asACustomShader(void** customData) const { return false; }
+#endif
+
     //////////////////////////////////////////////////////////////////////////
     //  Factory methods for stock shaders
 
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp
index b2f69b4..f7de73b 100644
--- a/src/core/SkComposeShader.cpp
+++ b/src/core/SkComposeShader.cpp
@@ -121,6 +121,16 @@
     fShaderContextB->~Context();
 }
 
+bool SkComposeShader::asACompose(ComposeRec* rec) const {
+    if (rec) {
+        rec->fShaderA = fShaderA;
+        rec->fShaderB = fShaderB;
+        rec->fMode = fMode;
+    }
+    return true;
+}
+
+
 // larger is better (fewer times we have to loop), but we shouldn't
 // take up too much stack-space (each element is 4 bytes)
 #define TMP_COLOR_COUNT     64