diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-30 19:08:47 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-30 19:08:47 +0000 |
commit | c2594f41066102d7a8a73effd3c574142a018b9a (patch) | |
tree | c37909d256544ee2932e9fbf2733b2a7c62d813c /include/effects | |
parent | 74749cd45c29b4f5300e2518f2c2c765ce8ae208 (diff) |
This changes the signature of SkImageFilter::filterImageGPU() to use SkBitmaps for input and output, and removes the rect param. This allows us to return textures which are larger than the actual result, such as when GrAutoScratchTextures are used. The SkBitmap's size represents the active region, while the GrTexture's size is the full texture size.
This fixes the bicubic image filter GM on the GPU, which otherwise draws garbage outside the filtered region. It also moves us closer to unifying the signatures of SkImageFilter::onFilterImage() and SkImageFilter::filterImageGPU().
Review URL: https://codereview.appspot.com/7180048
git-svn-id: http://skia.googlecode.com/svn/trunk@7467 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/effects')
-rw-r--r-- | include/effects/SkBicubicImageFilter.h | 3 | ||||
-rw-r--r-- | include/effects/SkBlendImageFilter.h | 2 | ||||
-rw-r--r-- | include/effects/SkBlurImageFilter.h | 2 | ||||
-rw-r--r-- | include/effects/SkDisplacementMapEffect.h | 2 | ||||
-rw-r--r-- | include/effects/SkImageFilterUtils.h | 36 | ||||
-rw-r--r-- | include/effects/SkMorphologyImageFilter.h | 6 | ||||
-rw-r--r-- | include/effects/SkSingleInputImageFilter.h | 6 |
7 files changed, 42 insertions, 15 deletions
diff --git a/include/effects/SkBicubicImageFilter.h b/include/effects/SkBicubicImageFilter.h index 682b4600cc..cb856fbaa2 100644 --- a/include/effects/SkBicubicImageFilter.h +++ b/include/effects/SkBicubicImageFilter.h @@ -42,8 +42,7 @@ protected: #if SK_SUPPORT_GPU virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } - virtual GrTexture* filterImageGPU(Proxy* proxy, GrTexture* src, - const SkRect& rect) SK_OVERRIDE; + virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) SK_OVERRIDE; #endif private: diff --git a/include/effects/SkBlendImageFilter.h b/include/effects/SkBlendImageFilter.h index 7812b185e4..a2dc847494 100644 --- a/include/effects/SkBlendImageFilter.h +++ b/include/effects/SkBlendImageFilter.h @@ -33,7 +33,7 @@ public: SkIPoint* offset) SK_OVERRIDE; #if SK_SUPPORT_GPU virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } - virtual GrTexture* filterImageGPU(Proxy* proxy, GrTexture* src, const SkRect& rect) SK_OVERRIDE; + virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) SK_OVERRIDE; #endif protected: diff --git a/include/effects/SkBlurImageFilter.h b/include/effects/SkBlurImageFilter.h index 9202e9b47f..018718fcc2 100644 --- a/include/effects/SkBlurImageFilter.h +++ b/include/effects/SkBlurImageFilter.h @@ -25,7 +25,7 @@ protected: SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; bool canFilterImageGPU() const SK_OVERRIDE { return true; } - virtual GrTexture* filterImageGPU(Proxy* proxy, GrTexture* src, const SkRect& rect) SK_OVERRIDE; + virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) SK_OVERRIDE; private: SkSize fSigma; diff --git a/include/effects/SkDisplacementMapEffect.h b/include/effects/SkDisplacementMapEffect.h index 641b4cbee4..18f9df866e 100644 --- a/include/effects/SkDisplacementMapEffect.h +++ b/include/effects/SkDisplacementMapEffect.h @@ -35,7 +35,7 @@ public: SkIPoint* offset) SK_OVERRIDE; #if SK_SUPPORT_GPU virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } - virtual GrTexture* filterImageGPU(Proxy* proxy, GrTexture* src, const SkRect& rect) SK_OVERRIDE; + virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) SK_OVERRIDE; #endif protected: diff --git a/include/effects/SkImageFilterUtils.h b/include/effects/SkImageFilterUtils.h new file mode 100644 index 0000000000..72a25fef77 --- /dev/null +++ b/include/effects/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/include/effects/SkMorphologyImageFilter.h b/include/effects/SkMorphologyImageFilter.h index 60424e9a0a..b4bc6767b2 100644 --- a/include/effects/SkMorphologyImageFilter.h +++ b/include/effects/SkMorphologyImageFilter.h @@ -38,8 +38,7 @@ public: virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; #if SK_SUPPORT_GPU - virtual GrTexture* filterImageGPU(Proxy* proxy, GrTexture* src, - const SkRect& rect) SK_OVERRIDE; + virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) SK_OVERRIDE; #endif SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter) @@ -59,8 +58,7 @@ public: virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; #if SK_SUPPORT_GPU - virtual GrTexture* filterImageGPU(Proxy* proxy, GrTexture* src, - const SkRect& rect) SK_OVERRIDE; + virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) SK_OVERRIDE; #endif SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter) diff --git a/include/effects/SkSingleInputImageFilter.h b/include/effects/SkSingleInputImageFilter.h index e7819c4f2f..3df718f8d1 100644 --- a/include/effects/SkSingleInputImageFilter.h +++ b/include/effects/SkSingleInputImageFilter.h @@ -29,12 +29,6 @@ protected: SkBitmap getInputResult(Proxy*, const SkBitmap& src, const SkMatrix&, SkIPoint* offset); -#if SK_SUPPORT_GPU - // Recurses on input (if non-NULL), and returns the processed result as - // a texture, otherwise returns src. - GrTexture* getInputResultAsTexture(Proxy* proxy, GrTexture* src, const SkRect& rect); -#endif - SkImageFilter* input() const { return getInput(0); } private: typedef SkImageFilter INHERITED; |