aboutsummaryrefslogtreecommitdiffstats
path: root/tests/MathTest.cpp
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-04-14 09:57:06 -0400
committerDerek Sollenberger <djsollen@google.com>2011-04-14 15:01:11 -0400
commit87b8e645865f9633f410c02252a0fd3feb18f09b (patch)
tree21e2521ed6f69bf466849f7c9579c37aa6b22b06 /tests/MathTest.cpp
parent7f10e10e25231b613ebb242fa14ad8c924ce694f (diff)
downloadexternal_skia-87b8e645865f9633f410c02252a0fd3feb18f09b.zip
external_skia-87b8e645865f9633f410c02252a0fd3feb18f09b.tar.gz
external_skia-87b8e645865f9633f410c02252a0fd3feb18f09b.tar.bz2
Skia Merge (revision 1116)
There is a companion change in external/webkit Change-Id: I1c4110e7520bbef3f4e5f9551adb7ec79ac1e3ed
Diffstat (limited to 'tests/MathTest.cpp')
-rw-r--r--tests/MathTest.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp
index 493691e..7a9364f 100644
--- a/tests/MathTest.cpp
+++ b/tests/MathTest.cpp
@@ -3,6 +3,40 @@
#include "SkPoint.h"
#include "SkRandom.h"
+#if 0
+static U8CPU premul_fast(U8CPU a, U8CPU x) {
+ return a * x * 32897 >> 23;
+}
+
+static U8CPU premul_trunc(U8CPU a, U8CPU x) {
+ double result = a * x;
+ result /= 255.0;
+ return (unsigned)floor(result + 0.0);
+}
+
+static U8CPU premul_round(U8CPU a, U8CPU x) {
+ double result = a * x;
+ result /= 255.0;
+ return (unsigned)floor(result + 0.5);
+}
+
+static void test_premul(skiatest::Reporter* reporter) {
+ for (int a = 0; a <= 255; a++) {
+ for (int x = 0; x <= 255; x++) {
+ unsigned curr_trunc = SkMulDiv255Trunc(a, x);
+ unsigned curr_round = SkMulDiv255Round(a, x);
+ unsigned fast = premul_fast(a, x);
+ unsigned slow_round = premul_round(a, x);
+ unsigned slow_trunc = premul_trunc(a, x);
+ if (fast != slow || curr != fast) {
+ SkDebugf("---- premul(%d %d) curr=%d fast=%d slow=%d\n", a, x,
+ curr, fast, slow);
+ }
+ }
+ }
+}
+#endif
+
#if defined(SkLONGLONG)
static int symmetric_fixmul(int a, int b) {
int sa = SkExtractSign(a);
@@ -458,6 +492,8 @@ static void TestMath(skiatest::Reporter* reporter) {
}
SkDebugf("SinCos: maximum error = %d\n", maxDiff);
#endif
+
+// test_premul(reporter);
}
#include "TestClassDef.h"