| Index: tests/BitmapTest.cpp
|
| diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp
|
| index 2bd8490b770ae481370aa36328c5c3d1d6cbad0d..58e3c8b3ec71be8e7eb68f263a5a7b55e50f58d4 100644
|
| --- a/tests/BitmapTest.cpp
|
| +++ b/tests/BitmapTest.cpp
|
| @@ -145,3 +145,24 @@ DEF_TEST(Bitmap_getColor_Swizzle, r) {
|
| REPORTER_ASSERT(r, source.getColor(0, 0) == copy.getColor(0, 0));
|
| }
|
| }
|
| +
|
| +static void test_erasecolor_premul(skiatest::Reporter* reporter, SkColorType ct, SkColor input,
|
| + SkColor expected) {
|
| + SkBitmap bm;
|
| + bm.allocPixels(SkImageInfo::Make(1, 1, ct, kPremul_SkAlphaType));
|
| + bm.eraseColor(input);
|
| + SkDebugf("expected: %x actual: %x\n", expected, bm.getColor(0, 0));
|
| + REPORTER_ASSERT(reporter, bm.getColor(0, 0) == expected);
|
| +}
|
| +
|
| +/**
|
| + * This test checks that eraseColor premultiplies the color correctly.
|
| + */
|
| +DEF_TEST(Bitmap_eraseColor_Premul, r) {
|
| + SkColor color = 0x80FF0080;
|
| + test_erasecolor_premul(r, kAlpha_8_SkColorType, color, 0x80000000);
|
| + test_erasecolor_premul(r, kRGB_565_SkColorType, color, 0xFF840042);
|
| + test_erasecolor_premul(r, kARGB_4444_SkColorType, color, 0x88FF0080);
|
| + test_erasecolor_premul(r, kRGBA_8888_SkColorType, color, color);
|
| + test_erasecolor_premul(r, kBGRA_8888_SkColorType, color, color);
|
| +}
|
|
|