Refactor FourByteInterps.  Add 64-bit Fast version.  Add tests.

Effect on benches (only _fast_ should be affected, and only on 64-bit):

Desktop (64-bit)
four_byte_interp_slow_255 NONRENDERING c          7.80       7.84      -0.04    -0.5%
four_byte_interp_slow_256 NONRENDERING c          7.38       7.36      +0.02    +0.3%
four_byte_interp_fast_256 NONRENDERING c          4.86       4.38      +0.48    +9.9%
four_byte_interp_fast_255 NONRENDERING c          5.80       5.16      +0.64   +11.0%

N5 (32-bit)
four_byte_interp_slow_256 NONRENDERING c         22.22      22.66      -0.44    -2.0%
four_byte_interp_fast_255 NONRENDERING c         22.22      22.22      +0.00    +0.0%
four_byte_interp_fast_256 NONRENDERING c         18.81      18.81      +0.00    +0.0%
four_byte_interp_slow_255 NONRENDERING c         22.42      22.42      +0.00    +0.0%

BUG=
R=reed@google.com

Author: mtklein@google.com

Review URL: https://codereview.chromium.org/100923003

git-svn-id: http://skia.googlecode.com/svn/trunk@12468 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/ColorPrivTest.cpp b/tests/ColorPrivTest.cpp
new file mode 100644
index 0000000..ddcde5d
--- /dev/null
+++ b/tests/ColorPrivTest.cpp
@@ -0,0 +1,44 @@
+#include "Test.h"
+#include "TestClassDef.h"
+
+#include "SkColorPriv.h"
+
+#define ASSERT(expr) REPORTER_ASSERT(r, expr)
+
+DEF_TEST(Splay, r) {
+    const SkPMColor color = 0xA1B2C3D4;
+
+    uint32_t ag, rb;
+    SkSplay(color, &ag, &rb);
+    ASSERT(ag == 0x00A100C3);
+    ASSERT(rb == 0x00B200D4);
+    ASSERT(SkUnsplay(ag << 8, rb << 8) == color);
+
+    const uint64_t agrb = SkSplay(color);
+    ASSERT(agrb == 0x00A100C300B200D4);
+    ASSERT(SkUnsplay(agrb<<8) == color);
+}
+
+DEF_TEST(FourByteInterp, r) {
+    const SkPMColor src = 0xAB998877, dst = 0x66334455;
+    for (unsigned scale = 0; scale <= 256; scale++) {
+        ASSERT(SkFourByteInterp256(src, dst, scale) == SkFastFourByteInterp256(src, dst, scale));
+    }
+
+    for (unsigned scale = 0; scale < 256; scale++) {
+        // SkFourByteInterp and SkFastFourByteInterp convert from [0, 255] to [0, 256] differently.
+        // In particular, slow may end up a little too high (weirdly, fast is more accurate).
+        const SkPMColor slow = SkFourByteInterp(src, dst, scale);
+        const SkPMColor fast = SkFastFourByteInterp(src, dst, scale);
+
+        const int deltaA = SkGetPackedA32(slow) - SkGetPackedA32(fast);
+        const int deltaR = SkGetPackedR32(slow) - SkGetPackedR32(fast);
+        const int deltaG = SkGetPackedG32(slow) - SkGetPackedG32(fast);
+        const int deltaB = SkGetPackedB32(slow) - SkGetPackedB32(fast);
+
+        ASSERT(deltaA == 0 || deltaA == 1);
+        ASSERT(deltaR == 0 || deltaR == 1);
+        ASSERT(deltaG == 0 || deltaG == 1);
+        ASSERT(deltaB == 0 || deltaB == 1);
+    }
+}