add code to test different premul techniques (disabled right now)



git-svn-id: http://skia.googlecode.com/svn/trunk@1030 2bbb7eff-a529-9590-31e7-b0007b416f81
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 @@
     }
     SkDebugf("SinCos: maximum error = %d\n", maxDiff);
 #endif
+
+//    test_premul(reporter);
 }
 
 #include "TestClassDef.h"