Mercurial > dwindows
changeset 815:c1e93dd575a5
Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 26 Mar 2011 04:53:41 +0000 |
parents | f5972669d7e9 |
children | 916002e29d4c |
files | dw.h gtk3/dw.c |
diffstat | 2 files changed, 11 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/dw.h Sat Mar 26 04:31:23 2011 +0000 +++ b/dw.h Sat Mar 26 04:53:41 2011 +0000 @@ -1258,6 +1258,7 @@ unsigned long width, height; #if GTK_MAJOR_VERSION > 2 GdkPixbuf *pixbuf; /* the actual image */ + cairo_surface_t *image; /* Going to have dual storage for now */ #else GdkPixmap *pixmap; /* the actual image */ GdkBitmap *bitmap; /* if not null, the image mask representing the transparency mask */
--- a/gtk3/dw.c Sat Mar 26 04:31:23 2011 +0000 +++ b/gtk3/dw.c Sat Mar 26 04:53:41 2011 +0000 @@ -6592,10 +6592,8 @@ DW_MUTEX_LOCK; if(handle) cr = gdk_cairo_create(gtk_widget_get_window(handle)); -#if 0 /* TODO */ else if(pixmap) - gc = _set_colors(pixmap->pixbuf); -#endif + cr = cairo_create(pixmap->image); if(cr) { int index = _find_thread_index(dw_thread_id()); @@ -6626,10 +6624,8 @@ DW_MUTEX_LOCK; if(handle) cr = gdk_cairo_create(gtk_widget_get_window(handle)); -#if 0 /* TODO */ else if(pixmap) - gc = _set_colors(pixmap->pixbuf); -#endif + cr = cairo_create(pixmap->image); if(cr) { int index = _find_thread_index(dw_thread_id()); @@ -6662,10 +6658,8 @@ DW_MUTEX_LOCK; if(handle) cr = gdk_cairo_create(gtk_widget_get_window(handle)); -#if 0 /* TODO */ else if(pixmap) - gc = _set_colors(pixmap->pixbuf); -#endif + cr = cairo_create(pixmap->image); if(cr) { int index = _find_thread_index(dw_thread_id()); @@ -6703,10 +6697,8 @@ DW_MUTEX_LOCK; if(handle) cr = gdk_cairo_create(gtk_widget_get_window(handle)); -#if 0 /* TODO */ else if(pixmap) - gc = _set_colors(pixmap->pixbuf); -#endif + cr = cairo_create(pixmap->image); if(cr) { int index = _find_thread_index(dw_thread_id()); @@ -6749,13 +6741,11 @@ cr = gdk_cairo_create(gtk_widget_get_window(handle)); fontname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname"); } -#if 0 /* TODO */ else if(pixmap) { fontname = (char *)g_object_get_data(G_OBJECT(pixmap->handle), "_dw_fontname"); - gc = _set_colors(pixmap->pixbuf); - } -#endif + cr = cairo_create(pixmap->image); + } if(cr) { font = pango_font_description_from_string(fontname); @@ -6884,10 +6874,8 @@ /* Depth needs to be divided by 3... but for the RGB colorspace... * only 8 bits per sample is allowed, so to avoid issues just pass 8 for now. */ - if ( handle ) - pixmap->pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, FALSE, 8, width, height ); - else - pixmap->pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, FALSE, 8, width, height ); + pixmap->pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, FALSE, 8, width, height ); + pixmap->image = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); DW_MUTEX_UNLOCK; return pixmap; } @@ -6938,6 +6926,7 @@ DW_MUTEX_LOCK; pixmap->pixbuf = gdk_pixbuf_new_from_file(file, NULL); + pixmap->image = cairo_image_surface_create_from_png(file); pixmap->width = gdk_pixbuf_get_width(pixmap->pixbuf); pixmap->height = gdk_pixbuf_get_height(pixmap->pixbuf); pixmap->handle = handle; @@ -6983,6 +6972,7 @@ return 0; } pixmap->pixbuf = gdk_pixbuf_new_from_file(file, NULL); + pixmap->image = cairo_image_surface_create_from_png(file); pixmap->width = gdk_pixbuf_get_width(pixmap->pixbuf); pixmap->height = gdk_pixbuf_get_height(pixmap->pixbuf); /* remove our temporary file */