Skip to content

Commit

Permalink
libgd: Use cairo surfaces instead of pixbufs in gd_embed_image_in_frame
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Garcia Campos committed May 4, 2014
1 parent fe7a89a commit c5177e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
23 changes: 9 additions & 14 deletions cut-n-paste/libgd/gd-icon-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ gd_create_symbolic_icon (const gchar *name,
*
* Returns: (transfer full):
*/
GdkPixbuf *
gd_embed_image_in_frame (GdkPixbuf *source_image,
cairo_surface_t *
gd_embed_image_in_frame (cairo_surface_t *source_image,
const gchar *frame_image_url,
GtkBorder *slice_width,
GtkBorder *border_width)
Expand All @@ -126,8 +126,8 @@ gd_embed_image_in_frame (GdkPixbuf *source_image,
GdkPixbuf *retval;
GtkWidgetPath *path;

source_width = gdk_pixbuf_get_width (source_image);
source_height = gdk_pixbuf_get_height (source_image);
source_width = cairo_image_surface_get_width (source_image);
source_height = cairo_image_surface_get_height (source_image);

dest_width = source_width + border_width->left + border_width->right;
dest_height = source_height + border_width->top + border_width->bottom;
Expand All @@ -145,7 +145,7 @@ gd_embed_image_in_frame (GdkPixbuf *source_image,
g_error_free (error);
g_free (css_str);

return g_object_ref (source_image);
return cairo_surface_reference (source_image);
}

surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dest_width, dest_height);
Expand All @@ -158,9 +158,9 @@ gd_embed_image_in_frame (GdkPixbuf *source_image,
gtk_style_context_set_path (context, path);
gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), 600);

gtk_render_icon (context, cr,
source_image,
border_width->left, border_width->top);
gtk_render_icon_surface (context, cr,
source_image,
border_width->left, border_width->top);

gtk_style_context_save (context);
gtk_style_context_add_class (context, "embedded-image");
Expand All @@ -170,17 +170,12 @@ gd_embed_image_in_frame (GdkPixbuf *source_image,
dest_width, dest_height);

gtk_style_context_restore (context);

retval = gdk_pixbuf_get_from_surface (surface,
0, 0, dest_width, dest_height);

cairo_surface_destroy (surface);
cairo_destroy (cr);

gtk_widget_path_unref (path);
g_object_unref (provider);
g_object_unref (context);
g_free (css_str);

return retval;
return surface;
}
8 changes: 4 additions & 4 deletions cut-n-paste/libgd/gd-icon-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
GIcon *gd_create_symbolic_icon (const gchar *name,
gint base_size);

GdkPixbuf *gd_embed_image_in_frame (GdkPixbuf *source_image,
const gchar *frame_image_url,
GtkBorder *slice_width,
GtkBorder *border_width);
cairo_surface_t *gd_embed_image_in_frame (cairo_surface_t *source_image,
const gchar *frame_image_url,
GtkBorder *slice_width,
GtkBorder *border_width);

#endif /* __GD_CREATE_SYMBOLIC_ICON_H__ */

0 comments on commit c5177e1

Please sign in to comment.