[gtk+/rendering-cleanup: 32/92] treeview: Port to gdk_window_shape_combine_region()



commit 8c2716c43410886518bc3f0e3ba186783784e909
Author: Benjamin Otte <otte redhat com>
Date:   Sat Aug 14 05:37:24 2010 +0200

    treeview: Port to gdk_window_shape_combine_region()
    
    gdk_window_shape_combine_mask() is going away. It's using a GdkPixmap
    and falls back to gdk_window_shape_combine_region() anyway.

 gtk/gtktreeview.c |   57 +++++++++++++++++++++++++++-------------------------
 1 files changed, 30 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 7bbb4e4..96f7da3 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -3381,7 +3381,8 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
 {
   GtkTreeViewColumnReorder *reorder = tree_view->priv->cur_reorder;
   GtkWidget *widget = GTK_WIDGET (tree_view);
-  GdkBitmap *mask = NULL;
+  cairo_surface_t *mask_image;
+  cairo_region_t *mask_region;
   gint x;
   gint y;
   gint width;
@@ -3437,19 +3438,21 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
 	  tree_view->priv->drag_highlight_window = gdk_window_new (tree_view->priv->header_window, &attributes, attributes_mask);
 	  gdk_window_set_user_data (tree_view->priv->drag_highlight_window, GTK_WIDGET (tree_view));
 
-	  mask = gdk_pixmap_new (tree_view->priv->drag_highlight_window, width, height, 1);
-          cr = gdk_cairo_create (mask);
+	  mask_image = cairo_image_surface_create (CAIRO_FORMAT_A1, width, height);
+          cr = cairo_create (mask_image);
 
-          cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
-          cairo_paint (cr);
-          cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
           cairo_rectangle (cr, 1, 1, width - 2, height - 2);
           cairo_stroke (cr);
           cairo_destroy (cr);
 
-	  gdk_window_shape_combine_mask (tree_view->priv->drag_highlight_window,
-					 mask, 0, 0);
-	  if (mask) g_object_unref (mask);
+          cairo_surface_write_to_png (mask_image, "foo.png");
+          mask_region = gdk_cairo_region_create_from_surface (mask_image);
+	  gdk_window_shape_combine_region (tree_view->priv->drag_highlight_window,
+					   mask_region, 0, 0);
+
+          cairo_region_destroy (mask_region);
+          cairo_surface_destroy (mask_image);
+
 	  tree_view->priv->drag_column_window_state = DRAG_COLUMN_WINDOW_STATE_ORIGINAL;
 	}
     }
@@ -3496,12 +3499,9 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
 								   &attributes, attributes_mask);
 	  gdk_window_set_user_data (tree_view->priv->drag_highlight_window, GTK_WIDGET (tree_view));
 
-	  mask = gdk_pixmap_new (tree_view->priv->drag_highlight_window, width, height, 1);
-          cr = gdk_cairo_create (mask);
+	  mask_image = cairo_image_surface_create (CAIRO_FORMAT_A1, width, height);
 
-          cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
-          cairo_paint (cr);
-          cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+          cr = cairo_create (mask_image);
           cairo_move_to (cr, 0, 0);
           cairo_line_to (cr, width, 0);
           cairo_line_to (cr, width / 2., width / 2);
@@ -3509,11 +3509,14 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
           cairo_line_to (cr, width, height);
           cairo_line_to (cr, width / 2., height - width / 2.);
           cairo_fill (cr);
-
           cairo_destroy (cr);
-	  gdk_window_shape_combine_mask (tree_view->priv->drag_highlight_window,
-					 mask, 0, 0);
-	  if (mask) g_object_unref (mask);
+
+          mask_region = gdk_cairo_region_create_from_surface (mask_image);
+	  gdk_window_shape_combine_region (tree_view->priv->drag_highlight_window,
+					   mask_region, 0, 0);
+
+          cairo_region_destroy (mask_region);
+          cairo_surface_destroy (mask_image);
 	}
 
       tree_view->priv->drag_column_window_state = DRAG_COLUMN_WINDOW_STATE_ARROW;
@@ -3562,12 +3565,9 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
 	  tree_view->priv->drag_highlight_window = gdk_window_new (NULL, &attributes, attributes_mask);
 	  gdk_window_set_user_data (tree_view->priv->drag_highlight_window, GTK_WIDGET (tree_view));
 
-	  mask = gdk_pixmap_new (tree_view->priv->drag_highlight_window, width, height, 1);
-          cr = gdk_cairo_create (mask);
+	  mask_image = cairo_image_surface_create (CAIRO_FORMAT_A1, width, height);
 
-          cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
-          cairo_paint (cr);
-          cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+          cr = cairo_create (mask_image);
           /* mirror if we're on the left */
           if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT)
             {
@@ -3581,11 +3581,14 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
           cairo_line_to (cr, width, height - width);
           cairo_line_to (cr, 0, height - tree_view->priv->expander_size);
           cairo_fill (cr);
-
           cairo_destroy (cr);
-	  gdk_window_shape_combine_mask (tree_view->priv->drag_highlight_window,
-					 mask, 0, 0);
-	  if (mask) g_object_unref (mask);
+
+          mask_region = gdk_cairo_region_create_from_surface (mask_image);
+	  gdk_window_shape_combine_region (tree_view->priv->drag_highlight_window,
+					   mask_region, 0, 0);
+
+          cairo_region_destroy (mask_region);
+          cairo_surface_destroy (mask_image);
 	}
 
       tree_view->priv->drag_column_window_state = arrow_type;



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