blob: c10897f1737497b42967bed7a607f081eb3f052c [file] [log] [blame]
reed@google.com83acbe02011-04-22 19:18:20 +00001#include "Test.h"
2#include "SkColor.h"
3#include "SkUnPreMultiply.h"
4
5static void test_premul(skiatest::Reporter* reporter) {
6 for (int a = 0; a <= 255; a++) {
7 for (int x = 0; x <= 255; x++) {
8 SkColor c0 = SkColorSetARGB(a, x, x, x);
9 SkPMColor p0 = SkPreMultiplyColor(c0);
10
11 SkColor c1 = SkUnPreMultiply::PMColorToColor(p0);
12 SkPMColor p1 = SkPreMultiplyColor(c1);
13
14 // we can't promise that c0 == c1, since c0 -> p0 is a many to one
15 // function, however, we can promise that p0 -> c1 -> p1 : p0 == p1
16 REPORTER_ASSERT(reporter, p0 == p1);
17 }
18 }
19}
20
21
22static void TestColor(skiatest::Reporter* reporter) {
23 test_premul(reporter);
24}
25
26#include "TestClassDef.h"
27DEFINE_TESTCLASS("Color", ColorTestClass, TestColor)