Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: include/core/SkImageFilter.h

Issue 26371002: Change SkImageFilter's cropRect from SkIRect to a CropRect struct (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Alternate version, using a single fFlags member. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/xfermodeimagefilter.cpp ('k') | include/core/SkRect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkImageFilter.h
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index 3dc145ca1979a40e966c352312c576193176fb26..9f0e29939114085d627aeb50e320f3fad9731566 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -31,6 +31,28 @@ class SK_API SkImageFilter : public SkFlattenable {
public:
SK_DECLARE_INST_COUNT(SkImageFilter)
+#ifdef SK_CROP_RECT_IS_INT
+ typedef SkIRect CropRect;
+#else
+ struct CropRect {
+ SkRect fRect;
+ uint32_t fFlags;
+ enum CropEdge {
+ kHasLeft_CropEdge = 0x01,
+ kHasTop_CropEdge = 0x02,
+ kHasRight_CropEdge = 0x04,
+ kHasBottom_CropEdge = 0x08,
+ kHasAll_CropEdge = 0x0F,
+ };
+ CropRect() {}
+ explicit CropRect(const SkRect& rect, uint32_t flags = kHasAll_CropEdge) : fRect(rect), fFlags(flags) {}
+ bool isSet() const
+ {
+ return fFlags != 0x0;
+ }
+ };
+#endif
+
class Proxy {
public:
virtual ~Proxy() {};
@@ -138,16 +160,20 @@ public:
* "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; }
+#ifdef SK_CROP_RECT_IS_INT
+ bool cropRectIsSet() const { return !fCropRect.isLargest(); }
+#else
+ bool cropRectIsSet() const { return fCropRect.isSet(); }
+#endif
protected:
- SkImageFilter(int inputCount, SkImageFilter** inputs, const SkIRect* cropRect = NULL);
+ SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRect = NULL);
// Convenience constructor for 1-input filters.
- explicit SkImageFilter(SkImageFilter* input, const SkIRect* cropRect = NULL);
+ explicit SkImageFilter(SkImageFilter* input, const CropRect* cropRect = NULL);
// Convenience constructor for 2-input filters.
- SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const SkIRect* cropRect = NULL);
+ SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const CropRect* cropRect = NULL);
virtual ~SkImageFilter();
@@ -170,7 +196,7 @@ private:
typedef SkFlattenable INHERITED;
int fInputCount;
SkImageFilter** fInputs;
- SkIRect fCropRect;
+ CropRect fCropRect;
};
#endif
« no previous file with comments | « gm/xfermodeimagefilter.cpp ('k') | include/core/SkRect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698