diff options
-rw-r--r-- | include/core/SkRect.h | 48 | ||||
-rw-r--r-- | tests/FloatingPointTextureTest.cpp | 1 | ||||
-rw-r--r-- | tests/PackedConfigsTextureTest.cpp | 1 |
3 files changed, 16 insertions, 34 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()") diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp index 816b0d37d8..d1718f8b48 100644 --- a/tests/FloatingPointTextureTest.cpp +++ b/tests/FloatingPointTextureTest.cpp @@ -23,7 +23,6 @@ #include "SkHalf.h" static const int DEV_W = 100, DEV_H = 100; -static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H); template <typename T> void runFPTest(skiatest::Reporter* reporter, GrContext* context, diff --git a/tests/PackedConfigsTextureTest.cpp b/tests/PackedConfigsTextureTest.cpp index f91fc428e6..5d54861196 100644 --- a/tests/PackedConfigsTextureTest.cpp +++ b/tests/PackedConfigsTextureTest.cpp @@ -20,7 +20,6 @@ #include "GrTextureProxy.h" static const int DEV_W = 10, DEV_H = 10; -static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H); static const uint8_t TOL = 0x4; static void check_component(skiatest::Reporter* reporter, uint8_t control, uint8_t test) { |