Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: tests/BitmapTest.cpp

Issue 1521673002: In SkPixmap.cpp, change SkAlphaMul to SkMulDiv255. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Make uppercase consistent. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPixmap.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « src/core/SkPixmap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698