[gtk+/wip/simple-draw3] GtkTreeView: Invalidate pixel cache on queue_draw



commit 16623aabd1333c57811550c03177ff401c50f150
Author: Alexander Larsson <alexl redhat com>
Date:   Thu May 2 11:12:50 2013 +0200

    GtkTreeView: Invalidate pixel cache on queue_draw
    
    Whenever queue_draw is called on the treeview we invalidate the
    whole pixel cache, as there is no way we can know when the area
    outside the visible region should be updated from the region
    (as it is in widget coords).
    
    This is not typically a problem though, we only queue redraws
    on the treeview itself on e.g. resizes or restyles, which are
    generally rare.

 gtk/gtktreeview.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 0389b0a..2d31ed2 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -797,6 +797,8 @@ static void     gtk_tree_view_stop_rubber_band               (GtkTreeView
 static void     update_prelight                              (GtkTreeView        *tree_view,
                                                               int                 x,
                                                               int                 y);
+static void     gtk_tree_view_queue_draw_region              (GtkWidget          *widget,
+                                                             const cairo_region_t *region);
 
 static inline gint gtk_tree_view_get_effective_header_height (GtkTreeView *tree_view);
 
@@ -963,6 +965,7 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
   widget_class->style_updated = gtk_tree_view_style_updated;
   widget_class->grab_notify = gtk_tree_view_grab_notify;
   widget_class->state_flags_changed = gtk_tree_view_state_flags_changed;
+  widget_class->queue_draw_region = gtk_tree_view_queue_draw_region;
 
   /* GtkContainer signals */
   container_class->remove = gtk_tree_view_remove;
@@ -2246,6 +2249,23 @@ gtk_tree_view_bin_window_invalidate_handler (GdkWindow *window,
 }
 
 static void
+gtk_tree_view_queue_draw_region (GtkWidget *widget,
+                                const cairo_region_t *region)
+{
+  GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
+
+  /* There is no way we can know if a region targets the
+     not-currently-visible but in pixel cache region, so we
+     always just invalidate the whole thing whenever the
+     tree view gets a queue draw. This doesn't normally happen
+     in normal scrolling cases anyway. */
+  _gtk_pixel_cache_invalidate (tree_view->priv->pixel_cache, NULL);
+
+  GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->queue_draw_region (widget,
+                                                                   region);
+}
+
+static void
 gtk_tree_view_realize (GtkWidget *widget)
 {
   GtkAllocation allocation;


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