]> Pileus Git - ~andy/gtk/commitdiff
pixbuf-engine: Make theme_pixbuf_render take a cairo_t
authorBenjamin Otte <otte@redhat.com>
Tue, 17 Aug 2010 02:37:03 +0000 (04:37 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 26 Sep 2010 13:02:57 +0000 (15:02 +0200)
This is in preparation for the theme engine switch to Cairo. We keep the
old function around so that we can step-by-step upgrade all the vfuncs.

modules/engines/pixbuf/pixbuf-draw.c
modules/engines/pixbuf/pixbuf-render.c
modules/engines/pixbuf/pixbuf.h

index f80a4d757ac152880553c45263f2a89e38a7ec0a..6c940ae40933a8be46d53c4335a353ed91d58c96 100644 (file)
@@ -130,7 +130,7 @@ draw_simple_image(GtkStyle       *style,
     {
       if (image->background)
        {
-         theme_pixbuf_render (image->background,
+         theme_pixbuf_render_no_cairo (image->background,
                               window, area,
                               draw_center ? COMPONENT_ALL : COMPONENT_ALL | COMPONENT_CENTER,
                               FALSE,
@@ -138,7 +138,7 @@ draw_simple_image(GtkStyle       *style,
        }
       
       if (image->overlay && draw_center)
-       theme_pixbuf_render (image->overlay,
+       theme_pixbuf_render_no_cairo (image->overlay,
                             window, area, COMPONENT_ALL,
                             TRUE, 
                             x, y, width, height);
@@ -299,19 +299,19 @@ draw_gap_image(GtkStyle       *style,
        }
 
       if (image->background)
-       theme_pixbuf_render (image->background,
+       theme_pixbuf_render_no_cairo (image->background,
                             window, area, components, FALSE,
                             x, y, width, height);
       if (image->gap_start)
-       theme_pixbuf_render (image->gap_start,
+       theme_pixbuf_render_no_cairo (image->gap_start,
                             window, area, COMPONENT_ALL, FALSE,
                             r1.x, r1.y, r1.width, r1.height);
       if (image->gap)
-       theme_pixbuf_render (image->gap,
+       theme_pixbuf_render_no_cairo (image->gap,
                             window, area, COMPONENT_ALL, FALSE,
                             r2.x, r2.y, r2.width, r2.height);
       if (image->gap_end)
-       theme_pixbuf_render (image->gap_end,
+       theme_pixbuf_render_no_cairo (image->gap_end,
                             window, area, COMPONENT_ALL, FALSE,
                             r3.x, r3.y, r3.width, r3.height);
 
@@ -348,7 +348,7 @@ draw_hline (GtkStyle     *style,
   if (image)
     {
       if (image->background)
-       theme_pixbuf_render (image->background,
+       theme_pixbuf_render_no_cairo (image->background,
                             window, area, COMPONENT_ALL, FALSE,
                             x1, y, (x2 - x1) + 1, 2);
     }
@@ -384,7 +384,7 @@ draw_vline (GtkStyle     *style,
   if (image)
     {
       if (image->background)
-       theme_pixbuf_render (image->background,
+       theme_pixbuf_render_no_cairo (image->background,
                             window, area, COMPONENT_ALL, FALSE,
                             x, y1, 2, (y2 - y1) + 1);
     }
index ce25cfbb78cc8a7de31c953fc3154582093ad610..30e3fadad12e0381fc1102530f52474ef99628a8 100644 (file)
@@ -352,8 +352,7 @@ replicate_cols (GdkPixbuf    *src,
 static void
 pixbuf_render (GdkPixbuf    *src,
               guint         hints,
-              GdkWindow    *window,
-              GdkRectangle *clip_rect,
+               cairo_t      *cr,
               gint          src_x,
               gint          src_y,
               gint          src_width,
@@ -381,12 +380,6 @@ pixbuf_render (GdkPixbuf    *src,
   if (hints & THEME_MISSING)
     return;
 
-  if (clip_rect)
-    {
-      if (!gdk_rectangle_intersect (clip_rect, &rect, &rect))
-       return;
-    }
-
   if (dest_width == src_width && dest_height == src_height)
     {
       tmp_pixbuf = g_object_ref (src);
@@ -471,9 +464,6 @@ pixbuf_render (GdkPixbuf    *src,
 
   if (tmp_pixbuf)
     {
-      cairo_t *cr;
-      
-      cr = gdk_cairo_create (window);
       gdk_cairo_set_source_pixbuf (cr, 
                                    tmp_pixbuf,
                                    -x_offset + rect.x, 
@@ -481,7 +471,6 @@ pixbuf_render (GdkPixbuf    *src,
       gdk_cairo_rectangle (cr, &rect);
       cairo_fill (cr);
 
-      cairo_destroy (cr);
       g_object_unref (tmp_pixbuf);
     }
 }
@@ -726,10 +715,34 @@ theme_pixbuf_get_pixbuf (ThemePixbuf *theme_pb)
   return theme_pb->pixbuf;
 }
 
+void
+theme_pixbuf_render_no_cairo (ThemePixbuf  *theme_pb,
+                              GdkWindow    *window,
+                              GdkRectangle *clip_rect,
+                              guint         component_mask,
+                              gboolean      center,
+                              gint          x,
+                              gint          y,
+                              gint          width,
+                              gint          height)
+{
+  cairo_t *cr;
+
+  cr = gdk_cairo_create (window);
+  if (clip_rect)
+    {
+      gdk_cairo_rectangle (cr, clip_rect);
+      cairo_clip (cr);
+    }
+
+  theme_pixbuf_render (theme_pb, cr, 
+                       component_mask, center,
+                       x, y, width, height);
+}
+
 void
 theme_pixbuf_render (ThemePixbuf  *theme_pb,
-                    GdkWindow    *window,
-                    GdkRectangle *clip_rect,
+                     cairo_t      *cr,
                     guint         component_mask,
                     gboolean      center,
                     gint          x,
@@ -785,7 +798,7 @@ theme_pixbuf_render (ThemePixbuf  *theme_pb,
 
 
 #define RENDER_COMPONENT(X1,X2,Y1,Y2)                                     \
-        pixbuf_render (pixbuf, theme_pb->hints[Y1][X1], window, clip_rect, \
+        pixbuf_render (pixbuf, theme_pb->hints[Y1][X1], cr,                \
                       src_x[X1], src_y[Y1],                               \
                       src_x[X2] - src_x[X1], src_y[Y2] - src_y[Y1],       \
                       dest_x[X1], dest_y[Y1],                             \
@@ -825,7 +838,7 @@ theme_pixbuf_render (ThemePixbuf  *theme_pb,
          x += (width - pixbuf_width) / 2;
          y += (height - pixbuf_height) / 2;
          
-         pixbuf_render (pixbuf, 0, window, clip_rect,
+         pixbuf_render (pixbuf, 0, cr,
                         0, 0,
                         pixbuf_width, pixbuf_height,
                         x, y,
@@ -833,19 +846,12 @@ theme_pixbuf_render (ThemePixbuf  *theme_pb,
        }
       else
        {
-          cairo_t *cr = gdk_cairo_create (window);
-
           gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
           cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
 
-         if (clip_rect)
-           gdk_cairo_rectangle (cr, clip_rect);
-         else
-           cairo_rectangle (cr, x, y, width, height);
+         cairo_rectangle (cr, x, y, width, height);
          
           cairo_fill (cr);
-
-          cairo_destroy (cr);
        }
     }
 }
index 2354d76cc39cb3bd1a380fee472b53e3b99a9313..9c9c38c5d432b287214adcd2b9ffc7be93d1570e 100644 (file)
@@ -200,7 +200,7 @@ G_GNUC_INTERNAL void         theme_pixbuf_set_border   (ThemePixbuf  *theme_pb,
                                        gint          bottom);
 G_GNUC_INTERNAL void         theme_pixbuf_set_stretch  (ThemePixbuf  *theme_pb,
                                        gboolean      stretch);
-G_GNUC_INTERNAL void         theme_pixbuf_render       (ThemePixbuf  *theme_pb,
+G_GNUC_INTERNAL void         theme_pixbuf_render_no_cairo (ThemePixbuf  *theme_pb,
                                        GdkWindow    *window,
                                        GdkRectangle *clip_rect,
                                        guint         component_mask,
@@ -209,6 +209,14 @@ G_GNUC_INTERNAL void         theme_pixbuf_render       (ThemePixbuf  *theme_pb,
                                        gint          dest_y,
                                        gint          dest_width,
                                        gint          dest_height);
+G_GNUC_INTERNAL void         theme_pixbuf_render       (ThemePixbuf  *theme_pb,
+                                        cairo_t      *cr,
+                                       guint         component_mask,
+                                       gboolean      center,
+                                       gint          dest_x,
+                                       gint          dest_y,
+                                       gint          dest_width,
+                                       gint          dest_height);