[gtk+/wip/window-scales2: 22/40] Use gdk_cairo_surface_create_from_pixbuf when possible
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/window-scales2: 22/40] Use gdk_cairo_surface_create_from_pixbuf when possible
- Date: Wed, 3 Jul 2013 12:43:49 +0000 (UTC)
commit 6cc5d2979290987582eb93de530be3cabcf5b22d
Author: Alexander Larsson <alexl redhat com>
Date: Mon Jun 24 12:53:53 2013 +0200
Use gdk_cairo_surface_create_from_pixbuf when possible
gtk/gtkcssimagesurface.c | 10 +---------
gtk/gtkcssstylefuncs.c | 11 ++---------
gtk/gtknumerableicon.c | 12 +-----------
3 files changed, 4 insertions(+), 29 deletions(-)
---
diff --git a/gtk/gtkcssimagesurface.c b/gtk/gtkcssimagesurface.c
index 8f2e612..ac812dd 100644
--- a/gtk/gtkcssimagesurface.c
+++ b/gtk/gtkcssimagesurface.c
@@ -142,20 +142,12 @@ _gtk_css_image_surface_new_for_pixbuf (GdkPixbuf *pixbuf)
{
GtkCssImage *image;
cairo_surface_t *surface;
- cairo_t *cr;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf));
- cr = cairo_create (surface);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
+ surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);
image = _gtk_css_image_surface_new (surface);
-
cairo_surface_destroy (surface);
return image;
diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c
index b6fefca..3a5e10c 100644
--- a/gtk/gtkcssstylefuncs.c
+++ b/gtk/gtkcssstylefuncs.c
@@ -766,7 +766,6 @@ pattern_value_parse (GtkCssParser *parser,
GFile *file;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
- cairo_t *cr;
cairo_matrix_t matrix;
file = _gtk_css_parser_read_url (parser);
@@ -784,21 +783,15 @@ pattern_value_parse (GtkCssParser *parser,
return FALSE;
}
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf));
- cr = cairo_create (surface);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
- cairo_paint (cr);
+ surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);
pattern = cairo_pattern_create_for_surface (surface);
+ cairo_surface_destroy (surface);
cairo_matrix_init_scale (&matrix,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
cairo_pattern_set_matrix (pattern, &matrix);
- cairo_surface_destroy (surface);
- cairo_destroy (cr);
g_object_unref (pixbuf);
g_value_take_boxed (value, pattern);
diff --git a/gtk/gtknumerableicon.c b/gtk/gtknumerableicon.c
index e465471..1d5768f 100644
--- a/gtk/gtknumerableicon.c
+++ b/gtk/gtknumerableicon.c
@@ -196,7 +196,6 @@ draw_from_gicon (GtkNumerableIcon *self)
GtkIconInfo *info;
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
- cairo_t *cr;
if (self->priv->style != NULL)
{
@@ -220,16 +219,7 @@ draw_from_gicon (GtkNumerableIcon *self)
if (pixbuf == NULL)
return NULL;
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf));
-
- cr = cairo_create (surface);
-
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
- cairo_paint (cr);
-
- cairo_destroy (cr);
+ surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);
g_object_unref (pixbuf);
return surface;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]