aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-07-16 13:17:13 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-16 13:17:13 -0700
commit189186337eb91b0b21c15db42377bbf3ae4acf23 (patch)
tree93190d801a2859d0a53e909b6e9506b3d8a63830 /include
parentdfa0ecf169db87f7afddd93bc1c500de481a62c7 (diff)
refactor code to apply the croprect
Diffstat (limited to 'include')
-rw-r--r--include/core/SkImageFilter.h56
1 files changed, 37 insertions, 19 deletions
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index 75fa29b425..896636bb75 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -32,24 +32,6 @@ struct SkIPoint;
*/
class SK_API SkImageFilter : public SkFlattenable {
public:
- class CropRect {
- public:
- 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) {}
- uint32_t flags() const { return fFlags; }
- const SkRect& rect() const { return fRect; }
- private:
- SkRect fRect;
- uint32_t fFlags;
- };
-
// This cache maps from (filter's unique ID + CTM + clipBounds + src bitmap generation ID) to
// (result, offset).
class Cache : public SkRefCnt {
@@ -77,6 +59,41 @@ public:
Cache* fCache;
};
+ class CropRect {
+ public:
+ 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) {}
+ uint32_t flags() const { return fFlags; }
+ const SkRect& rect() const { return fRect; }
+#ifndef SK_IGNORE_TO_STRING
+ void toString(SkString* str) const;
+#endif
+
+ /**
+ * Apply this cropRect to the imageBounds. If a given edge of the cropRect is not
+ * set, then the corresponding edge from imageBounds will be used.
+ *
+ * Note: imageBounds is in "device" space, as the output cropped rectangle will be,
+ * so the context's CTM is ignore for those. It is only applied the croprect's bounds.
+ *
+ * The resulting rect will be intersected with the context's clip. If that intersection is
+ * empty, then this returns false and cropped is unmodified.
+ */
+ bool applyTo(const SkIRect& imageBounds, const Context&, SkIRect* cropped) const;
+
+ private:
+ SkRect fRect;
+ uint32_t fFlags;
+ };
+
class Proxy {
public:
Proxy(SkBaseDevice* device) : fDevice(device) { }
@@ -182,7 +199,8 @@ public:
/**
* Returns whether any edges of the crop rect have been set. The crop
* rect is set at construction time, and determines which pixels from the
- * input image will be processed. The size of the crop rect should be
+ * input image will be processed, and which pixels in the output image will be allowed.
+ * The size of the crop rect 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