[gtk+/wip/paint-stack-2: 1/3] gdkwindow: Fizzle out early if we don't have to do anything



commit d29922ad73b7a34368fb82ddfac8620523147d0e
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Jun 23 16:30:58 2014 -0400

    gdkwindow: Fizzle out early if we don't have to do anything

 gdk/gdkwindow.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 68a75df..2ca81b0 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -3236,6 +3236,7 @@ _gdk_window_process_updates_recurse_helper (GdkWindow *window,
   GdkWindow *child;
   cairo_region_t *clipped_expose_region;
   GList *l, *children;
+  gboolean send_expose_event;
 
   if (window->destroyed)
     return;
@@ -3243,6 +3244,21 @@ _gdk_window_process_updates_recurse_helper (GdkWindow *window,
   if (window->alpha == 0 && !gdk_window_has_impl (window))
     return;
 
+  /* While gtk+ no longer handles exposes on anything but native
+     window we still have to send them to all windows that have the
+     event mask set for backwards compat. We also need to send
+     it to all native windows, even if they don't specify the
+     expose mask, because they may have non-native children that do. */
+  send_expose_event = (gdk_window_has_impl (window) ||
+                       window->event_mask & GDK_EXPOSURE_MASK);
+
+  /* If we have no children, we aren't an offscreen window, and we aren't going
+   * to send an expose event, so fizzle out now. */
+  if (window->children == NULL &&
+      !gdk_window_is_offscreen (window) &&
+      !send_expose_event)
+    return;
+
   clipped_expose_region = cairo_region_copy (expose_region);
 
   if (!gdk_window_has_impl (window))
@@ -3258,13 +3274,7 @@ _gdk_window_process_updates_recurse_helper (GdkWindow *window,
 
   /* Paint the window before the children, clipped to the window region */
 
-  /* While gtk+ no longer handles exposes on anything but native
-     window we still have to send them to all windows that have the
-     event mask set for backwards compat. We also need to send
-     it to all native windows, even if they don't specify the
-     expose mask, because they may have non-native children that do. */
-  if (gdk_window_has_impl (window) ||
-      window->event_mask & GDK_EXPOSURE_MASK)
+  if (send_expose_event)
     {
       GdkEvent event;
 


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