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.

https://bugzilla.gnome.org/show_bug.cgi?id=611838
This commit is contained in:
Robert Bragg 2010-05-13 21:43:30 +01:00
parent ed19060074
commit 91d82bf8c7

View File

@ -68,6 +68,7 @@ struct _MutterWindowPrivate
guint redecorating : 1;
guint needs_damage_all : 1;
guint received_damage : 1;
guint needs_pixmap : 1;
guint needs_reshape : 1;
@ -337,7 +338,7 @@ mutter_window_constructed (GObject *object)
priv->damage = None;
else
priv->damage = XDamageCreate (xdisplay, xwindow,
XDamageReportRawRectangles);
XDamageReportBoundingBox);
format = XRenderFindVisualFormat (xdisplay, priv->attrs.visual);
@ -1652,6 +1653,8 @@ mutter_window_process_damage (MutterWindow *self,
MutterWindowPrivate *priv = self->priv;
ClutterX11TexturePixmap *texture_x11 = CLUTTER_X11_TEXTURE_PIXMAP (priv->actor);
priv->received_damage = TRUE;
if (is_frozen (self))
{
/* The window is frozen due to an effect in progress: we ignore damage
@ -1748,6 +1751,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
@ -1755,6 +1763,12 @@ mutter_window_pre_paint (MutterWindow *self)
return;
}
if (priv->received_damage)
{
XDamageSubtract (xdisplay, priv->damage, None, None);
priv->received_damage = FALSE;
}
check_needs_reshape (self);
check_needs_pixmap (self);
}