Allow single-pass filters (which use asNewEffect()) to participate in the image filter DAG.  This was done by introducing the SkSinglePassImageFilter abstract base class, which implements canFilterImageGPU() and filterImageGPU() on behalf of the derived class.  The derived class still only needs to asNewEffect().  This allows us to recurse on the filter input in SkSinglePassImageFilter::onFilterImageGPU().  It also allows us to remove any knowledge of single-pass image filters from SkGpuDevice and from the SkImageFilter base class as well.

BUG=

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

git-svn-id: http://skia.googlecode.com/svn/trunk/include@8563 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkImageFilter.h b/core/SkImageFilter.h
index 6cc53c0..d89befa 100644
--- a/core/SkImageFilter.h
+++ b/core/SkImageFilter.h
@@ -99,16 +99,18 @@
      *  Returns true if the filter can be processed on the GPU.  This is most
      *  often used for multi-pass effects, where intermediate results must be
      *  rendered to textures.  For single-pass effects, use asNewEffect().
-     *  The default implementation returns false.
+     *  The default implementation returns asNewEffect(NULL, NULL).
      */
     virtual bool canFilterImageGPU() const;
 
     /**
-     *  Process this image filter on the GPU.  src is the source image for
-     *  processing, as a texture-backed bitmap.  result is the destination
-     *  bitmap, which should contain a texture-backed pixelref on success.
-     *  The default implementation returns returns false and ignores the
-     *  result parameter.
+     *  Process this image filter on the GPU.  This is most often used for 
+     *  multi-pass effects, where intermediate results must be rendered to
+     *  textures.  For single-pass effects, use asNewEffect().  src is the
+     *  source image for processing, as a texture-backed bitmap.  result is
+     *  the destination bitmap, which should contain a texture-backed pixelref
+     *  on success.  The default implementation does single-pass processing
+     *  using asNewEffect().
      */
     virtual bool filterImageGPU(Proxy*, const SkBitmap& src, SkBitmap* result);
 
diff --git a/core/SkImageFilterUtils.h b/core/SkImageFilterUtils.h
new file mode 100644
index 0000000..72a25fe
--- /dev/null
+++ b/core/SkImageFilterUtils.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkImageFilterUtils_DEFINED
+#define SkImageFilterUtils_DEFINED
+
+#if SK_SUPPORT_GPU
+
+#include "SkImageFilter.h"
+
+class SkBitmap;
+class GrTexture;
+class SkImageFilter;
+
+class SK_API SkImageFilterUtils {
+public:
+    /**
+     * Wrap the given texture in a texture-backed SkBitmap.
+     */
+    static bool WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result);
+
+    /**
+     * Recursively evaluate the given filter on the GPU.  If filter is NULL,
+     * this function returns src.  If the filter has no GPU implementation, it
+     * will be processed in software and uploaded to the GPU.
+     */
+    static bool GetInputResultGPU(SkImageFilter* filter, SkImageFilter::Proxy* proxy, const SkBitmap& src, SkBitmap* result);
+};
+
+#endif
+
+#endif
diff --git a/effects/SkMagnifierImageFilter.h b/effects/SkMagnifierImageFilter.h
index e013426..80e3af6 100644
--- a/effects/SkMagnifierImageFilter.h
+++ b/effects/SkMagnifierImageFilter.h
@@ -16,7 +16,9 @@
 public:
     SkMagnifierImageFilter(SkRect srcRect, SkScalar inset);
 
+#if SK_SUPPORT_GPU
     virtual bool asNewEffect(GrEffectRef** effect, GrTexture* texture) const SK_OVERRIDE;
+#endif
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter)
 
diff --git a/effects/SkMatrixConvolutionImageFilter.h b/effects/SkMatrixConvolutionImageFilter.h
index cd2a16f..78a66f8 100644
--- a/effects/SkMatrixConvolutionImageFilter.h
+++ b/effects/SkMatrixConvolutionImageFilter.h
@@ -62,7 +62,7 @@
                                SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
 
 #if SK_SUPPORT_GPU
-    virtual bool asNewEffect(GrEffectRef**, GrTexture*) const SK_OVERRIDE;
+    virtual bool asNewEffect(GrEffectRef** effect, GrTexture*) const SK_OVERRIDE;
 #endif
 
 private: