improve expose handling for alpha children
authorDana Jansens <danakj@orodu.net>
Tue, 3 Jun 2003 20:27:09 +0000 (20:27 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 3 Jun 2003 20:27:09 +0000 (20:27 +0000)
render2/paint.c

index dbdff14080a9ad705288a6bbbd7cd345ce775eb8..e22f1f2062898d88bb4018f2c2b490eb5d134755 100644 (file)
@@ -6,33 +6,41 @@
 #include <stdlib.h>
 #include <GL/glx.h>
 
-struct ExposeArea {
-    struct RrSurface *sur;
-    int x;
-    int y;
-    int w;
-    int h;
-};
-
-#define MERGE_AREA(a, x, y, w, h) \
-            a->w = MAX(a->x + a->w - 1, x + w - 1) - MIN(a->x, x), \
-            a->h = MAX(a->y + a->h - 1, y + h - 1) - MIN(a->y, y), \
-            a->x = MIN(a->x, x), \
-            a->y = MIN(a->y, y)
+void steal_children_exposes(struct RrInstance *inst, struct RrSurface *sur)
+{
+    GSList *it;
+    XEvent e2;
 
+    for (it = sur->children; it; it = g_slist_next(it)) {
+        switch (RrSurfaceType(((struct RrSurface*)it->data))) {
+        case RR_SURFACE_NONE:
+            break;
+        case RR_SURFACE_PLANAR:
+            if (RrPlanarHasAlpha(((struct RrSurface*)it->data))) {
+                while (XCheckTypedWindowEvent
+                       (RrDisplay(inst), Expose,
+                        ((struct RrSurface*)it->data)->win, &e2));
+                steal_children_exposes(inst, it->data);
+            }
+            break;
+        case RR_SURFACE_NONPLANAR:
+            assert(0);
+        }
+    }
+}
 
 void RrExpose(struct RrInstance *inst, XExposeEvent *e)
 {
     XEvent e2;
     struct RrSurface *sur;
-    Window win;
 
-    win = e->window;
+    g_message("Expose on %lx", e->window);
 
-    if ((sur = RrInstaceLookupSurface(inst, win))) {
+    if ((sur = RrInstaceLookupSurface(inst, e->window))) {
         while (1) {
             struct RrSurface *p = NULL;
 
+            /* steal events along the way */
             while (XCheckTypedWindowEvent(RrDisplay(inst), Expose,
                                           sur->win, &e2));
 
@@ -50,9 +58,11 @@ void RrExpose(struct RrInstance *inst, XExposeEvent *e)
             if (p) sur = p;
             else break;
         }
+        /* also do this for transparent children */
+        steal_children_exposes(inst, sur);
         RrPaint(sur, 0);
     } else
-        RrDebug("Unable to find surface for window 0x%lx\n", win);
+        RrDebug("Unable to find surface for window 0x%lx\n", e->window);
 }
 
 /*! Paints the surface, and all its children */
@@ -72,6 +82,8 @@ void RrPaint(struct RrSurface *sur, int recurse_always)
 
     if (!RrSurfaceVisible(sur)) return;
 
+    g_message("PAINTING SURFACE %p", sur);
+
     ok = glXMakeCurrent(RrDisplay(inst), RrSurfaceWindow(sur),RrContext(inst));
     assert(ok);