Changeset 42780 in webkit


Ignore:
Timestamp:
Apr 23, 2009 8:39:29 AM (15 years ago)
Author:
kov@webkit.org
Message:

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

Add support for converting a Cairo surface to a GdkPixbuf.

  • platform/graphics/BitmapImage.h:
  • platform/graphics/Image.h: (WebCore::Image::getGdkPixbuf):
  • platform/graphics/gtk/ImageGtk.cpp: (WebCore::BitmapImage::getGdkPixbuf):
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r42778 r42780  
     12009-04-23  Zan Dobersek  <zandobersek@gmail.com>
     2
     3        Reviewed by Gustavo Noronha.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=15654
     6        GdkPixbuf support for ImageCairo
     7
     8        Add support for converting a Cairo surface to a GdkPixbuf.
     9
     10        * platform/graphics/BitmapImage.h:
     11        * platform/graphics/Image.h:
     12        (WebCore::Image::getGdkPixbuf):
     13        * platform/graphics/gtk/ImageGtk.cpp:
     14        (WebCore::BitmapImage::getGdkPixbuf):
     15
    1162009-04-23  Kenneth Rohde Christiansen  <kenneth.christiansen@openbossa.org>
    217
  • trunk/WebCore/platform/graphics/BitmapImage.h

    r41358 r42780  
    141141#endif
    142142
     143#if PLATFORM(GTK)
     144    virtual GdkPixbuf* getGdkPixbuf();
     145#endif
     146
    143147    virtual NativeImagePtr nativeImageForCurrentFrame() { return frameAtIndex(currentFrame()); }
    144148
  • trunk/WebCore/platform/graphics/Image.h

    r41996 r42780  
    6060#if PLATFORM(QT)
    6161#include <QPixmap>
     62#endif
     63
     64#if PLATFORM(GTK)
     65typedef struct _GdkPixbuf GdkPixbuf;
    6266#endif
    6367
     
    143147#endif
    144148
     149#if PLATFORM(GTK)
     150    virtual GdkPixbuf* getGdkPixbuf() { return 0; }
     151#endif
     152
    145153protected:
    146154    Image(ImageObserver* = 0);
  • trunk/WebCore/platform/graphics/gtk/ImageGtk.cpp

    r35731 r42780  
    2828#include "BitmapImage.h"
    2929
     30#include <cairo.h>
     31#include <gtk/gtk.h>
     32
    3033// This function loads resources from WebKit
    3134Vector<char> loadResourceIntoArray(const char*);
     
    5053}
    5154
     55GdkPixbuf* BitmapImage::getGdkPixbuf()
     56{
     57    int width = cairo_image_surface_get_width(frameAtIndex(currentFrame()));
     58    int height = cairo_image_surface_get_height(frameAtIndex(currentFrame()));
     59
     60    GdkPixmap* pixmap = gdk_pixmap_new(0, width, height, 32);
     61    cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(pixmap));
     62    cairo_set_source_surface(cr, frameAtIndex(currentFrame()), 0, 0);
     63    cairo_paint(cr);
     64    cairo_destroy(cr);
     65
     66    GdkPixbuf* pixbuf = gdk_pixbuf_get_from_drawable(0, GDK_DRAWABLE(pixmap), 0, 0, 0, 0, 0, width, height);
     67    g_object_unref(pixmap);
     68
     69    return pixbuf;
    5270}
     71
     72}
Note: See TracChangeset for help on using the changeset viewer.