Author: vince
Date: Tue Dec 27 14:59:08 2011
New Revision: 13349
URL:
http://source.netsurf-browser.org?rev=13349&view=rev
Log:
still not working pixmap_from_cairo_surface
Modified:
branches/vince/netsurf-cairo/gtk/scaffolding.c
Modified: branches/vince/netsurf-cairo/gtk/scaffolding.c
URL:
http://source.netsurf-browser.org/branches/vince/netsurf-cairo/gtk/scaffo...
==============================================================================
--- branches/vince/netsurf-cairo/gtk/scaffolding.c (original)
+++ branches/vince/netsurf-cairo/gtk/scaffolding.c Tue Dec 27 14:59:08 2011
@@ -1992,33 +1992,29 @@
gtk_image_set_from_pixbuf(g->throbber, nsgtk_throbber->framedata[0]);
}
-/**
- * set favicon
- */
-void gui_window_set_icon(struct gui_window *_g, hlcache_handle *icon)
-{
- struct gtk_scaffolding *g = nsgtk_get_scaffold(_g);
- struct bitmap *icon_bitmap;
- GtkImage *iconImage = NULL;
-
- if (g->top_level != _g)
- return;
-
- icon_bitmap = (icon != NULL) ? content_get_bitmap(icon) : NULL;
-
- if (icon_bitmap != NULL) {
- int bmwidth, bmheight;
- cairo_surface_t *bmsurface = icon_bitmap->surface;
- bmwidth = cairo_image_surface_get_width(bmsurface);
- bmheight = cairo_image_surface_get_height(bmsurface);
-
- GdkPixmap *pixmap;
- pixmap = gdk_pixmap_new(g->url_bar->window, 16, 16, -1);
-
- cairo_t *cr;
- cr = gdk_cairo_create(pixmap);
-
- cairo_scale(cr, (double)16 / bmwidth, (double)16 / bmheight);
+static GdkPixmap *
+pixmap_from_cairo_surface(cairo_surface_t *bmsurface,
+ GdkDrawable *drawable,
+ int width,
+ int height)
+{
+ int bmwidth, bmheight;
+ GdkPixmap *pixmap;
+ cairo_t *cr;
+
+ cairo_surface_flush(bmsurface);
+
+ bmwidth = cairo_image_surface_get_width(bmsurface);
+ bmheight = cairo_image_surface_get_height(bmsurface);
+
+ pixmap = gdk_pixmap_new(drawable, width, height, -1);
+
+ cr = gdk_cairo_create(pixmap);
+
+ if (cairo_status(cr) == CAIRO_STATUS_SUCCESS) {
+ cairo_scale(cr,
+ (double)width / bmwidth,
+ (double)height / bmheight);
cairo_set_source_surface(cr, bmsurface, 0, 0);
@@ -2037,10 +2033,38 @@
/* Do the actual drawing */
cairo_paint(cr);
- cairo_destroy(cr);
+ cairo_surface_flush(cairo_get_target(cr));
+ } else {
+ LOG(("%s", cairo_status_to_string(cairo_status(cr))));
+ g_object_unref(pixmap);
+ pixmap = NULL;
+ }
+
+ cairo_destroy(cr);
+
+ return pixmap;
+}
+
+/**
+ * set favicon
+ */
+void gui_window_set_icon(struct gui_window *_g, hlcache_handle *icon)
+{
+ struct gtk_scaffolding *g = nsgtk_get_scaffold(_g);
+ struct bitmap *icon_bitmap;
+ GtkImage *iconImage = NULL;
+
+ if (g->top_level != _g)
+ return;
+
+ icon_bitmap = (icon != NULL) ? content_get_bitmap(icon) : NULL;
+
+ if (icon_bitmap != NULL) {
+ GdkPixmap *pixmap;
+ pixmap = pixmap_from_cairo_surface(icon_bitmap->surface, ((GtkWidget
*)g->window)->window, 16, 16);
iconImage = GTK_IMAGE(gtk_image_new_from_pixmap(pixmap, NULL));
-
+ LOG(("set to %p",iconImage));
g_object_unref(pixmap);
}