diff options
Diffstat (limited to 'tests/BitmapTest.cpp')
| -rw-r--r-- | tests/BitmapTest.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp index 2bd8490b77..58e3c8b3ec 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); +} |
