2009-04-23 Zan Dobersek <zandobersek@gmail.com>
authorkov@webkit.org <kov@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Apr 2009 18:45:15 +0000 (18:45 +0000)
committerkov@webkit.org <kov@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Apr 2009 18:45:15 +0000 (18:45 +0000)
        Reviewed by Gustavo Noronha.

        When creating a new drawable object, collect system's
        information about the best depth it can provide and use it
        in a new colormap that the new drawable requires.

        * platform/graphics/gtk/ImageGtk.cpp:
        (WebCore::BitmapImage::getGdkPixbuf):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@42783 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/gtk/ImageGtk.cpp

index 60c9987..1a6fec3 100644 (file)
@@ -2,6 +2,17 @@
 
         Reviewed by Gustavo Noronha.
 
+        When creating a new drawable object, collect system's
+        information about the best depth it can provide and use it
+        in a new colormap that the new drawable requires.
+
+        * platform/graphics/gtk/ImageGtk.cpp:
+        (WebCore::BitmapImage::getGdkPixbuf):
+
+2009-04-23  Zan Dobersek  <zandobersek@gmail.com>
+
+        Reviewed by Gustavo Noronha.
+
         https://bugs.webkit.org/show_bug.cgi?id=15654
         GdkPixbuf support for ImageCairo
 
index caf3068..daf98c2 100644 (file)
@@ -57,7 +57,11 @@ GdkPixbuf* BitmapImage::getGdkPixbuf()
     int width = cairo_image_surface_get_width(frameAtIndex(currentFrame()));
     int height = cairo_image_surface_get_height(frameAtIndex(currentFrame()));
 
-    GdkPixmap* pixmap = gdk_pixmap_new(0, width, height, 32);
+    int bestDepth = gdk_visual_get_best_depth();
+    GdkColormap* cmap = gdk_colormap_new(gdk_visual_get_best_with_depth(bestDepth), true);
+
+    GdkPixmap* pixmap = gdk_pixmap_new(0, width, height, bestDepth);
+    gdk_drawable_set_colormap(GDK_DRAWABLE(pixmap), cmap);
     cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(pixmap));
     cairo_set_source_surface(cr, frameAtIndex(currentFrame()), 0, 0);
     cairo_paint(cr);
@@ -65,6 +69,7 @@ GdkPixbuf* BitmapImage::getGdkPixbuf()
 
     GdkPixbuf* pixbuf = gdk_pixbuf_get_from_drawable(0, GDK_DRAWABLE(pixmap), 0, 0, 0, 0, 0, width, height);
     g_object_unref(pixmap);
+    g_object_unref(cmap);
 
     return pixbuf;
 }