Commit 6cc5d297 authored by Alexander Larsson's avatar Alexander Larsson

Use gdk_cairo_surface_create_from_pixbuf when possible

parent ae43f9fa
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment