[mutter/meego-1.0: 29/30] mutter-window: request DamageReportBoundingBox report level



commit 81cee3d8af9e321d0cb02e60d62b46cb6a1704f3
Author: Robert Bragg <robert linux intel com>
Date:   Thu May 13 21:43:30 2010 +0100

    mutter-window: request DamageReportBoundingBox report level
    
    In commit d34ae764769 I switched mutter-window to ask for Raw rectangles
    from the X server. This avoided 2 non synchronous and 2 synchronous X
    requests per window with damage, per frame; 2 (non-sync) to
    create/destroy a temporary region to copy the damage region into, 1 to
    request the server to copy the damage region into a our given region and
    another to fetch that region back into the client. The problem with raw
    events though is that it's possible to DOS the compositor with them.
    
    Instead of receiving an event for every bit of damage this patch instead
    asks the server to only report BoundingBox changes to the damage region.
    The disadvantage is that with this scheme we have to use a synchronous
    request to clear the region each frame (per window with damage), but it
    avoids the DOS issue which can cause window contents to freeze.

 src/compositor/mutter-window.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/compositor/mutter-window.c b/src/compositor/mutter-window.c
index fe64b7b..7a1b3ce 100644
--- a/src/compositor/mutter-window.c
+++ b/src/compositor/mutter-window.c
@@ -69,6 +69,7 @@ struct _MutterWindowPrivate
   guint             redecorating           : 1;
 
   guint		    needs_damage_all       : 1;
+  guint		    received_damage        : 1;
 
   guint		    needs_pixmap           : 1;
   guint		    needs_reshape          : 1;
@@ -352,7 +353,7 @@ mutter_window_constructed (GObject *object)
     priv->damage = None;
   else
     priv->damage = XDamageCreate (xdisplay, xwindow,
-                                  XDamageReportRawRectangles);
+                                  XDamageReportBoundingBox);
 
   format = XRenderFindVisualFormat (xdisplay, priv->attrs.visual);
 
@@ -1742,6 +1743,7 @@ mutter_window_process_damage (MutterWindow       *self,
                                           event->area.y,
                                           event->area.width,
                                           event->area.height);
+  priv->received_damage = TRUE;
 }
 
 void
@@ -1812,6 +1814,11 @@ mutter_window_update_shape (MutterWindow   *self,
 void
 mutter_window_pre_paint (MutterWindow *self)
 {
+  MutterWindowPrivate *priv = self->priv;
+  MetaScreen          *screen   = priv->screen;
+  MetaDisplay         *display  = meta_screen_get_display (screen);
+  Display             *xdisplay = meta_display_get_xdisplay (display);
+
   if (is_frozen (self))
     {
       /* The window is frozen due to a pending animation: we'll wait until
@@ -1819,6 +1826,13 @@ mutter_window_pre_paint (MutterWindow *self)
       return;
     }
 
+  if (priv->received_damage)
+    {
+      /* XXX: this is a synchronous request, per window with damage! */
+      XDamageSubtract (xdisplay, priv->damage, None, None);
+      priv->received_damage = FALSE;
+    }
+
   check_needs_reshape (self);
   check_needs_pixmap (self);
 }



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