[gtk+/cairo-style: 3/23] pixbuf-engine: Add Cairo version for draw_simple_image()



commit e2b64ebf015202fdba625b7d6dc7b0b5f2655274
Author: Benjamin Otte <otte redhat com>
Date:   Tue Aug 17 04:43:11 2010 +0200

    pixbuf-engine: Add Cairo version for draw_simple_image()

 modules/engines/pixbuf/pixbuf-draw.c |   88 +++++++++++++++++++++++-----------
 1 files changed, 59 insertions(+), 29 deletions(-)
---
diff --git a/modules/engines/pixbuf/pixbuf-draw.c b/modules/engines/pixbuf/pixbuf-draw.c
index 91405e7..6bff6f7 100644
--- a/modules/engines/pixbuf/pixbuf-draw.c
+++ b/modules/engines/pixbuf/pixbuf-draw.c
@@ -97,8 +97,7 @@ match_theme_image (GtkStyle       *style,
 
 static gboolean
 draw_simple_image(GtkStyle       *style,
-		  GdkWindow      *window,
-		  GdkRectangle   *area,
+		  cairo_t        *cr,
 		  GtkWidget      *widget,
 		  ThemeMatchData *match_data,
 		  gboolean        draw_center,
@@ -108,15 +107,9 @@ draw_simple_image(GtkStyle       *style,
 		  gint            width,
 		  gint            height)
 {
+
   ThemeImage *image;
   
-  if ((width == -1) && (height == -1))
-    gdk_drawable_get_size(window, &width, &height);
-  else if (width == -1)
-    gdk_drawable_get_size(window, &width, NULL);
-  else if (height == -1)
-    gdk_drawable_get_size(window, NULL, &height);
-
   if (!(match_data->flags & THEME_MATCH_ORIENTATION))
     {
       match_data->flags |= THEME_MATCH_ORIENTATION;
@@ -132,16 +125,14 @@ draw_simple_image(GtkStyle       *style,
     {
       if (image->background)
 	{
-	  theme_pixbuf_render_no_cairo (image->background,
-			       window, area,
+	  theme_pixbuf_render (image->background, cr,
 			       draw_center ? COMPONENT_ALL : COMPONENT_ALL | COMPONENT_CENTER,
 			       FALSE,
 			       x, y, width, height);
 	}
       
       if (image->overlay && draw_center)
-	theme_pixbuf_render_no_cairo (image->overlay,
-			     window, area, COMPONENT_ALL,
+	theme_pixbuf_render (image->overlay, cr, COMPONENT_ALL,
 			     TRUE, 
 			     x, y, width, height);
 
@@ -152,6 +143,45 @@ draw_simple_image(GtkStyle       *style,
 }
 
 static gboolean
+draw_simple_image_no_cairo(GtkStyle       *style,
+		  GdkWindow      *window,
+		  GdkRectangle   *area,
+		  GtkWidget      *widget,
+		  ThemeMatchData *match_data,
+		  gboolean        draw_center,
+		  gboolean        allow_setbg,
+		  gint            x,
+		  gint            y,
+		  gint            width,
+		  gint            height)
+{
+  gboolean result;
+  cairo_t *cr;
+
+  if ((width == -1) && (height == -1))
+    gdk_drawable_get_size(window, &width, &height);
+  else if (width == -1)
+    gdk_drawable_get_size(window, &width, NULL);
+  else if (height == -1)
+    gdk_drawable_get_size(window, NULL, &height);
+
+  cr = gdk_cairo_create (window);
+  if (area)
+    {
+      gdk_cairo_rectangle (cr, area);
+      cairo_clip (cr);
+    }
+
+  result = draw_simple_image (style, cr, widget, match_data,
+                              draw_center, allow_setbg,
+                              x, y, width, height);
+
+  cairo_destroy (cr);
+
+  return result;
+}
+
+static gboolean
 draw_gap_image(GtkStyle       *style,
 	       GdkWindow      *window,
 	       GdkRectangle   *area,
@@ -419,7 +449,7 @@ draw_shadow(GtkStyle     *style,
   match_data.shadow = shadow;
   match_data.state = state;
 
-  if (!draw_simple_image (style, window, area, widget, &match_data, FALSE, FALSE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, FALSE, FALSE,
 			  x, y, width, height))
     parent_class->draw_shadow (style, window, state, shadow, area, widget, detail,
 			       x, y, width, height);
@@ -519,7 +549,7 @@ draw_arrow (GtkStyle     *style,
       match_data.state = state;
       match_data.arrow_direction = arrow_direction;
       
-      if (draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+      if (draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			     box_x, box_y, box_width, box_height))
 	{
 	  /* The theme included stepper images, we're done */
@@ -534,7 +564,7 @@ draw_arrow (GtkStyle     *style,
       match_data.shadow = shadow;
       match_data.state = state;
       
-      if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+      if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			      box_x, box_y, box_width, box_height))
 	parent_class->draw_box (style, window, state, shadow, area, widget, detail,
 				box_x, box_y, box_width, box_height);
@@ -550,7 +580,7 @@ draw_arrow (GtkStyle     *style,
   match_data.state = state;
   match_data.arrow_direction = arrow_direction;
   
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height))
     parent_class->draw_arrow (style, window, state, shadow, area, widget, detail,
 			      arrow_direction, fill, x, y, width, height);
@@ -580,7 +610,7 @@ draw_diamond (GtkStyle     *style,
   match_data.shadow = shadow;
   match_data.state = state;
   
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height))
     parent_class->draw_diamond (style, window, state, shadow, area, widget, detail,
 				x, y, width, height);
@@ -617,7 +647,7 @@ draw_box (GtkStyle     *style,
   match_data.shadow = shadow;
   match_data.state = state;
 
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height)) {
     parent_class->draw_box (style, window, state, shadow, area, widget, detail,
 			    x, y, width, height);
@@ -648,7 +678,7 @@ draw_flat_box (GtkStyle     *style,
   match_data.shadow = shadow;
   match_data.state = state;
 
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height))
     parent_class->draw_flat_box (style, window, state, shadow, area, widget, detail,
 				 x, y, width, height);
@@ -678,7 +708,7 @@ draw_check (GtkStyle     *style,
   match_data.shadow = shadow;
   match_data.state = state;
   
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height))
     parent_class->draw_check (style, window, state, shadow, area, widget, detail,
 			      x, y, width, height);
@@ -708,7 +738,7 @@ draw_option (GtkStyle      *style,
   match_data.shadow = shadow;
   match_data.state = state;
   
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height))
     parent_class->draw_option (style, window, state, shadow, area, widget, detail,
 			       x, y, width, height);
@@ -738,7 +768,7 @@ draw_tab (GtkStyle     *style,
   match_data.shadow = shadow;
   match_data.state = state;
   
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height))
     parent_class->draw_tab (style, window, state, shadow, area, widget, detail,
 			    x, y, width, height);
@@ -836,7 +866,7 @@ draw_extension (GtkStyle       *style,
   match_data.state = state;
   match_data.gap_side = gap_side;
 
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height))
     parent_class->draw_extension (style, window, state, shadow, area, widget, detail,
 				  x, y, width, height, gap_side);
@@ -863,7 +893,7 @@ draw_focus (GtkStyle     *style,
   match_data.detail = (gchar *)detail;
   match_data.flags = 0;
   
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, FALSE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, FALSE,
 			  x, y, width, height))
     parent_class->draw_focus (style, window, state_type, area, widget, detail,
 			      x, y, width, height);
@@ -897,7 +927,7 @@ draw_slider (GtkStyle      *style,
   match_data.state = state;
   match_data.orientation = orientation;
 
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height))
     parent_class->draw_slider (style, window, state, shadow, area, widget, detail,
 			       x, y, width, height, orientation);
@@ -932,7 +962,7 @@ draw_handle (GtkStyle      *style,
   match_data.state = state;
   match_data.orientation = orientation;
 
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height))
     parent_class->draw_handle (style, window, state, shadow, area, widget, detail,
 			       x, y, width, height, orientation);
@@ -978,7 +1008,7 @@ draw_expander (GtkStyle      *style,
   match_data.state = state;
   match_data.expander_style = expander_style;
 
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x - radius, y - radius, expander_size, expander_size))
     parent_class->draw_expander (style, window, state, area, widget, detail,
 				 x, y, expander_style);
@@ -1009,7 +1039,7 @@ draw_resize_grip (GtkStyle      *style,
   match_data.state = state;
   match_data.window_edge = edge;
 
-  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height))
     parent_class->draw_resize_grip (style, window, state, area, widget, detail,
 				    edge, x, y, width, height);



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