diff options
-rw-r--r-- | include/core/SkTypes.h | 7 | ||||
-rw-r--r-- | tests/DeferredCanvasTest.cpp | 2 | ||||
-rw-r--r-- | tests/InfRectTest.cpp | 16 | ||||
-rw-r--r-- | tests/Matrix44Test.cpp | 2 | ||||
-rw-r--r-- | tests/RoundRectTest.cpp | 2 |
5 files changed, 19 insertions, 10 deletions
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h index a8d283df39..113fd00e6b 100644 --- a/include/core/SkTypes.h +++ b/include/core/SkTypes.h @@ -283,6 +283,13 @@ static inline int32_t SkAbs32(int32_t value) { #endif } +template <typename T> inline T SkTAbs(T value) { + if (value < 0) { + value = -value; + } + return value; +} + static inline int32_t SkMax32(int32_t a, int32_t b) { if (a < b) a = b; diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp index 1e7725d592..8a834bec68 100644 --- a/tests/DeferredCanvasTest.cpp +++ b/tests/DeferredCanvasTest.cpp @@ -400,7 +400,7 @@ static void TestDeferredCanvasBitmapShaderNoLeak(skiatest::Reporter* reporter) { } } // All cached resources should be evictable since last canvas call was flush() - canvas.freeMemoryIfPossible(~0); + canvas.freeMemoryIfPossible(~0U); REPORTER_ASSERT(reporter, 0 == canvas.storageAllocatedForRecording()); } diff --git a/tests/InfRectTest.cpp b/tests/InfRectTest.cpp index 808bcee811..4d957dcf75 100644 --- a/tests/InfRectTest.cpp +++ b/tests/InfRectTest.cpp @@ -15,22 +15,24 @@ static float make_zero() { } #endif +struct RectCenter { + SkIRect fRect; + SkIPoint fCenter; +}; + static void test_center(skiatest::Reporter* reporter) { - static const struct { - SkIRect fRect; - SkIPoint fCenter; - } data[] = { + static const RectCenter gData[] = { { { 0, 0, 0, 0 }, { 0, 0 } }, { { 0, 0, 1, 1 }, { 0, 0 } }, { { -1, -1, 0, 0 }, { -1, -1 } }, { { 0, 0, 10, 7 }, { 5, 3 } }, { { 0, 0, 11, 6 }, { 5, 3 } }, }; - for (size_t index = 0; index < SK_ARRAY_COUNT(data); ++index) { + for (size_t index = 0; index < SK_ARRAY_COUNT(gData); ++index) { REPORTER_ASSERT(reporter, - data[index].fRect.centerX() == data[index].fCenter.x()); + gData[index].fRect.centerX() == gData[index].fCenter.x()); REPORTER_ASSERT(reporter, - data[index].fRect.centerY() == data[index].fCenter.y()); + gData[index].fRect.centerY() == gData[index].fCenter.y()); } SkRandom rand; diff --git a/tests/Matrix44Test.cpp b/tests/Matrix44Test.cpp index a680b44bda..269e359022 100644 --- a/tests/Matrix44Test.cpp +++ b/tests/Matrix44Test.cpp @@ -25,7 +25,7 @@ static bool nearly_equal_scalar(SkMScalar a, SkMScalar b) { const SkScalar tolerance = SK_Scalar1 / 1024; #endif - return SkScalarAbs(a - b) <= tolerance; + return SkTAbs<SkMScalar>(a - b) <= tolerance; } template <typename T> void assert16(skiatest::Reporter* reporter, const T data[], diff --git a/tests/RoundRectTest.cpp b/tests/RoundRectTest.cpp index 98e4e5d5b4..a8387d5dff 100644 --- a/tests/RoundRectTest.cpp +++ b/tests/RoundRectTest.cpp @@ -35,7 +35,7 @@ static void test_inset(skiatest::Reporter* reporter) { // Test out the basic API entry points static void test_round_rect_basic(skiatest::Reporter* reporter) { // Test out initialization methods - SkPoint zeroPt = { 0.0, 0.0 }; + SkPoint zeroPt = { 0, 0 }; SkRRect empty; empty.setEmpty(); |