aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRect.h
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2017-10-05 11:27:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-05 16:55:34 +0000
commit583dd2bbc0e0a3bb784d315e25b6575270572e06 (patch)
tree2ff87eac1595f1b8c0a05d195042d5941fade46f /include/core/SkRect.h
parent2a769859f03f69e510e3dbde58e10313012dcbf7 (diff)
add constexpr to SkRect, SkIRect Make functions
Also, doing so exposed a couple of unused variables in tests. R: bsalomon@google.com Bug: skia: 6898 Change-Id: I7b065e26a838fe55a1d772bcefaef5325e1baa61 Reviewed-on: https://skia-review.googlesource.com/55680 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'include/core/SkRect.h')
-rw-r--r--include/core/SkRect.h48
1 files changed, 16 insertions, 32 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index bd496e304d..2cc2604941 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -24,10 +24,8 @@ struct SK_API SkIRect {
int32_t fRight;
int32_t fBottom;
- static SkIRect SK_WARN_UNUSED_RESULT MakeEmpty() {
- SkIRect r;
- r.setEmpty();
- return r;
+ static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeEmpty() {
+ return SkIRect{0, 0, 0, 0};
}
static SkIRect SK_WARN_UNUSED_RESULT MakeLargest() {
@@ -36,28 +34,20 @@ struct SK_API SkIRect {
return r;
}
- static SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h) {
- SkIRect r;
- r.set(0, 0, w, h);
- return r;
+ static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h) {
+ return SkIRect{0, 0, w, h};
}
- static SkIRect SK_WARN_UNUSED_RESULT MakeSize(const SkISize& size) {
- SkIRect r;
- r.set(0, 0, size.width(), size.height());
- return r;
+ static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeSize(const SkISize& size) {
+ return SkIRect{0, 0, size.fWidth, size.fHeight};
}
- static SkIRect SK_WARN_UNUSED_RESULT MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b) {
- SkIRect rect;
- rect.set(l, t, r, b);
- return rect;
+ static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b) {
+ return SkIRect{l, t, r, b};
}
- static SkIRect SK_WARN_UNUSED_RESULT MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h) {
- SkIRect r;
- r.set(x, y, x + w, y + h);
- return r;
+ static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h) {
+ return SkIRect{x, y, x + w, y + h};
}
int left() const { return fLeft; }
@@ -421,10 +411,8 @@ struct SK_API SkRect {
return r;
}
- static SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h) {
- SkRect r;
- r.set(0, 0, w, h);
- return r;
+ static constexpr SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h) {
+ return SkRect{0, 0, w, h};
}
static SkRect SK_WARN_UNUSED_RESULT MakeIWH(int w, int h) {
@@ -433,10 +421,8 @@ struct SK_API SkRect {
return r;
}
- static SkRect SK_WARN_UNUSED_RESULT MakeSize(const SkSize& size) {
- SkRect r;
- r.set(0, 0, size.width(), size.height());
- return r;
+ static constexpr SkRect SK_WARN_UNUSED_RESULT MakeSize(const SkSize& size) {
+ return SkRect{0, 0, size.fWidth, size.fHeight};
}
static constexpr SkRect SK_WARN_UNUSED_RESULT MakeLTRB(SkScalar l, SkScalar t, SkScalar r,
@@ -444,10 +430,8 @@ struct SK_API SkRect {
return SkRect {l, t, r, b};
}
- static SkRect SK_WARN_UNUSED_RESULT MakeXYWH(SkScalar x, SkScalar y, SkScalar w, SkScalar h) {
- SkRect r;
- r.set(x, y, x + w, y + h);
- return r;
+ static constexpr SkRect SK_WARN_UNUSED_RESULT MakeXYWH(SkScalar x, SkScalar y, SkScalar w, SkScalar h) {
+ return SkRect {x, y, x + w, y + h};
}
SK_ATTR_DEPRECATED("use Make()")