This patch implements generalized DAG connectivity for SkImageFilter.  SkImageFilter maintains a list of inputs, which can be constructed either from a SkImageFilter** or zero or more SkImageFilter* arguments (varargs).

Existing filters which maintained their own filter connectivity were refactored to use the new constructors and flattening/unflattening code.  Modifying the remaining filters which are not yet DAG-friendly is left for future work; they are considered to have zero inputs for now.

Review URL: https://codereview.appspot.com/6443119

git-svn-id: http://skia.googlecode.com/svn/trunk@5891 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index 92a5a58..f035bf9 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -109,8 +109,18 @@
     virtual GrTexture* onFilterImageGPU(Proxy*, GrTexture* texture, const SkRect& rect);
 
 protected:
-    SkImageFilter() {}
-    explicit SkImageFilter(SkFlattenableReadBuffer& rb) : INHERITED(rb) {}
+    SkImageFilter(int numInputs, SkImageFilter** inputs);
+
+    // The ... represents numInputs SkImageFilter pointers, upon which this
+    // constructor will call SkSafeRef().  This is the same behaviour as
+    // the SkImageFilter(int, SkImageFilter**) constructor above.
+    explicit SkImageFilter(int numInputs, ...);
+
+    virtual ~SkImageFilter();
+
+    explicit SkImageFilter(SkFlattenableReadBuffer& rb);
+
+    virtual void flatten(SkFlattenableWriteBuffer& wb) const SK_OVERRIDE;
 
     // Default impl returns false
     virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
@@ -118,8 +128,17 @@
     // Default impl copies src into dst and returns true
     virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*);
 
+    int numInputs() const { return fNumInputs; }
+    SkImageFilter* getInput(int i) const { SkASSERT(i < fNumInputs); return fInputs[i]; }
+    // Return the result of processing the given input, or the source bitmap
+    // if we have no connected input at that index.
+    SkBitmap getInputResult(int index, Proxy*, const SkBitmap& src, const SkMatrix&,
+                            SkIPoint*);
+
 private:
     typedef SkFlattenable INHERITED;
+    int fNumInputs;
+    SkImageFilter** fInputs;
 };
 
 #endif