Re: Some initial thoughts about 2.4



Soeren Sandmann <sandmann daimi au dk> writes:

> For Gnumeric, just making GtkWindow and GtkToolbar !REDRAW_ON_ALLOCATE
> would increase the framerate significantly because all the pixbufs on
> the toolbar wouldn't get redrawn on every mouse event.

I tried this, and it turned out that it was necessary to change
libbonoboui as well. The attached patches gives a good speedup on
opaque resizing Gnumeric.

The patches are definitely not commit material for several reasons,
including

        - it is not clear that we can make widgets !redraw_on_allocate
          without breaking API compatibility. As changes-2.0 says:

                The GtkBox, GtkTable, and GtkAlignment widgets now
                call gtk_widget_set_redraw_on_allocate (widget,
                FALSE); on themselves. If you want to actually draw
                contents in a widget derived from one of these
                widgets, you'll probably want to change this in your
                init() function.

          It would be possible to work around this by checking in the
          init() functions whether the widget actually is a derived
          widget and if so, don't call set_redraw_on_allocate().

        - themes that want to draw a gradient or something else that
          depends on the widget's size, will need a way to make
          widgets redraw_on_allocate() always.

        - the coding style is wrong


Søren

? autom4te.cache
? bonoboui.patch
Index: bonobo/bonobo-dock-item.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/bonobo/bonobo-dock-item.c,v
retrieving revision 1.61
diff -u -p -u -r1.61 bonobo-dock-item.c
--- bonobo/bonobo-dock-item.c	28 Jun 2002 04:42:26 -0000	1.61
+++ bonobo/bonobo-dock-item.c	1 Jan 2003 13:58:02 -0000
@@ -395,7 +395,8 @@ static void
 bonobo_dock_item_instance_init (BonoboDockItem *dock_item)
 {
   GTK_WIDGET_UNSET_FLAGS (dock_item, GTK_NO_WINDOW);
-
+  gtk_widget_set_redraw_on_allocate (GTK_WIDGET (dock_item), FALSE);
+  
   dock_item->_priv = g_new (BonoboDockItemPrivate, 1);
 
   dock_item->_priv->grip = bonobo_dock_item_grip_new (dock_item);
@@ -866,6 +867,8 @@ bonobo_dock_item_paint (GtkWidget      *
   bin = GTK_BIN (widget);
   di = BONOBO_DOCK_ITEM (widget);
 
+  g_print ("dock item expose\n");
+  
   border_width = GTK_CONTAINER (di)->border_width;
 
   if (di->is_floating)
Index: bonobo/bonobo-dock.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/bonobo/bonobo-dock.c,v
retrieving revision 1.43
diff -u -p -u -r1.43 bonobo-dock.c
--- bonobo/bonobo-dock.c	26 Mar 2002 11:10:12 -0000	1.43
+++ bonobo/bonobo-dock.c	1 Jan 2003 13:58:03 -0000
@@ -196,6 +196,7 @@ static void
 bonobo_dock_instance_init (BonoboDock *dock)
 {
   GTK_WIDGET_SET_FLAGS (GTK_WIDGET (dock), GTK_NO_WINDOW);
+  gtk_widget_set_redraw_on_allocate (GTK_WIDGET (dock), FALSE);
 
   dock->_priv = NULL;
   /* XXX: when there is some private stuff enable this
Index: gtkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwindow.c,v
retrieving revision 1.237
diff -u -p -u -r1.237 gtkwindow.c
--- gtkwindow.c	16 Dec 2002 00:05:21 -0000	1.237
+++ gtkwindow.c	1 Jan 2003 13:59:11 -0000
@@ -691,6 +691,7 @@ gtk_window_init (GtkWindow *window)
   
   GTK_WIDGET_UNSET_FLAGS (window, GTK_NO_WINDOW);
   GTK_WIDGET_SET_FLAGS (window, GTK_TOPLEVEL);
+  gtk_widget_set_redraw_on_allocate (GTK_WIDGET (window), FALSE);
 
   GTK_PRIVATE_SET_FLAG (window, GTK_ANCHORED);
 
Index: gtktoolbar.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktoolbar.c,v
retrieving revision 1.84
diff -u -p -u -r1.84 gtktoolbar.c
--- gtktoolbar.c	26 Nov 2002 22:12:56 -0000	1.84
+++ gtktoolbar.c	1 Jan 2003 13:59:12 -0000
@@ -382,6 +382,7 @@ gtk_toolbar_init (GtkToolbar *toolbar)
 {
   GTK_WIDGET_SET_FLAGS (toolbar, GTK_NO_WINDOW);
   GTK_WIDGET_UNSET_FLAGS (toolbar, GTK_CAN_FOCUS);
+  gtk_widget_set_redraw_on_allocate (GTK_WIDGET (toolbar), FALSE);
 
   toolbar->num_children = 0;
   toolbar->children     = NULL;
@@ -698,6 +699,27 @@ gtk_toolbar_size_allocate (GtkWidget    
   
   g_return_if_fail (GTK_IS_TOOLBAR (widget));
   g_return_if_fail (allocation != NULL);
+
+  if (GTK_WIDGET_MAPPED (widget))
+  {
+      if (widget->allocation.height != allocation->height ||
+	  widget->allocation.x != allocation->x ||
+	  widget->allocation.y != allocation->y)
+      {
+	  gtk_widget_queue_draw (widget);
+      }
+      else
+      {
+	  GdkRectangle invalid;
+	  
+	  invalid.x = widget->allocation.x + widget->allocation.width - widget->style->xthickness - 2;
+	  invalid.y = widget->allocation.y;
+	  invalid.height = widget->allocation.height;
+	  invalid.width = widget->style->xthickness + 2;
+	  
+	  gdk_window_invalidate_rect (widget->window, &invalid, FALSE);
+      }
+  }
 
   toolbar = GTK_TOOLBAR (widget);
   widget->allocation = *allocation;
Index: gtknotebook.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtknotebook.c,v
retrieving revision 1.147
diff -u -p -u -r1.147 gtknotebook.c
--- gtknotebook.c	10 Dec 2002 12:02:42 -0000	1.147
+++ gtknotebook.c	1 Jan 2003 13:59:16 -0000
@@ -3276,7 +3276,7 @@ gtk_notebook_pages_allocate (GtkNotebook
     }
 
  done:
-  gtk_notebook_redraw_tabs (notebook);  
+  return;
 }
 
 static void
@@ -3338,8 +3338,6 @@ gtk_notebook_page_allocate (GtkNotebook 
          y = 0;
          break;
        }
-
-      gtk_widget_queue_draw_area (widget, x, y, width, height);
     }
 
   page->allocation = *allocation;
Index: gtkmenubar.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenubar.c,v
retrieving revision 1.51
diff -u -p -u -r1.51 gtkmenubar.c
--- gtkmenubar.c	2 Nov 2002 00:18:14 -0000	1.51
+++ gtkmenubar.c	1 Jan 2003 13:59:17 -0000
@@ -38,12 +38,13 @@
 
 
 #define BORDER_SPACING  0
-#define CHILD_SPACING   3
-#define DEFAULT_IPADDING 1
+#define CHILD_SPACING   0
+#define DEFAULT_IPADDING 0
 
 static void gtk_menu_bar_class_init        (GtkMenuBarClass *klass);
 static void gtk_menu_bar_size_request      (GtkWidget       *widget,
 					    GtkRequisition  *requisition);
+static void gtk_menu_bar_init              (GtkWidget       *widget);
 static void gtk_menu_bar_size_allocate     (GtkWidget       *widget,
 					    GtkAllocation   *allocation);
 static void gtk_menu_bar_paint             (GtkWidget       *widget,
@@ -76,7 +77,7 @@ gtk_menu_bar_get_type (void)
 	NULL,		/* class_data */
 	sizeof (GtkMenuBar),
 	0,		/* n_preallocs */
-	NULL,		/* instance_init */
+	(GInstanceInitFunc) gtk_menu_bar_init,
       };
 
       menu_bar_type = g_type_register_static (GTK_TYPE_MENU_SHELL, "GtkMenuBar",
@@ -176,7 +177,13 @@ gtk_menu_bar_class_init (GtkMenuBarClass
 						   0,
 						   G_PARAM_READWRITE));
 }
- 
+
+static void
+gtk_menu_bar_init (GtkWidget *widget)
+{
+  gtk_widget_set_redraw_on_allocate (widget, FALSE);
+}
+
 GtkWidget*
 gtk_menu_bar_new (void)
 {
@@ -275,6 +282,27 @@ gtk_menu_bar_size_allocate (GtkWidget   
 
   g_return_if_fail (GTK_IS_MENU_BAR (widget));
   g_return_if_fail (allocation != NULL);
+
+  if (GTK_WIDGET_MAPPED (widget))
+  {
+      if (widget->allocation.height != allocation->height ||
+	  widget->allocation.x != allocation->x ||
+	  widget->allocation.y != allocation->y)
+      {
+	  gtk_widget_queue_draw (widget);
+      }
+      else
+      {
+	  GdkRectangle invalid;
+	  
+	  invalid.x = widget->allocation.width - widget->style->xthickness - 2;
+	  invalid.y = 0;
+	  invalid.height = widget->allocation.height;
+	  invalid.width = widget->style->xthickness + 2;
+	  
+	  gdk_window_invalidate_rect (widget->window, &invalid, FALSE);
+      }
+  }
 
   menu_bar = GTK_MENU_BAR (widget);
   menu_shell = GTK_MENU_SHELL (widget);


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