Index: content/common/cursors/webcursor.cc |
diff --git a/content/common/cursors/webcursor.cc b/content/common/cursors/webcursor.cc |
index 6bc3f3eb98fa7985262f2a056f10d399ccff798a..faa6d703b4f53169468556fe15d596ca0c1ad33e 100644 |
--- a/content/common/cursors/webcursor.cc |
+++ b/content/common/cursors/webcursor.cc |
@@ -231,10 +231,12 @@ void WebCursor::SetCustomData(const SkBitmap& bitmap) { |
return; |
// Fill custom_data_ directly with the NativeImage pixels. |
- SkAutoLockPixels bitmap_lock(bitmap); |
custom_data_.resize(bitmap.getSize()); |
- if (!custom_data_.empty()) |
- memcpy(&custom_data_[0], bitmap.getPixels(), bitmap.getSize()); |
+ if (!custom_data_.empty()) { |
+ //This will divide color values by alpha (un-premultiply) if necessary |
+ SkImageInfo dstInfo = bitmap.info().makeAlphaType(kUnpremul_SkAlphaType); |
+ bitmap.readPixels(dstInfo, &custom_data_[0], dstInfo.minRowBytes(), 0, 0); |
+ } |
custom_size_.set_width(bitmap.width()); |
custom_size_.set_height(bitmap.height()); |
} |
@@ -243,7 +245,10 @@ void WebCursor::ImageFromCustomData(SkBitmap* image) const { |
if (custom_data_.empty()) |
return; |
- if (!image->tryAllocN32Pixels(custom_size_.width(), custom_size_.height())) |
+ SkImageInfo image_info = SkImageInfo::MakeN32(custom_size_.width(), |
+ custom_size_.height(), |
+ kUnpremul_SkAlphaType); |
+ if (!image->tryAllocPixels(image_info)) |
return; |
memcpy(image->getPixels(), &custom_data_[0], custom_data_.size()); |
} |