Commit e08285fc authored by Alexander Larsson's avatar Alexander Larsson
Browse files

gdk: Add scale to gdk_cairo_surface_create_from_pixbuf

This is needed so we can create scaled surfaces as we want to
switch away from using patterns.
parent 0b06e202
......@@ -178,6 +178,7 @@ gdk_cairo_region (cairo_t *cr,
/**
* gdk_cairo_surface_create_from_pixbuf:
* @pixbuf: a #GdkPixbuf
* @scale: the scale of the new surface, or 0 to use same as @window
* @for_window: The window this will be drawn to, on %NULL.
*
* Creates an image surface with the same contents as
......@@ -187,7 +188,8 @@ gdk_cairo_region (cairo_t *cr,
*/
cairo_surface_t *
gdk_cairo_surface_create_from_pixbuf (const GdkPixbuf *pixbuf,
GdkWindow *for_window)
int scale,
GdkWindow *for_window)
{
gint width = gdk_pixbuf_get_width (pixbuf);
gint height = gdk_pixbuf_get_height (pixbuf);
......@@ -209,7 +211,7 @@ gdk_cairo_surface_create_from_pixbuf (const GdkPixbuf *pixbuf,
gdk_window_create_similar_image_surface (for_window,
format,
width, height,
1);
scale);
cairo_stride = cairo_image_surface_get_stride (surface);
cairo_pixels = cairo_image_surface_get_data (surface);
......@@ -295,7 +297,7 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
{
cairo_surface_t *surface;
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, NULL);
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
cairo_surface_destroy (surface);
}
......
......@@ -73,7 +73,8 @@ cairo_surface_t * gdk_cairo_surface_create_similar (cairo_surface_t *surface,
int height);
GDK_AVAILABLE_IN_3_10
cairo_surface_t * gdk_cairo_surface_create_from_pixbuf (const GdkPixbuf *pixbuf,
GdkWindow *for_window);
int scale,
GdkWindow *for_window);
G_END_DECLS
......
......@@ -145,7 +145,7 @@ _gtk_css_image_surface_new_for_pixbuf (GdkPixbuf *pixbuf)
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, NULL);
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);
image = _gtk_css_image_surface_new (surface);
cairo_surface_destroy (surface);
......
......@@ -783,7 +783,7 @@ pattern_value_parse (GtkCssParser *parser,
return FALSE;
}
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, NULL);
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);
pattern = cairo_pattern_create_for_surface (surface);
cairo_surface_destroy (surface);
......
......@@ -819,8 +819,8 @@ _gtk_file_info_render_icon (GFileInfo *info,
icon_size*scale, icon_size*scale,
NULL);
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf,
gtk_widget_get_window (widget));
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1,
gtk_widget_get_window (widget));
g_object_unref (pixbuf);
pattern = cairo_pattern_create_for_surface (surface);
cairo_surface_destroy (surface);
......
......@@ -1615,7 +1615,7 @@ gtk_icon_set_render_icon_pattern (GtkIconSet *icon_set,
pixbuf = gtk_icon_set_render_icon_pixbuf_for_scale (icon_set, context, size, scale);
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, for_window);
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, for_window);
g_object_unref (pixbuf);
pattern = cairo_pattern_create_for_surface (surface);
cairo_surface_destroy (surface);
......
......@@ -588,7 +588,7 @@ ensure_pattern_from_pixbuf (GtkIconHelper *self,
self->priv->rendered_pattern_width = (gdk_pixbuf_get_width (pixbuf) + scale - 1) / scale;
self->priv->rendered_pattern_height = (gdk_pixbuf_get_height (pixbuf) + scale - 1) / scale;
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, self->priv->window);
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, self->priv->window);
g_object_unref (pixbuf);
self->priv->rendered_pattern = cairo_pattern_create_for_surface (surface);
cairo_surface_destroy (surface);
......@@ -685,7 +685,7 @@ ensure_stated_pattern_from_info (GtkIconHelper *self,
pattern = NULL;
if (destination)
{
surface = gdk_cairo_surface_create_from_pixbuf (destination, self->priv->window);
surface = gdk_cairo_surface_create_from_pixbuf (destination, 1, self->priv->window);
pattern = cairo_pattern_create_for_surface (surface);
cairo_matrix_init_scale (&matrix, scale, scale);
cairo_pattern_set_matrix (pattern, &matrix);
......
......@@ -3909,7 +3909,7 @@ gtk_icon_info_load_pattern (GtkIconInfo *icon_info,
if (pixbuf == NULL)
return NULL;
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, for_window);
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, for_window);
g_object_unref (pixbuf);
pattern = cairo_pattern_create_for_surface (surface);
cairo_surface_destroy (surface);
......
......@@ -219,7 +219,7 @@ draw_from_gicon (GtkNumerableIcon *self)
if (pixbuf == NULL)
return NULL;
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, NULL);
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