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

Unified Diff: include/core/SkRect.h

Issue 1118293002: Simple CL to add a joinWithPossiblyEmptyArg to SkRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits Created 5 years, 8 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRect.h
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index 0f68825fc1ced755a9ae41e89f807c9fcd76ff3b..fe276e6710b0d242a0b96de66eb22d87f7e7c015 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -747,14 +747,22 @@ public:
if (fLeft >= fRight || fTop >= fBottom) {
*this = r;
} else {
- fLeft = SkMinScalar(fLeft, r.left());
- fTop = SkMinScalar(fTop, r.top());
- fRight = SkMaxScalar(fRight, r.right());
- fBottom = SkMaxScalar(fBottom, r.bottom());
+ this->joinPossiblyEmptyRect(r);
}
}
/**
+ * Joins the rectangle with another without checking if either are empty (may produce unexpected
+ * results if either rect is inverted).
+ */
+ void joinPossiblyEmptyRect(const SkRect& r) {
+ fLeft = SkMinScalar(fLeft, r.left());
+ fTop = SkMinScalar(fTop, r.top());
+ fRight = SkMaxScalar(fRight, r.right());
+ fBottom = SkMaxScalar(fBottom, r.bottom());
+ }
+
+ /**
* Grow the rect to include the specified (x,y). After this call, the
* following will be true: fLeft <= x <= fRight && fTop <= y <= fBottom.
*
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698