[PATCH] composite: Optimize resizes of ForgetGravity windows

Adam Jackson ajax at redhat.com
Fri Jul 25 08:07:26 PDT 2014


Per the spec:

    A bit-gravity of Forget indicates that the window contents are
    always discarded after a size change, even if backing-store or
    save-under has been requested. The window is tiled with its
    background (except, if no background is defined, the existing
    screen contents are not altered) and zero or more exposure events
    are generated.

For redirected windows, size changes hit compReallocPixmap, which
normally attempts to preserve the previous pixmap in cw->pOldPixmap.
For ForgetGravity windows we now destroy the old pixmap before
allocating the new one.  This reduces pressure on the allocator, and
also eliminates some overdraw (compCopyWindow would copy in the bits
from the old pixmap regardless of gravity, even though they're about to
be blown away by the background tile described above).

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 composite/compalloc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/composite/compalloc.c b/composite/compalloc.c
index dfbff06..38ebc7e 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -678,6 +678,10 @@ compReallocPixmap(WindowPtr pWin, int draw_x, int draw_y,
     pix_w = w + (bw << 1);
     pix_h = h + (bw << 1);
     if (pix_w != pOld->drawable.width || pix_h != pOld->drawable.height) {
+        if (pWin->bitGravity == ForgetGravity) {
+            pScreen->DestroyPixmap(pOld);
+            pOld = NULL;
+        }
         pNew = compNewPixmap(pWin, pix_x, pix_y, pix_w, pix_h);
         if (!pNew)
             return FALSE;
-- 
1.9.3



More information about the xorg-devel mailing list