summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-20 02:00:08 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-20 02:00:08 +0000
commitaa0d77af73798a141846310e5d57487c8b7ab55d (patch)
tree6bc8e70bc868902684e950d92e72201a09631235 /ui/gfx
parent000bed6be3f6ccf8497096ff9f0cc31ec83c24d3 (diff)
downloadchromium_src-aa0d77af73798a141846310e5d57487c8b7ab55d.zip
chromium_src-aa0d77af73798a141846310e5d57487c8b7ab55d.tar.gz
chromium_src-aa0d77af73798a141846310e5d57487c8b7ab55d.tar.bz2
Fix ClipboardGtk::WriteBitmap not unpremultiplying images.
We share code with GdkPixbufFromSkBitmap now, which has also been updated to remove the need to pass in our own function to free memory. BUG=154573 Review URL: https://chromiumcodereview.appspot.com/11187047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163125 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/gtk_util.cc22
1 files changed, 7 insertions, 15 deletions
diff --git a/ui/gfx/gtk_util.cc b/ui/gfx/gtk_util.cc
index 4c39e1c..bc34224 100644
--- a/ui/gfx/gtk_util.cc
+++ b/ui/gfx/gtk_util.cc
@@ -52,10 +52,6 @@ class GdkCursorCache {
DISALLOW_COPY_AND_ASSIGN(GdkCursorCache);
};
-void FreePixels(guchar* pixels, gpointer data) {
- free(data);
-}
-
} // namespace
namespace gfx {
@@ -95,11 +91,16 @@ GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap) {
int width = bitmap.width();
int height = bitmap.height();
- int stride = bitmap.rowBytes();
+
+ GdkPixbuf* pixbuf = gdk_pixbuf_new(
+ GDK_COLORSPACE_RGB, // The only colorspace gtk supports.
+ TRUE, // There is an alpha channel.
+ 8,
+ width, height);
// SkBitmaps are premultiplied, we need to unpremultiply them.
const int kBytesPerPixel = 4;
- uint8* divided = static_cast<uint8*>(malloc(height * stride));
+ uint8* divided = gdk_pixbuf_get_pixels(pixbuf);
for (int y = 0, i = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
@@ -122,15 +123,6 @@ GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap) {
}
}
- // This pixbuf takes ownership of our malloc()ed data and will
- // free it for us when it is destroyed.
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(
- divided,
- GDK_COLORSPACE_RGB, // The only colorspace gtk supports.
- true, // There is an alpha channel.
- 8,
- width, height, stride, &FreePixels, divided);
-
return pixbuf;
}