aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-19 22:28:48 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-19 22:28:48 +0000
commitb1560445c66a751fc2ea7b85b94430a985940f3e (patch)
tree0b32c5228339f562a7f1c983638ff81b3568afae /tests
parent8d7ed847be265d3e5058079029a3f6430d93130e (diff)
Revert "begin to remove SkLONGLONG and wean Skia off of Sk64"
This reverts commit 784890196fdab96289f9389db43aca01f35db0f9. Revert "use LL suffix for 64bit literal" This reverts commit 9634295aff9bffd7a3875a0ca4a9b1a27d0793fc. BUG= Review URL: https://codereview.chromium.org/116543009 git-svn-id: http://skia.googlecode.com/svn/trunk@12790 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/BitmapCopyTest.cpp12
-rw-r--r--tests/MathTest.cpp17
-rw-r--r--tests/Sk64Test.cpp48
3 files changed, 47 insertions, 30 deletions
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp
index 7a1d9acd7c..0df8c06d9b 100644
--- a/tests/BitmapCopyTest.cpp
+++ b/tests/BitmapCopyTest.cpp
@@ -358,22 +358,22 @@ DEF_TEST(BitmapCopy, reporter) {
case SkBitmap::kA8_Config:
case SkBitmap::kIndex8_Config:
- if (safeSize.as64() != 0x2386F26FC10000LL) {
+ if (safeSize.fHi != 0x2386F2 ||
+ safeSize.fLo != 0x6FC10000)
sizeFail = true;
- }
break;
case SkBitmap::kRGB_565_Config:
case SkBitmap::kARGB_4444_Config:
- if (safeSize.as64() != 0x470DE4DF820000LL) {
+ if (safeSize.fHi != 0x470DE4 ||
+ safeSize.fLo != 0xDF820000)
sizeFail = true;
- }
break;
case SkBitmap::kARGB_8888_Config:
- if (safeSize.as64() != 0x8E1BC9BF040000LL) {
+ if (safeSize.fHi != 0x8E1BC9 ||
+ safeSize.fLo != 0xBF040000)
sizeFail = true;
- }
break;
default:
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp
index 3efbbcb9fc..1b8954a361 100644
--- a/tests/MathTest.cpp
+++ b/tests/MathTest.cpp
@@ -188,6 +188,7 @@ static void test_blend(skiatest::Reporter* reporter) {
}
}
+#if defined(SkLONGLONG)
static int symmetric_fixmul(int a, int b) {
int sa = SkExtractSign(a);
int sb = SkExtractSign(b);
@@ -195,9 +196,19 @@ static int symmetric_fixmul(int a, int b) {
a = SkApplySign(a, sa);
b = SkApplySign(b, sb);
- int c = (int)(((int64_t)a * b) >> 16);
+#if 1
+ int c = (int)(((SkLONGLONG)a * b) >> 16);
+
return SkApplySign(c, sa ^ sb);
+#else
+ SkLONGLONG ab = (SkLONGLONG)a * b;
+ if (sa ^ sb) {
+ ab = -ab;
+ }
+ return ab >> 16;
+#endif
}
+#endif
static void check_length(skiatest::Reporter* reporter,
const SkPoint& p, SkScalar targetLen) {
@@ -481,11 +492,12 @@ DEF_TEST(Math, reporter) {
unittest_fastfloat(reporter);
unittest_isfinite(reporter);
+#ifdef SkLONGLONG
for (i = 0; i < 10000; i++) {
SkFixed numer = rand.nextS();
SkFixed denom = rand.nextS();
SkFixed result = SkFixedDiv(numer, denom);
- int64_t check = ((int64_t)numer << 16) / denom;
+ SkLONGLONG check = ((SkLONGLONG)numer << 16) / denom;
(void)SkCLZ(numer);
(void)SkCLZ(denom);
@@ -510,6 +522,7 @@ DEF_TEST(Math, reporter) {
r2 = SkFixedSquare(numer);
REPORTER_ASSERT(reporter, result == r2);
}
+#endif
test_blend(reporter);
diff --git a/tests/Sk64Test.cpp b/tests/Sk64Test.cpp
index 1777d24d10..589801b272 100644
--- a/tests/Sk64Test.cpp
+++ b/tests/Sk64Test.cpp
@@ -25,9 +25,14 @@ static void bool_table_test(skiatest::Reporter* reporter,
REPORTER_ASSERT(reporter, a.getSign() == table.sign);
}
-void Sk64::UnitTestWithReporter(void* reporterParam) {
- skiatest::Reporter* reporter = (skiatest::Reporter*)reporterParam;
+#ifdef SkLONGLONG
+ static SkLONGLONG asLL(const Sk64& a)
+ {
+ return ((SkLONGLONG)a.fHi << 32) | a.fLo;
+ }
+#endif
+DEF_TEST(Sk64Test, reporter) {
enum BoolTests {
kZero_BoolTest,
kPos_BoolTest,
@@ -91,7 +96,9 @@ void Sk64::UnitTestWithReporter(void* reporterParam) {
REPORTER_ASSERT(reporter, c.get32() == aa - bb);
}
- for (i = 0; i < 1000; i++) {
+#ifdef SkLONGLONG
+ for (i = 0; i < 1000; i++)
+ {
rand.next64(&a); //a.fHi >>= 1; // avoid overflow
rand.next64(&b); //b.fHi >>= 1; // avoid overflow
@@ -106,8 +113,8 @@ void Sk64::UnitTestWithReporter(void* reporterParam) {
b.fHi = 0;
}
- int64_t aa = a.as64();
- int64_t bb = b.as64();
+ SkLONGLONG aa = asLL(a);
+ SkLONGLONG bb = asLL(b);
REPORTER_ASSERT(reporter, (a < b) == (aa < bb));
REPORTER_ASSERT(reporter, (a <= b) == (aa <= bb));
@@ -117,31 +124,31 @@ void Sk64::UnitTestWithReporter(void* reporterParam) {
REPORTER_ASSERT(reporter, (a != b) == (aa != bb));
c = a; c.add(b);
- REPORTER_ASSERT(reporter, c.as64() == aa + bb);
+ REPORTER_ASSERT(reporter, asLL(c) == aa + bb);
c = a; c.sub(b);
- REPORTER_ASSERT(reporter, c.as64() == aa - bb);
+ REPORTER_ASSERT(reporter, asLL(c) == aa - bb);
c = a; c.rsub(b);
- REPORTER_ASSERT(reporter, c.as64() == bb - aa);
+ REPORTER_ASSERT(reporter, asLL(c) == bb - aa);
c = a; c.negate();
- REPORTER_ASSERT(reporter, c.as64() == -aa);
+ REPORTER_ASSERT(reporter, asLL(c) == -aa);
int bits = rand.nextU() & 63;
c = a; c.shiftLeft(bits);
- REPORTER_ASSERT(reporter, c.as64() == (aa << bits));
+ REPORTER_ASSERT(reporter, asLL(c) == (aa << bits));
c = a; c.shiftRight(bits);
- REPORTER_ASSERT(reporter, c.as64() == (aa >> bits));
+ REPORTER_ASSERT(reporter, asLL(c) == (aa >> bits));
c = a; c.roundRight(bits);
- int64_t tmp;
+ SkLONGLONG tmp;
tmp = aa;
if (bits > 0)
- tmp += (int64_t)1 << (bits - 1);
- REPORTER_ASSERT(reporter, c.as64() == (tmp >> bits));
+ tmp += (SkLONGLONG)1 << (bits - 1);
+ REPORTER_ASSERT(reporter, asLL(c) == (tmp >> bits));
c.setMul(a.fHi, b.fHi);
- tmp = (int64_t)a.fHi * b.fHi;
- REPORTER_ASSERT(reporter, c.as64() == tmp);
+ tmp = (SkLONGLONG)a.fHi * b.fHi;
+ REPORTER_ASSERT(reporter, asLL(c) == tmp);
}
@@ -153,11 +160,11 @@ void Sk64::UnitTestWithReporter(void* reporterParam) {
while (denom == 0)
denom = rand.nextS();
wide.setMul(rand.nextS(), rand.nextS());
- int64_t check = wide.getLongLong();
+ SkLONGLONG check = wide.getLongLong();
wide.div(denom, Sk64::kTrunc_DivOption);
check /= denom;
- int64_t w = wide.getLongLong();
+ SkLONGLONG w = wide.getLongLong();
REPORTER_ASSERT(reporter, check == w);
@@ -168,8 +175,5 @@ void Sk64::UnitTestWithReporter(void* reporterParam) {
int diff = denom - ck;
REPORTER_ASSERT(reporter, SkAbs32(diff) <= 1);
}
-}
-
-DEF_TEST(Sk64Test, reporter) {
- Sk64::UnitTestWithReporter(reporter);
+#endif
}