[gtk+/wip/window-scales] gdk: Add scale to gdk_cairo_surface_create_from_pixbuf



commit e08285fc788f38d7ae6d224e242a2c7d3c946df6
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Jul 2 16:44:01 2013 +0200

    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.

 gdk/gdkcairo.c           |    8 +++++---
 gdk/gdkcairo.h           |    3 ++-
 gtk/gtkcssimagesurface.c |    2 +-
 gtk/gtkcssstylefuncs.c   |    2 +-
 gtk/gtkfilesystem.c      |    4 ++--
 gtk/gtkiconfactory.c     |    2 +-
 gtk/gtkiconhelper.c      |    4 ++--
 gtk/gtkicontheme.c       |    2 +-
 gtk/gtknumerableicon.c   |    2 +-
 9 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c
index 33fb565..74bc636 100644
--- a/gdk/gdkcairo.c
+++ b/gdk/gdkcairo.c
@@ -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);
 }
diff --git a/gdk/gdkcairo.h b/gdk/gdkcairo.h
index fdee4e8..82548c1 100644
--- a/gdk/gdkcairo.h
+++ b/gdk/gdkcairo.h
@@ -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
 
diff --git a/gtk/gtkcssimagesurface.c b/gtk/gtkcssimagesurface.c
index 2de8a23..ac812dd 100644
--- a/gtk/gtkcssimagesurface.c
+++ b/gtk/gtkcssimagesurface.c
@@ -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);
diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c
index c84339c..3a5e10c 100644
--- a/gtk/gtkcssstylefuncs.c
+++ b/gtk/gtkcssstylefuncs.c
@@ -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);
 
diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c
index 96ffb99..1e4308b 100644
--- a/gtk/gtkfilesystem.c
+++ b/gtk/gtkfilesystem.c
@@ -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);
diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c
index 837e644..7fcb777 100644
--- a/gtk/gtkiconfactory.c
+++ b/gtk/gtkiconfactory.c
@@ -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);
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index cb12b18..99af81d 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -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);
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index b23d350..ffcbd57 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -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);
diff --git a/gtk/gtknumerableicon.c b/gtk/gtknumerableicon.c
index 44cbbea..1d5768f 100644
--- a/gtk/gtknumerableicon.c
+++ b/gtk/gtknumerableicon.c
@@ -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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]