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

Unified Diff: src/core/SkRect.cpp

Issue 1893433002: In SkDraw::drawRect, use SkPath for huge rects. Base URL: https://skia.googlesource.com/skia@fixed-assert
Patch Set: Created 4 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 | « src/core/SkRasterClip.cpp ('k') | src/core/SkScalar.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRect.cpp
diff --git a/src/core/SkRect.cpp b/src/core/SkRect.cpp
index 0b2723ab0a555f36703825f3c059a4d2c3e16f70..011d38a86a192a59fa64f62d49c958e91d1bab39 100644
--- a/src/core/SkRect.cpp
+++ b/src/core/SkRect.cpp
@@ -7,6 +7,18 @@
#include "SkRect.h"
+bool SkIRect::contains(const SkRect& r) const {
+ if (r.isEmpty() || this->isEmpty()) {
+ return false;
+ }
+ // If r's coords are greater than the max int32_t, then they must be outside this SkIRect.
+ if (!r.canRound()) {
+ return false;
+ }
+ // At this point, we can convert the SkRect to SkIRect and compare directly.
+ return this->contains(r.roundOut());
+}
+
void SkIRect::join(int32_t left, int32_t top, int32_t right, int32_t bottom) {
// do nothing if the params are empty
if (left >= right || top >= bottom) {
@@ -142,6 +154,19 @@ void SkRect::join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
}
}
+bool SkRect::canRound() const {
+ if (fLeft < -SK_MaxS32Scalar || fTop < -SK_MaxS32Scalar ||
+ fRight > SK_MaxS32Scalar || fBottom > SK_MaxS32Scalar) {
+ return false;
+ }
+ if (this->isEmpty()) {
+ return fLeft < SK_MaxS32Scalar && fTop < SK_MaxS32Scalar &&
+ fRight > -SK_MaxS32Scalar && fBottom > -SK_MaxS32Scalar;
+ } else {
+ return true;
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////////////////////
#include "SkString.h"
« no previous file with comments | « src/core/SkRasterClip.cpp ('k') | src/core/SkScalar.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698