[gtk+] render: Split icon surface rendering out
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] render: Split icon surface rendering out
- Date: Tue, 20 Jan 2015 05:34:50 +0000 (UTC)
commit 8c745088d5376ba399985dad98d82311218ca548
Author: Benjamin Otte <otte redhat com>
Date: Tue Jan 20 05:21:15 2015 +0100
render: Split icon surface rendering out
Just like normal icons, icon surfaces belong into gtkrendericon.c.
gtk/gtkrender.c | 48 +++++++++++---------------------------------
gtk/gtkrendericon.c | 18 ++++++++++++++++
gtk/gtkrendericonprivate.h | 20 +++++++++++------
3 files changed, 43 insertions(+), 43 deletions(-)
---
diff --git a/gtk/gtkrender.c b/gtk/gtkrender.c
index 165c727..caead6f 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 8d8f195..3d3fbb7 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 2fc8c49..f006e97 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]