[gtk+/rendering-cleanup: 7/141] style: Convert draw_vline vfunc to a Cairo version



commit 618858be97ce0ac01f2c30832949abc684513c50
Author: Benjamin Otte <otte redhat com>
Date:   Mon Aug 16 15:40:03 2010 +0200

    style: Convert draw_vline vfunc to a Cairo version

 gtk/gtkstyle.c                       |   65 +++++++++++++++++++++++++---------
 gtk/gtkstyle.h                       |   29 +++++++++------
 modules/engines/pixbuf/pixbuf-draw.c |   12 ++----
 3 files changed, 70 insertions(+), 36 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 720b6f9..14f0cdb 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -109,9 +109,8 @@ static void gtk_default_draw_hline      (GtkStyle        *style,
 					 gint             x2,
 					 gint             y);
 static void gtk_default_draw_vline      (GtkStyle        *style,
-					 GdkWindow       *window,
+					 cairo_t         *cr,
 					 GtkStateType     state_type,
-					 GdkRectangle    *area,
 					 GtkWidget       *widget,
 					 const gchar     *detail,
 					 gint             y1,
@@ -1686,17 +1685,15 @@ gtk_default_draw_hline (GtkStyle      *style,
 
 
 static void
-gtk_default_draw_vline (GtkStyle     *style,
-                        GdkWindow    *window,
+gtk_default_draw_vline (GtkStyle      *style,
+                        cairo_t       *cr,
                         GtkStateType  state_type,
-                        GdkRectangle  *area,
                         GtkWidget     *widget,
                         const gchar   *detail,
                         gint          y1,
                         gint          y2,
                         gint          x)
 {
-  cairo_t *cr;
   gint thickness_light;
   gint thickness_dark;
   gint i;
@@ -1704,15 +1701,8 @@ gtk_default_draw_vline (GtkStyle     *style,
   thickness_light = style->xthickness / 2;
   thickness_dark = style->xthickness - thickness_light;
 
-  cr = gdk_cairo_create (window);
   cairo_set_line_width (cr, 1.0);
 
-  if (area)
-    {
-      gdk_cairo_rectangle (cr, area);
-      cairo_clip (cr);
-    }
-
   for (i = 0; i < thickness_dark; i++)
     { 
       _cairo_draw_line (cr, &style->dark[state_type],
@@ -1729,8 +1719,6 @@ gtk_default_draw_vline (GtkStyle     *style,
       _cairo_draw_line (cr, &style->light[state_type],
                         x + i, y1 + thickness_light - i, x + i, y2);
     }
-
-  cairo_destroy (cr);
 }
 
 static void
@@ -4903,13 +4891,56 @@ gtk_paint_vline (GtkStyle           *style,
                  gint                y2_,
                  gint                x)
 {
+  cairo_t *cr;
+
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
 
-  GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type,
-                                           (GdkRectangle *) area, widget, detail,
+  cr = gtk_style_cairo_create (window, area);
+
+  GTK_STYLE_GET_CLASS (style)->draw_vline (style, cr, state_type,
+                                           widget, detail,
                                            y1_, y2_, x);
+
+  cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_vline:
+ * @style: a #GtkStyle
+ * @cr: a #cairo_t
+ * @state_type: a state
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
+ * @y1_: the starting y coordinate
+ * @y2_: the ending y coordinate
+ * @x: the x coordinate
+ *
+ * Draws a vertical line from (@x, @y1_) to (@x, @y2_) in @cr
+ * using the given style and state.
+ */
+void
+gtk_cairo_paint_vline (GtkStyle           *style,
+                       cairo_t            *cr,
+                       GtkStateType        state_type,
+                       GtkWidget          *widget,
+                       const gchar        *detail,
+                       gint                y1_,
+                       gint                y2_,
+                       gint                x)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (cr != NULL);
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
+
+  cairo_save (cr);
+
+  GTK_STYLE_GET_CLASS (style)->draw_vline (style, cr, state_type,
+                                           widget, detail,
+                                           y1_, y2_, x);
+
+  cairo_restore (cr);
 }
 
 /**
diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h
index 999babd..ff20876 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -174,9 +174,8 @@ struct _GtkStyleClass
 				 gint			 x2,
 				 gint			 y);
   void (*draw_vline)		(GtkStyle		*style,
-				 GdkWindow		*window,
+				 cairo_t                *cr,
 				 GtkStateType		 state_type,
-				 GdkRectangle		*area,
 				 GtkWidget		*widget,
 				 const gchar		*detail,
 				 gint			 y1_,
@@ -470,15 +469,23 @@ void gtk_cairo_paint_hline       (GtkStyle           *style,
                                   gint                x1,
                                   gint                x2,
                                   gint                y);
-void gtk_paint_vline       (GtkStyle           *style,
-			    GdkWindow          *window,
-			    GtkStateType        state_type,
-			    const GdkRectangle *area,
-			    GtkWidget          *widget,
-			    const gchar        *detail,
-			    gint                y1_,
-			    gint                y2_,
-			    gint                x);
+void gtk_paint_vline             (GtkStyle           *style,
+                                  GdkWindow          *window,
+                                  GtkStateType        state_type,
+                                  const GdkRectangle *area,
+                                  GtkWidget          *widget,
+                                  const gchar        *detail,
+                                  gint                y1_,
+                                  gint                y2_,
+                                  gint                x);
+void gtk_cairo_paint_vline       (GtkStyle           *style,
+                                  cairo_t            *cr,
+                                  GtkStateType        state_type,
+                                  GtkWidget          *widget,
+                                  const gchar        *detail,
+                                  gint                y1_,
+                                  gint                y2_,
+                                  gint                x);
 void gtk_paint_shadow      (GtkStyle           *style,
 			    GdkWindow          *window,
 			    GtkStateType        state_type,
diff --git a/modules/engines/pixbuf/pixbuf-draw.c b/modules/engines/pixbuf/pixbuf-draw.c
index 1c1dc39..6393820 100644
--- a/modules/engines/pixbuf/pixbuf-draw.c
+++ b/modules/engines/pixbuf/pixbuf-draw.c
@@ -420,9 +420,8 @@ draw_hline (GtkStyle     *style,
 
 static void
 draw_vline (GtkStyle     *style,
-	    GdkWindow    *window,
+	    cairo_t      *cr,
 	    GtkStateType  state,
-	    GdkRectangle *area,
 	    GtkWidget    *widget,
 	    const gchar  *detail,
 	    gint          y1,
@@ -432,9 +431,6 @@ draw_vline (GtkStyle     *style,
   ThemeImage    *image;
   ThemeMatchData match_data;
   
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (window != NULL);
-
   match_data.function = TOKEN_D_VLINE;
   match_data.detail = (gchar *)detail;
   match_data.flags = THEME_MATCH_ORIENTATION | THEME_MATCH_STATE;
@@ -445,12 +441,12 @@ draw_vline (GtkStyle     *style,
   if (image)
     {
       if (image->background)
-	theme_pixbuf_render_no_cairo (image->background,
-			     window, area, COMPONENT_ALL, FALSE,
+	theme_pixbuf_render (image->background,
+			     cr, COMPONENT_ALL, FALSE,
 			     x, y1, 2, (y2 - y1) + 1);
     }
   else
-    parent_class->draw_vline (style, window, state, area, widget, detail,
+    parent_class->draw_vline (style, cr, state, widget, detail,
 			      y1, y2, x);
 }
 



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