diff options
| author | benjaminwagner <benjaminwagner@google.com> | 2015-12-11 14:08:58 -0800 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2015-12-11 14:08:59 -0800 |
| commit | a1bb8e02fe7956b2f85a0afadbca5f607a804403 (patch) | |
| tree | 2f88af63800c221ba3711f9eb7f48779cc458be9 /tests/BitmapTest.cpp | |
| parent | 52e2581700b719aad317605160a2cef45d3db68b (diff) | |
In SkPixmap.cpp, change SkAlphaMul to SkMulDiv255.
Add a test that we get the same color back after calling SkBitmap::eraseColor, modulo rounding.
Also update some incorrect docs.
BUG=skia:4297
Review URL: https://codereview.chromium.org/1521673002
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); +} |
