[gtk+/rendering-cleanup: 21/142] style: Convert draw_resize_grip vfunc to Cairo version



commit c1416507ac83576ba4c340897bcdc40173602ef3
Author: Benjamin Otte <otte redhat com>
Date:   Mon Aug 16 15:13:26 2010 +0200

    style: Convert draw_resize_grip vfunc to Cairo version
    
    Includes removal of now unused draw_simple_image_no_cairo() function
    from pixbuf engine.

 gtk/gtkstyle.c                       |   64 +++++++++++++++++++++++++--------
 gtk/gtkstyle.h                       |   35 +++++++++++-------
 modules/engines/pixbuf/pixbuf-draw.c |   65 ++++++----------------------------
 3 files changed, 82 insertions(+), 82 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index f486173..36cc1d9 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -284,9 +284,8 @@ static void gtk_default_draw_layout     (GtkStyle        *style,
                                          gint             y,
                                          PangoLayout     *layout);
 static void gtk_default_draw_resize_grip (GtkStyle       *style,
-                                          GdkWindow      *window,
+                                          cairo_t        *cr,
                                           GtkStateType    state_type,
-                                          GdkRectangle   *area,
                                           GtkWidget      *widget,
                                           const gchar    *detail,
                                           GdkWindowEdge   edge,
@@ -3976,9 +3975,8 @@ gtk_default_draw_layout (GtkStyle        *style,
 
 static void
 gtk_default_draw_resize_grip (GtkStyle       *style,
-                              GdkWindow      *window,
+                              cairo_t        *cr,
                               GtkStateType    state_type,
-                              GdkRectangle   *area,
                               GtkWidget      *widget,
                               const gchar    *detail,
                               GdkWindowEdge   edge,
@@ -3988,16 +3986,9 @@ gtk_default_draw_resize_grip (GtkStyle       *style,
                               gint            height)
 {
   gint skip;
-  cairo_t *cr;
 
-  cr = gdk_cairo_create (window);
   cairo_rectangle (cr, x, y, width, height);
   cairo_clip (cr);
-  if (area)
-    {
-      gdk_cairo_rectangle (cr, area);
-      cairo_clip (cr);
-    }
 
   cairo_set_line_width (cr, 1.0);
 
@@ -4272,8 +4263,6 @@ gtk_default_draw_resize_grip (GtkStyle       *style,
       g_assert_not_reached ();
       break;
     }
-  
-  cairo_destroy (cr);
 }
 
 static void
@@ -6222,13 +6211,58 @@ gtk_paint_resize_grip (GtkStyle           *style,
                        gint                height)
 
 {
+  cairo_t *cr;
+
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
 
-  GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
-                                                 (GdkRectangle *) area, widget, detail,
+  cr = gtk_style_cairo_create (window, area);
+
+  GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, cr, state_type,
+                                                 widget, detail,
                                                  edge, x, y, width, height);
+  cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_resize_grip:
+ * @style: a #GtkStyle
+ * @cr: a #cairo_t
+ * @state_type: a state
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
+ * @edge: the edge in which to draw the resize grip
+ * @x: the x origin of the rectangle in which to draw the resize grip
+ * @y: the y origin of the rectangle in which to draw the resize grip
+ * @width: the width of the rectangle in which to draw the resize grip
+ * @height: the height of the rectangle in which to draw the resize grip
+ *
+ * Draws a resize grip in the given rectangle on @cr using the given
+ * parameters. 
+ */
+void
+gtk_cairo_paint_resize_grip (GtkStyle           *style,
+                             cairo_t            *cr,
+                             GtkStateType        state_type,
+                             GtkWidget          *widget,
+                             const gchar        *detail,
+                             GdkWindowEdge       edge,
+                             gint                x,
+                             gint                y,
+                             gint                width,
+                             gint                height)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
+  g_return_if_fail (cr != NULL);
+
+  cairo_save (cr);
+
+  GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, cr, state_type,
+                                                 widget, detail,
+                                                 edge, x, y, width, height);
+  cairo_restore (cr);
 }
 
 /**
diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h
index 44a0bf0..c7c0fea 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -350,9 +350,8 @@ struct _GtkStyleClass
 				 gint			 y,
                                  PangoLayout            *layout);
   void (*draw_resize_grip)      (GtkStyle		*style,
-				 GdkWindow		*window,
+                                 cairo_t                *cr,
 				 GtkStateType		 state_type,
-				 GdkRectangle		*area,
 				 GtkWidget		*widget,
 				 const gchar		*detail,
                                  GdkWindowEdge           edge,
@@ -820,17 +819,27 @@ void gtk_cairo_paint_layout      (GtkStyle           *style,
                                   gint                x,
                                   gint                y,
                                   PangoLayout        *layout);
-void gtk_paint_resize_grip (GtkStyle           *style,
-                            GdkWindow          *window,
-                            GtkStateType        state_type,
-                            const GdkRectangle *area,
-                            GtkWidget          *widget,
-                            const gchar        *detail,
-                            GdkWindowEdge       edge,
-                            gint                x,
-                            gint                y,
-                            gint                width,
-                            gint                height);
+void gtk_paint_resize_grip       (GtkStyle           *style,
+                                  GdkWindow          *window,
+                                  GtkStateType        state_type,
+                                  const GdkRectangle *area,
+                                  GtkWidget          *widget,
+                                  const gchar        *detail,
+                                  GdkWindowEdge       edge,
+                                  gint                x,
+                                  gint                y,
+                                  gint                width,
+                                  gint                height);
+void gtk_cairo_paint_resize_grip (GtkStyle           *style,
+                                  cairo_t            *cr,
+                                  GtkStateType        state_type,
+                                  GtkWidget          *widget,
+                                  const gchar        *detail,
+                                  GdkWindowEdge       edge,
+                                  gint                x,
+                                  gint                y,
+                                  gint                width,
+                                  gint                height);
 void gtk_paint_spinner     (GtkStyle           *style,
 			    GdkWindow          *window,
 			    GtkStateType        state_type,
diff --git a/modules/engines/pixbuf/pixbuf-draw.c b/modules/engines/pixbuf/pixbuf-draw.c
index d74f5e3..c166360 100644
--- a/modules/engines/pixbuf/pixbuf-draw.c
+++ b/modules/engines/pixbuf/pixbuf-draw.c
@@ -143,45 +143,6 @@ 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,
                cairo_t        *cr,
 	       GtkWidget      *widget,
@@ -946,22 +907,18 @@ draw_expander (GtkStyle      *style,
 
 static void
 draw_resize_grip (GtkStyle      *style,
-		     GdkWindow     *window,
-		     GtkStateType   state,
-		     GdkRectangle  *area,
-		     GtkWidget     *widget,
-		     const gchar   *detail,
-		     GdkWindowEdge  edge,
-		     gint           x,
-		     gint           y,
-		     gint           width,
-		     gint           height)
+		  cairo_t       *cr,
+                  GtkStateType   state,
+                  GtkWidget     *widget,
+                  const gchar   *detail,
+                  GdkWindowEdge  edge,
+                  gint           x,
+                  gint           y,
+                  gint           width,
+		  gint           height)
 {
   ThemeMatchData match_data;
   
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (window != NULL);
-
   match_data.function = TOKEN_D_RESIZE_GRIP;
   match_data.detail = (gchar *)detail;
   match_data.flags = (THEME_MATCH_STATE | 
@@ -969,9 +926,9 @@ draw_resize_grip (GtkStyle      *style,
   match_data.state = state;
   match_data.window_edge = edge;
 
-  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_resize_grip (style, window, state, area, widget, detail,
+    parent_class->draw_resize_grip (style, cr, state, widget, detail,
 				    edge, x, y, width, height);
 }
 



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