fix warings. add SkTAbs()
git-svn-id: http://skia.googlecode.com/svn/trunk@7075 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index a8d283d..113fd00 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -283,6 +283,13 @@
#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 1e7725d..8a834be 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -400,7 +400,7 @@
}
}
// 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 808bcee..4d957dc 100644
--- a/tests/InfRectTest.cpp
+++ b/tests/InfRectTest.cpp
@@ -15,22 +15,24 @@
}
#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 a680b44..269e359 100644
--- a/tests/Matrix44Test.cpp
+++ b/tests/Matrix44Test.cpp
@@ -25,7 +25,7 @@
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 98e4e5d..a8387d5 100644
--- a/tests/RoundRectTest.cpp
+++ b/tests/RoundRectTest.cpp
@@ -35,7 +35,7 @@
// 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();