detect when we can filter bitmaps/images directly, w/o a tmp layer

visual bench run on Mac Pro

curr/maxrss	loops	min	median	mean	max	stddev	samples   	config	bench
 100/100 MB	16	412µs	413µs	413µs	414µs	0%	▄▁▇▄▄▄▄█▄▃▅	gpu	warmupbench
 101/102 MB	32	547µs	548µs	611µs	1.24ms	34%	█▁▁▁▁▁▁▁▁▁▁	gpu	image-filter-sprite-draw-image
 102/103 MB	32	547µs	548µs	721µs	1.23ms	41%	█▁▇▁▁█▁▁▁▁▁	gpu	image-filter-sprite-draw-bitmap
 103/103 MB	64	546µs	546µs	546µs	547µs	0%	▆▄▂▁▇█▅▇▅▇▃	gpu	image-filter-sprite-draw-sprite

Should have no effect on Chrome while SK_SUPPORT_LEGACY_LAYER_BITMAP_IMAGEFILTERS is defined (which it is in chrome)

BUG=skia:1073

Review URL: https://codereview.chromium.org/1491293002
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index c91430e..5cb6a48 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -55,6 +55,12 @@
 
     virtual bool onIsLazyGenerated() const { return false; }
 
+    // Return a bitmap suitable for passing to image-filters
+    // For now, that means wrapping textures into SkGrPixelRefs...
+    virtual bool asBitmapForImageFilters(SkBitmap* bitmap) const {
+        return this->getROPixels(bitmap, kAllow_CachingHint);
+    }
+
     // Call when this image is part of the key to a resourcecache entry. This allows the cache
     // to know automatically those entries can be purged when this SkImage deleted.
     void notifyAddedToCache() const {
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 346f798..55a82bb 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -5,16 +5,18 @@
  * found in the LICENSE file.
  */
 
-#include "SkBitmapCache.h"
-#include "SkImage_Gpu.h"
 #include "GrCaps.h"
 #include "GrContext.h"
 #include "GrDrawContext.h"
 #include "GrTextureParamsAdjuster.h"
 #include "effects/GrYUVtoRGBEffect.h"
 #include "SkCanvas.h"
+#include "SkBitmapCache.h"
 #include "SkGpuDevice.h"
+#include "SkGrPixelRef.h"
 #include "SkGrPriv.h"
+#include "SkImageFilter.h"
+#include "SkImage_Gpu.h"
 #include "SkPixelRef.h"
 
 SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrTexture* tex,
@@ -69,6 +71,13 @@
     return true;
 }
 
+bool SkImage_Gpu::asBitmapForImageFilters(SkBitmap* bitmap) const {
+    bitmap->setInfo(make_info(this->width(), this->height(), this->isOpaque()));
+    bitmap->setPixelRef(new SkGrPixelRef(bitmap->info(), fTexture))->unref();
+    bitmap->pixelRef()->setImmutableWithID(this->uniqueID());
+    return true;
+}
+
 class GpuImage_GrTextureAdjuster : public GrTextureAdjuster {
 public:
     GpuImage_GrTextureAdjuster(const SkImage_Gpu* image)
@@ -166,9 +175,6 @@
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-#include "SkGrPixelRef.h"
-#include "SkImageFilter.h"
-
 class SkGpuImageFilterProxy : public SkImageFilter::Proxy {
     GrContext* fCtx;
 
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index ff3b12e..bd8abd2 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -50,6 +50,8 @@
         return SkSurface::NewRenderTarget(fTexture->getContext(), SkSurface::kNo_Budgeted, info);
     }
 
+    bool asBitmapForImageFilters(SkBitmap* bitmap) const override;
+
 private:
     SkAutoTUnref<GrTexture>     fTexture;
     const SkAlphaType           fAlphaType;