aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkRectPriv.h
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-01-17 12:20:04 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-17 17:38:57 +0000
commit8008df1080f5623bf1cf13c713082c2b732d4eb2 (patch)
tree2c0914aa9f49f5e97c68325f58d2eebe7a41faf3 /src/core/SkRectPriv.h
parent33a86560ce12b549c2d69e3f891e0cae3173aed9 (diff)
handle large rects, rename helper
To fix gm/bigrect, needed to do adjust "largest" rect so it doesn't become empty when round-tripping with SkRect/SkIRect. I renamed it after this. Bug: skia: Change-Id: I747782c8456da603cf298275d2300ea1996e7629 Reviewed-on: https://skia-review.googlesource.com/95563 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Yuqian Li <liyuqian@google.com>
Diffstat (limited to 'src/core/SkRectPriv.h')
-rw-r--r--src/core/SkRectPriv.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/core/SkRectPriv.h b/src/core/SkRectPriv.h
index a8f40db005..16c9535cc8 100644
--- a/src/core/SkRectPriv.h
+++ b/src/core/SkRectPriv.h
@@ -12,18 +12,22 @@
class SkRectPriv {
public:
- static SkIRect MakeILargest() {
- const int32_t ihalf = SK_MaxS32 >> 1;
- return { -ihalf, -ihalf, ihalf, ihalf };
+ // Returns an irect that is very large, and can be safely round-trip with SkRect and still
+ // be considered non-empty (i.e. width/height > 0) even if we round-out the SkRect.
+ static SkIRect MakeILarge() {
+ // SK_MaxS32 >> 1 seemed better, but it did not survive round-trip with SkRect and rounding.
+ // Also, 1 << 29 can be perfectly represented in float, while SK_MaxS32 >> 1 cannot.
+ const int32_t large = 1 << 29;
+ return { -large, -large, large, large };
}
static SkIRect MakeILargestInverted() {
return { SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32 };
}
- static SkRect MakeLargestS32() {
+ static SkRect MakeLargeS32() {
SkRect r;
- r.set(MakeILargest());
+ r.set(MakeILarge());
return r;
}