Index: include/core/SkImageFilter.h |
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h |
index fe383ae9e316d632ce04eb15efdd0b40efeeb46c..e467761a1f0607e2ce244003be132c295c4f9874 100644 |
--- a/include/core/SkImageFilter.h |
+++ b/include/core/SkImageFilter.h |
@@ -9,13 +9,13 @@ |
#define SkImageFilter_DEFINED |
#include "SkFlattenable.h" |
+#include "SkRect.h" |
class SkBitmap; |
class SkColorFilter; |
class SkDevice; |
class SkMatrix; |
struct SkIPoint; |
-struct SkIRect; |
class SkShader; |
class GrEffectRef; |
class GrTexture; |
@@ -139,14 +139,25 @@ public: |
return fInputs[i]; |
} |
+ /** |
+ * Returns the crop rectangle of this filter. This is set at construction |
+ * time, and determines which pixels from the input image will |
+ * be processed. The size of this rectangle should be used as the size |
+ * of the destination image. The origin of this rect should be used to |
+ * offset access to the input images, and should also be added to the |
+ * "offset" parameter in onFilterImage and filterImageGPU(). (The latter |
+ * ensures that the resulting buffer is drawn in the correct location.) |
+ */ |
+ const SkIRect& cropRect() const { return fCropRect; } |
+ |
protected: |
- SkImageFilter(int inputCount, SkImageFilter** inputs); |
+ SkImageFilter(int inputCount, SkImageFilter** inputs, const SkIRect* cropRect = NULL); |
// Convenience constructor for 1-input filters. |
- explicit SkImageFilter(SkImageFilter* input); |
+ explicit SkImageFilter(SkImageFilter* input, const SkIRect* cropRect = NULL); |
// Convenience constructor for 2-input filters. |
- SkImageFilter(SkImageFilter* input1, SkImageFilter* input2); |
+ SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const SkIRect* cropRect = NULL); |
virtual ~SkImageFilter(); |
@@ -160,10 +171,15 @@ protected: |
// Default impl copies src into dst and returns true |
virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*); |
+ // Sets rect to the intersection of rect and the crop rect. If there |
+ // is no overlap, returns false and leaves rect unchanged. |
+ bool applyCropRect(SkIRect* rect) const; |
+ |
private: |
typedef SkFlattenable INHERITED; |
int fInputCount; |
SkImageFilter** fInputs; |
+ SkIRect fCropRect; |
}; |
#endif |