aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkImageFilter.h
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-14 15:44:01 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-14 15:44:01 +0000
commit4cb543d6057b692e1099e9f115155f0bf323a0c8 (patch)
tree66f8cbe4e7ef74221766ade874096f934c8b2031 /include/core/SkImageFilter.h
parent0d30c51c6cf45b3a08a3000b6d348c16bdec7f05 (diff)
Implement support for a Context parameter in image filters
Some upcoming work (support for expanding crop rects) requires the clip bounds to be available during filter traversal. This change replaces the SkMatrix parameter in the onFilterImage() traversals with a Context parameter. It contains the CTM, as well as the clip bounds. BUG=skia: R=reed@google.com Review URL: https://codereview.chromium.org/189913021 git-svn-id: http://skia.googlecode.com/svn/trunk@13803 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkImageFilter.h')
-rw-r--r--include/core/SkImageFilter.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index 91b98f4a8d..4f33f54b6d 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -9,12 +9,12 @@
#define SkImageFilter_DEFINED
#include "SkFlattenable.h"
+#include "SkMatrix.h"
#include "SkRect.h"
class SkBitmap;
class SkColorFilter;
class SkBaseDevice;
-class SkMatrix;
struct SkIPoint;
class SkShader;
class GrEffectRef;
@@ -49,6 +49,18 @@ public:
uint32_t fFlags;
};
+ class Context {
+ public:
+ Context(const SkMatrix& ctm, const SkIRect& clipBounds) :
+ fCTM(ctm), fClipBounds(clipBounds) {
+ }
+ const SkMatrix& ctm() const { return fCTM; }
+ const SkIRect& clipBounds() const { return fClipBounds; }
+ private:
+ SkMatrix fCTM;
+ SkIRect fClipBounds;
+ };
+
class Proxy {
public:
virtual ~Proxy() {};
@@ -59,7 +71,7 @@ public:
// returns true if the proxy handled the filter itself. if this returns
// false then the filter's code will be called.
virtual bool filterImage(const SkImageFilter*, const SkBitmap& src,
- const SkMatrix& ctm,
+ const Context&,
SkBitmap* result, SkIPoint* offset) = 0;
};
@@ -76,7 +88,7 @@ public:
* If the result image cannot be created, return false, in which case both
* the result and offset parameters will be ignored by the caller.
*/
- bool filterImage(Proxy*, const SkBitmap& src, const SkMatrix& ctm,
+ bool filterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const;
/**
@@ -104,7 +116,7 @@ public:
* relative to the src when it is drawn. The default implementation does
* single-pass processing using asNewEffect().
*/
- virtual bool filterImageGPU(Proxy*, const SkBitmap& src, const SkMatrix& ctm,
+ virtual bool filterImageGPU(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const;
/**
@@ -156,7 +168,7 @@ public:
* Recursively evaluate this filter on the GPU. If the filter has no GPU
* implementation, it will be processed in software and uploaded to the GPU.
*/
- bool getInputResultGPU(SkImageFilter::Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
+ bool getInputResultGPU(SkImageFilter::Proxy* proxy, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const;
#endif
@@ -200,7 +212,7 @@ protected:
* case both the result and offset parameters will be ignored by the
* caller.
*/
- virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
+ virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const;
// Given the bounds of the destination rect to be filled in device
// coordinates (first parameter), and the CTM, compute (conservatively)