From 7e8a83c5f13b6ed0c5be202f5697efc07cee06ce Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Thu, 12 Aug 2010 00:55:14 +0000 Subject: GTK: fix decoding of custom cursor bytes. The bytes of an SkBitmap are not directly translatable into those of a GdkPixbuf. Use the utility function we already have for converting between the pixel data of these two types. BUG=51816 TEST=see bug Review URL: http://codereview.chromium.org/3130008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55825 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/glue/webcursor_gtk.cc | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'webkit/glue/webcursor_gtk.cc') diff --git a/webkit/glue/webcursor_gtk.cc b/webkit/glue/webcursor_gtk.cc index 70c0f46..54c8837 100644 --- a/webkit/glue/webcursor_gtk.cc +++ b/webkit/glue/webcursor_gtk.cc @@ -8,6 +8,7 @@ #include #include "base/logging.h" +#include "gfx/gtk_util.h" #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" using WebKit::WebCursorInfo; @@ -171,18 +172,13 @@ GdkCursor* WebCursor::GetCustomCursor() const { return NULL; } - const guchar* data = reinterpret_cast(&custom_data_[0]); - GdkPixbuf* pixbuf = - gdk_pixbuf_new_from_data(data, - GDK_COLORSPACE_RGB, - TRUE, // has_alpha - 8, // bits_per_sample - custom_size_.width(), // width - custom_size_.height(), // height - custom_size_.width() * 4, // row stride - NULL, // data destroy function - NULL); // data destroy function extra data + SkBitmap bitmap; + bitmap.setConfig(SkBitmap::kARGB_8888_Config, + custom_size_.width(), custom_size_.height()); + bitmap.allocPixels(); + memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size()); + GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); GdkCursor* cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, hotspot_.x(), -- cgit v1.1