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

Unified Diff: include/core/SkRect.h

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Added ImageFilter derived classes safety checks (retry) Created 7 years, 3 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
Index: include/core/SkRect.h
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index d8919ae5d6b888d3195cc57ce7346bc905cf2a8c..85baa6d5b5b7a3eb73ce40ab8b8e374d3f927d94 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -100,6 +100,8 @@ struct SK_API SkIRect {
*/
bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
+ bool isValid() const { return (fLeft <= fRight) && (fTop <= fBottom); }
reed1 2013/09/03 20:25:21 I think we already have the notion of "inverted" f
sugoi1 2013/09/04 18:01:10 Good point, I added a check to make sure width() a
+
bool isLargest() const { return SK_MinS32 == fLeft &&
SK_MinS32 == fTop &&
SK_MaxS32 == fRight &&
@@ -419,6 +421,12 @@ struct SK_API SkRect {
*/
bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
+ bool isValid() const { return SkScalarIsFinite(fLeft) &&
+ SkScalarIsFinite(fTop) &&
+ SkScalarIsFinite(fRight) &&
+ SkScalarIsFinite(fBottom) &&
+ (fLeft <= fRight) &&
+ (fTop <= fBottom); }
/**
* Returns true iff all values in the rect are finite. If any are
* infinite or NaN (or SK_FixedNaN when SkScalar is fixed) then this

Powered by Google App Engine
This is Rietveld 408576698