[gtk+/rendering-cleanup: 15/144] style: Convert draw_extension vfunc to Cairo version



commit 023778c1c1176d205391d63c296a269ffc52929c
Author: Benjamin Otte <otte redhat com>
Date:   Mon Aug 16 22:19:56 2010 +0200

    style: Convert draw_extension vfunc to Cairo version

 gtk/gtkstyle.c                       |   76 +++++++++++++++++++++++++--------
 gtk/gtkstyle.h                       |   38 +++++++++++------
 modules/engines/pixbuf/pixbuf-draw.c |   10 +---
 3 files changed, 84 insertions(+), 40 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 1142419..375b17f 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -225,10 +225,9 @@ static void gtk_default_draw_box_gap    (GtkStyle        *style,
 					 gint             gap_x,
 					 gint             gap_width);
 static void gtk_default_draw_extension  (GtkStyle        *style,
-					 GdkWindow       *window,
+					 cairo_t         *cr,
 					 GtkStateType     state_type,
 					 GtkShadowType    shadow_type,
-					 GdkRectangle    *area,
 					 GtkWidget       *widget,
 					 const gchar     *detail,
 					 gint             x,
@@ -3440,10 +3439,9 @@ gtk_default_draw_box_gap (GtkStyle       *style,
 
 static void 
 gtk_default_draw_extension (GtkStyle       *style,
-                            GdkWindow      *window,
+                            cairo_t        *cr,
                             GtkStateType    state_type,
                             GtkShadowType   shadow_type,
-                            GdkRectangle   *area,
                             GtkWidget      *widget,
                             const gchar    *detail,
                             gint            x,
@@ -3452,21 +3450,12 @@ gtk_default_draw_extension (GtkStyle       *style,
                             gint            height,
                             GtkPositionType gap_side)
 {
-  cairo_t *cr;
+  GdkWindow *window = gtk_widget_get_window (widget);
   GdkColor color1;
   GdkColor color2;
   GdkColor color3;
   GdkColor color4;
   
-  sanitize_size (window, &width, &height);
-
-  cr = gdk_cairo_create (window);
-  if (area)
-    {
-      gdk_cairo_rectangle (cr, area);
-      cairo_clip (cr);
-    }
-  
   switch (gap_side)
     {
     case GTK_POS_TOP:
@@ -3506,7 +3495,6 @@ gtk_default_draw_extension (GtkStyle       *style,
   switch (shadow_type)
     {
     case GTK_SHADOW_NONE:
-      cairo_destroy (cr);
       return;
     case GTK_SHADOW_IN:
       color1 = style->dark[state_type];
@@ -3607,8 +3595,6 @@ gtk_default_draw_extension (GtkStyle       *style,
           break;
         }
     }
-
-  cairo_destroy (cr);
 }
 
 static void 
@@ -5747,13 +5733,65 @@ gtk_paint_extension (GtkStyle           *style,
                      gint                height,
                      GtkPositionType     gap_side)
 {
+  cairo_t *cr;
+
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
 
-  GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type,
-                                               (GdkRectangle *) area, widget, detail,
+  sanitize_size (window, &width, &height);
+
+  cr = gtk_style_cairo_create (window, area);
+
+  gtk_cairo_paint_extension (style, cr, state_type, shadow_type,
+                             widget, detail,
+                             x, y, width, height, gap_side);
+
+  cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_extension: 
+ * @style: a #GtkStyle
+ * @cr: a #cairo_t
+ * @state_type: a state
+ * @shadow_type: type of shadow to draw
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
+ * @x: x origin of the extension
+ * @y: y origin of the extension
+ * @width: width of the extension
+ * @height: width of the extension
+ * @gap_side: the side on to which the extension is attached
+ * 
+ * Draws an extension, i.e. a notebook tab.
+ **/
+void
+gtk_cairo_paint_extension (GtkStyle           *style,
+                           cairo_t            *cr,
+                           GtkStateType        state_type,
+                           GtkShadowType       shadow_type,
+                           GtkWidget          *widget,
+                           const gchar        *detail,
+                           gint                x,
+                           gint                y,
+                           gint                width,
+                           gint                height,
+                           GtkPositionType     gap_side)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
+  g_return_if_fail (cr != NULL);
+  g_return_if_fail (width >= 0);
+  g_return_if_fail (height >= 0);
+
+  cairo_save (cr);
+
+  GTK_STYLE_GET_CLASS (style)->draw_extension (style, cr, state_type, shadow_type,
+                                               widget, detail,
                                                x, y, width, height, gap_side);
+
+  cairo_restore (cr);
 }
 
 /**
diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h
index dcc5cd3..c6268b7 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -290,10 +290,9 @@ struct _GtkStyleClass
 				 gint			 gap_x,
 				 gint			 gap_width);
   void (*draw_extension)	(GtkStyle		*style,
-				 GdkWindow		*window,
+				 cairo_t                *cr,
 				 GtkStateType		 state_type,
 				 GtkShadowType		 shadow_type,
-				 GdkRectangle		*area,
 				 GtkWidget		*widget,
 				 const gchar		*detail,
 				 gint			 x,
@@ -702,18 +701,29 @@ void gtk_cairo_paint_box_gap     (GtkStyle           *style,
                                   GtkPositionType     gap_side,
                                   gint                gap_x,
                                   gint                gap_width);
-void gtk_paint_extension   (GtkStyle           *style,
-			    GdkWindow          *window,
-			    GtkStateType        state_type,
-			    GtkShadowType       shadow_type,
-			    const GdkRectangle *area,
-			    GtkWidget          *widget,
-			    const gchar        *detail,
-			    gint                x,
-			    gint                y,
-			    gint                width,
-			    gint                height,
-			    GtkPositionType     gap_side);
+void gtk_paint_extension         (GtkStyle           *style,
+                                  GdkWindow          *window,
+                                  GtkStateType        state_type,
+                                  GtkShadowType       shadow_type,
+                                  const GdkRectangle *area,
+                                  GtkWidget          *widget,
+                                  const gchar        *detail,
+                                  gint                x,
+                                  gint                y,
+                                  gint                width,
+                                  gint                height,
+                                  GtkPositionType     gap_side);
+void gtk_cairo_paint_extension   (GtkStyle           *style,
+                                  cairo_t            *cr,
+                                  GtkStateType        state_type,
+                                  GtkShadowType       shadow_type,
+                                  GtkWidget          *widget,
+                                  const gchar        *detail,
+                                  gint                x,
+                                  gint                y,
+                                  gint                width,
+                                  gint                height,
+                                  GtkPositionType     gap_side);
 void gtk_paint_focus       (GtkStyle           *style,
 			    GdkWindow          *window,
 			    GtkStateType        state_type,
diff --git a/modules/engines/pixbuf/pixbuf-draw.c b/modules/engines/pixbuf/pixbuf-draw.c
index d3f1c9c..b371986 100644
--- a/modules/engines/pixbuf/pixbuf-draw.c
+++ b/modules/engines/pixbuf/pixbuf-draw.c
@@ -790,10 +790,9 @@ draw_box_gap (GtkStyle       *style,
 
 static void
 draw_extension (GtkStyle       *style,
-		GdkWindow      *window,
+		cairo_t        *cr,
 		GtkStateType    state,
 		GtkShadowType   shadow,
-		GdkRectangle   *area,
 		GtkWidget      *widget,
 		const gchar    *detail,
 		gint            x,
@@ -804,9 +803,6 @@ draw_extension (GtkStyle       *style,
 {
   ThemeMatchData match_data;
   
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (window != NULL);
-
   match_data.function = TOKEN_D_EXTENSION;
   match_data.detail = (gchar *)detail;
   match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE | THEME_MATCH_GAP_SIDE;
@@ -814,9 +810,9 @@ draw_extension (GtkStyle       *style,
   match_data.state = state;
   match_data.gap_side = gap_side;
 
-  if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
+  if (!draw_simple_image (style, cr, widget, &match_data, TRUE, TRUE,
 			  x, y, width, height))
-    parent_class->draw_extension (style, window, state, shadow, area, widget, detail,
+    parent_class->draw_extension (style, cr, state, shadow, widget, detail,
 				  x, y, width, height, gap_side);
 }
 



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