diff --git a/gtk/gtkrender.c b/gtk/gtkrender.c index 165c727254..caead6faac 100644 --- a/gtk/gtkrender.c +++ b/gtk/gtkrender.c @@ -1193,24 +1193,6 @@ gtk_render_icon_pixbuf (GtkStyleContext *context, return gtk_do_render_icon_pixbuf (context, source, size); } -static void -gtk_do_render_icon (GtkStyleContext *context, - cairo_t *cr, - GdkPixbuf *pixbuf, - gdouble x, - gdouble y) -{ - cairo_save (cr); - - gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y); - - _gtk_css_shadows_value_paint_icon (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SHADOW), cr); - - cairo_paint (cr); - - cairo_restore (cr); -} - /** * gtk_render_icon: * @context: a #GtkStyleContext @@ -1230,31 +1212,22 @@ gtk_render_icon (GtkStyleContext *context, gdouble x, gdouble y) { + cairo_surface_t *surface; + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); cairo_save (cr); cairo_new_path (cr); - gtk_do_render_icon (context, cr, pixbuf, x, y); + surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL); - cairo_restore (cr); -} + gtk_css_style_render_icon_surface (gtk_style_context_lookup_style (context), + cr, + surface, + x, y); -static void -gtk_do_render_icon_surface (GtkStyleContext *context, - cairo_t *cr, - cairo_surface_t *surface, - gdouble x, - gdouble y) -{ - cairo_save (cr); - - cairo_set_source_surface (cr, surface, x, y); - - _gtk_css_shadows_value_paint_icon (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SHADOW), cr); - - cairo_paint (cr); + cairo_surface_destroy (surface); cairo_restore (cr); } @@ -1284,7 +1257,10 @@ gtk_render_icon_surface (GtkStyleContext *context, cairo_save (cr); cairo_new_path (cr); - gtk_do_render_icon_surface (context, cr, surface, x, y); + gtk_css_style_render_icon_surface (gtk_style_context_lookup_style (context), + cr, + surface, + x, y); cairo_restore (cr); } diff --git a/gtk/gtkrendericon.c b/gtk/gtkrendericon.c index 8d8f19502e..3d3fbb754a 100644 --- a/gtk/gtkrendericon.c +++ b/gtk/gtkrendericon.c @@ -74,3 +74,21 @@ gtk_css_style_render_icon (GtkCssStyle *style, } } +void +gtk_css_style_render_icon_surface (GtkCssStyle *style, + cairo_t *cr, + cairo_surface_t *surface, + double x, + double y) +{ + g_return_if_fail (GTK_IS_CSS_STYLE (style)); + g_return_if_fail (cr != NULL); + g_return_if_fail (surface != NULL); + + cairo_set_source_surface (cr, surface, x, y); + + _gtk_css_shadows_value_paint_icon (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_SHADOW), cr); + + cairo_paint (cr); +} + diff --git a/gtk/gtkrendericonprivate.h b/gtk/gtkrendericonprivate.h index 2fc8c49857..f006e97105 100644 --- a/gtk/gtkrendericonprivate.h +++ b/gtk/gtkrendericonprivate.h @@ -29,13 +29,19 @@ G_BEGIN_DECLS -void gtk_css_style_render_icon (GtkCssStyle *style, - cairo_t *cr, - double x, - double y, - double width, - double height, - GtkCssImageBuiltinType builtin_type); +void gtk_css_style_render_icon (GtkCssStyle *style, + cairo_t *cr, + double x, + double y, + double width, + double height, + GtkCssImageBuiltinType builtin_type); + +void gtk_css_style_render_icon_surface (GtkCssStyle *style, + cairo_t *cr, + cairo_surface_t *surface, + double x, + double y); G_END_DECLS