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

Unified Diff: skia/ext/image_operations_unittest.cc

Issue 160034: Our masker didn't account for the source image also having alpha.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months 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 | « skia/ext/image_operations.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/image_operations_unittest.cc
===================================================================
--- skia/ext/image_operations_unittest.cc (revision 21515)
+++ skia/ext/image_operations_unittest.cc (working copy)
@@ -6,8 +6,9 @@
#include "skia/ext/image_operations.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColorPriv.h"
-#include "third_party/skia/include/core/SkBitmap.h"
+#include "third_party/skia/include/core/SkUnPreMultiply.h"
namespace {
@@ -218,18 +219,20 @@
for (int y = 0; y < src_h; y++) {
for (int x = 0; x < src_w; x++) {
// Test that the alpha is equal.
- SkColor src_pixel = *src.getAddr32(x, y);
- SkColor alpha_pixel = *alpha.getAddr32(x, y);
+ SkColor src_pixel = SkUnPreMultiply::PMColorToColor(*src.getAddr32(x, y));
+ SkColor alpha_pixel =
+ SkUnPreMultiply::PMColorToColor(*alpha.getAddr32(x, y));
SkColor masked_pixel = *masked.getAddr32(x, y);
- // Test that the alpha is equal.
- unsigned int alpha = (alpha_pixel & 0xff000000) >> SK_A32_SHIFT;
- EXPECT_EQ(alpha, (masked_pixel & 0xff000000) >> SK_A32_SHIFT);
+ int alpha_value = SkAlphaMul(SkColorGetA(src_pixel),
+ SkColorGetA(alpha_pixel));
+ SkColor expected_pixel = SkColorSetARGB(
+ alpha_value,
+ SkAlphaMul(SkColorGetR(src_pixel), alpha_value),
+ SkAlphaMul(SkColorGetG(src_pixel), alpha_value),
+ SkAlphaMul(SkColorGetB(src_pixel), alpha_value));
- // Test that the colors are right - SkBitmaps have premultiplied alpha,
- // so we can't just do a direct comparison.
- EXPECT_EQ(SkColorGetR(masked_pixel),
- SkAlphaMul(SkColorGetR(src_pixel), alpha));
+ EXPECT_TRUE(ColorsClose(expected_pixel, masked_pixel));
}
}
}
« no previous file with comments | « skia/ext/image_operations.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698