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

Unified Diff: gfx/skbitmap_operations.cc

Issue 2963009: Windows: Fix opacity of drag images.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: merge Created 10 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 | « gfx/skbitmap_operations.h ('k') | gfx/skbitmap_operations_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gfx/skbitmap_operations.cc
diff --git a/gfx/skbitmap_operations.cc b/gfx/skbitmap_operations.cc
index 27508bad5241fed6dda395c7dafe1e042447459e..b8cec114e5c87759567edf5de3645e6c3a7f98a2 100644
--- a/gfx/skbitmap_operations.cc
+++ b/gfx/skbitmap_operations.cc
@@ -668,3 +668,30 @@ SkBitmap SkBitmapOperations::DownsampleByTwo(const SkBitmap& bitmap) {
return result;
}
+// static
+SkBitmap SkBitmapOperations::UnPreMultiply(const SkBitmap& bitmap) {
+ if (bitmap.isNull())
+ return bitmap;
+ if (bitmap.isOpaque())
+ return bitmap;
+
+ SkBitmap opaque_bitmap;
+ opaque_bitmap.setConfig(bitmap.config(), bitmap.width(), bitmap.height());
+ opaque_bitmap.allocPixels();
+
+ {
+ SkAutoLockPixels bitmap_lock(bitmap);
+ SkAutoLockPixels opaque_bitmap_lock(opaque_bitmap);
+ for (int y = 0; y < opaque_bitmap.height(); y++) {
+ for (int x = 0; x < opaque_bitmap.width(); x++) {
+ uint32 src_pixel = *bitmap.getAddr32(x, y);
+ uint32* dst_pixel = opaque_bitmap.getAddr32(x, y);
+ SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(src_pixel);
+ *dst_pixel = unmultiplied;
+ }
+ }
+ }
+
+ opaque_bitmap.setIsOpaque(true);
+ return opaque_bitmap;
+}
« no previous file with comments | « gfx/skbitmap_operations.h ('k') | gfx/skbitmap_operations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698