[PATCH 04/11] mi: Drastically simplify miWindowExposures

Adam Jackson ajax at redhat.com
Thu Sep 18 10:23:53 PDT 2014


First, we drop the "spontaneous combustion" path.  In a composited
environment you're never going to hit that anyway, and even in a classic
environment it's so rare to hit as to not be worth it.  Second, we
delete the declaration of exposures, replace exposures with prgn
to match, and then delete all the redundant conditionals.

Suddenly this looks like a function a mortal could understand.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 mi/miexpose.c | 53 +++++------------------------------------------------
 1 file changed, 5 insertions(+), 48 deletions(-)

diff --git a/mi/miexpose.c b/mi/miexpose.c
index 23987fa..98112ab 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -423,55 +423,12 @@ miSendExposures(WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
 void
 miWindowExposures(WindowPtr pWin, RegionPtr prgn)
 {
-    RegionPtr exposures = prgn;
-
-    if ((prgn && !RegionNil(prgn)) || (exposures && !RegionNil(exposures))) {
-        RegionRec expRec;
-        int clientInterested;
-
-        /*
-         * Restore from backing-store FIRST.
-         */
-        clientInterested =
-            (pWin->eventMask | wOtherEventMasks(pWin)) & ExposureMask;
-        if (clientInterested && exposures &&
-            (RegionNumRects(exposures) > RECTLIMIT)) {
-            /*
-             * If we have LOTS of rectangles, we decide to take the extents
-             * and force an exposure on that.  This should require much less
-             * work overall, on both client and server.  This is cheating, but
-             * isn't prohibited by the protocol ("spontaneous combustion" :-).
-             */
-            BoxRec box;
-
-            box = *RegionExtents(exposures);
-            if (exposures == prgn) {
-                exposures = &expRec;
-                RegionInit(exposures, &box, 1);
-                RegionReset(prgn, &box);
-            }
-            else {
-                RegionReset(exposures, &box);
-                RegionUnion(prgn, prgn, exposures);
-            }
-            /* miPaintWindow doesn't clip, so we have to */
-            RegionIntersect(prgn, prgn, &pWin->clipList);
-        }
-        if (prgn && !RegionNil(prgn))
-            miPaintWindow(pWin, prgn, PW_BACKGROUND);
-        if (clientInterested && exposures && !RegionNil(exposures))
-            miSendExposures(pWin, exposures,
-                            pWin->drawable.x, pWin->drawable.y);
-        if (exposures == &expRec) {
-            RegionUninit(exposures);
-        }
-        else if (exposures && exposures != prgn)
-            RegionDestroy(exposures);
-        if (prgn)
-            RegionEmpty(prgn);
+    if (prgn && !RegionNil(prgn)) {
+        miPaintWindow(pWin, prgn, PW_BACKGROUND);
+        if ((pWin->eventMask | wOtherEventMasks(pWin)) & ExposureMask)
+            miSendExposures(pWin, prgn, pWin->drawable.x, pWin->drawable.y);
+        RegionEmpty(prgn);
     }
-    else if (exposures && exposures != prgn)
-        RegionDestroy(exposures);
 }
 
 #ifdef ROOTLESS
-- 
1.9.3



More information about the xorg-devel mailing list