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

Unified Diff: include/core/SkImageFilter.h

Issue 1218993002: refactor code to apply the croprect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | src/core/SkImageFilter.cpp » ('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 75fa29b425663795b80b89e301fd740e0aa214ee..896636bb75e0bff8024d84940d85e2b35fa5b300 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
« no previous file with comments | « no previous file | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698