summaryrefslogtreecommitdiffstats
path: root/skia/ext
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-25 02:07:00 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-25 02:07:00 +0000
commit30bcf3718ace8f0ab46be60f318b476b658217b2 (patch)
tree5fc5a90d6086002db86dfb1aa49de271450a6fd9 /skia/ext
parent9840e55175f02e7580bbce98c27a4276d5259350 (diff)
downloadchromium_src-30bcf3718ace8f0ab46be60f318b476b658217b2.zip
chromium_src-30bcf3718ace8f0ab46be60f318b476b658217b2.tar.gz
chromium_src-30bcf3718ace8f0ab46be60f318b476b658217b2.tar.bz2
Attempt to fix the ImageOperations::CreateMaskedBitmap UMR by bringing the unittest code in line with the other tests in image_operations_unittest. My half-educated suspicion is that alpha wasn't getting initted correctly, as a new UMR appeared in the "SkColor alpha_pixel = " line. (Can't verify as all my machines are in boxes).
(This is TBR because the build is red). TBR=tony BUG=15762 TEST=Run valgrind/purify as in bug Review URL: http://codereview.chromium.org/159381 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext')
-rw-r--r--skia/ext/image_operations.cc4
-rw-r--r--skia/ext/image_operations_unittest.cc17
2 files changed, 11 insertions, 10 deletions
diff --git a/skia/ext/image_operations.cc b/skia/ext/image_operations.cc
index 9b0beb1..a86f99e 100644
--- a/skia/ext/image_operations.cc
+++ b/skia/ext/image_operations.cc
@@ -388,12 +388,12 @@ SkBitmap ImageOperations::CreateMaskedBitmap(const SkBitmap& rgb,
SkAutoLockPixels lock_alpha(alpha);
SkAutoLockPixels lock_masked(masked);
- for (int y = 0; y < rgb.height(); y++) {
+ for (int y = 0; y < masked.height(); y++) {
uint32* rgb_row = rgb.getAddr32(0, y);
uint32* alpha_row = alpha.getAddr32(0, y);
uint32* dst_row = masked.getAddr32(0, y);
- for (int x = 0; x < rgb.width(); x++) {
+ for (int x = 0; x < masked.width(); x++) {
uint32 alpha_pixel = alpha_row[x];
SkColor rgb_pixel = SkUnPreMultiply::PMColorToColor(rgb_row[x]);
diff --git a/skia/ext/image_operations_unittest.cc b/skia/ext/image_operations_unittest.cc
index 40e63bd..5066683 100644
--- a/skia/ext/image_operations_unittest.cc
+++ b/skia/ext/image_operations_unittest.cc
@@ -202,19 +202,20 @@ TEST(ImageOperations, CreateMaskedBitmap) {
SkBitmap alpha;
alpha.setConfig(SkBitmap::kARGB_8888_Config, src_w, src_h);
alpha.allocPixels();
-
- unsigned char* src_data =
- reinterpret_cast<unsigned char*>(alpha.getAddr32(0, 0));
- for (int i = 0; i < src_w * src_h; i++) {
- src_data[i * 4] = SkColorSetARGB(i + 128 % 255,
- i + 128 % 255,
- i + 64 % 255,
- i + 0 % 255);
+ for (int y = 0, i = 0; y < src_h; y++) {
+ for (int x = 0; x < src_w; x++) {
+ *alpha.getAddr32(x, y) = SkColorSetARGB(i + 128 % 255,
+ i + 128 % 255,
+ i + 64 % 255,
+ i + 0 % 255);
+ i++;
+ }
}
SkBitmap masked = skia::ImageOperations::CreateMaskedBitmap(src, alpha);
SkAutoLockPixels src_lock(src);
+ SkAutoLockPixels alpha_lock(alpha);
SkAutoLockPixels masked_lock(masked);
for (int y = 0; y < src_h; y++) {
for (int x = 0; x < src_w; x++) {