Signed-off-by: Francisco Jerez <[email protected]>
---
 glx/glxdri2.c |   54 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 0f998de..2cfc691 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -102,14 +102,14 @@ __glXDRIdrawableDestroy(__GLXdrawable *drawable)
 {
     __GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable;
     const __DRIcoreExtension *core = private->screen->core;
-    
-    (*core->destroyDrawable)(private->driDrawable);
 
     /* If the X window was destroyed, the dri DestroyWindow hook will
      * aready have taken care of this, so only call if pDraw isn't NULL. */
     if (drawable->pDraw != NULL)
        DRI2DestroyDrawable(drawable->pDraw);
 
+    (*core->destroyDrawable)(private->driDrawable);
+
     __glXDrawableRelease(drawable);
 
     xfree(private);
@@ -213,13 +213,8 @@ __glXdriSwapEvent(ClientPtr client, void *data, int type, 
CARD64 ust,
 static GLboolean
 __glXDRIdrawableSwapBuffers(ClientPtr client, __GLXdrawable *drawable)
 {
-    __GLXDRIdrawable *priv = (__GLXDRIdrawable *) drawable;
-    __GLXDRIscreen *screen = priv->screen;
     CARD64 unused;
 
-    if (screen->flush)
-       (*screen->flush->flushInvalidate)(priv->driDrawable);
-
     if (DRI2SwapBuffers(client, drawable->pDraw, 0, 0, 0, &unused,
                        __glXdriSwapEvent, drawable->pDraw) != Success)
        return FALSE;
@@ -467,6 +462,21 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
     return &private->base;
 }
 
+static void
+__glXDRIinvalidateEvent(DrawablePtr pDraw, XID id)
+{
+    __GLXDRIscreen *screen;
+    __GLXDRIdrawable *draw;
+
+    if (pDraw->type == DRAWABLE_WINDOW) {
+       screen = (__GLXDRIscreen *)glxGetScreen(pDraw->pScreen);
+       draw = (__GLXDRIdrawable *)glxGetDrawableFromWindow((WindowPtr)pDraw);
+
+       if (screen->flush)
+           screen->flush->invalidate(draw->driDrawable);
+    }
+}
+
 static __DRIbuffer *
 dri2GetBuffers(__DRIdrawable *driDrawable,
               int *width, int *height,
@@ -474,17 +484,21 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
               int *out_count, void *loaderPrivate)
 {
     __GLXDRIdrawable *private = loaderPrivate;
+    DrawablePtr pDraw = private->base.pDraw;
     DRI2BufferPtr *buffers;
-    int i;
-    int j;
+    int i, j, ret;
 
-    buffers = DRI2GetBuffers(private->base.pDraw,
-                            width, height, attachments, count, out_count);
+    buffers = DRI2GetBuffers(pDraw, width, height, attachments,
+                            count, out_count);
     if (*out_count > MAX_DRAWABLE_BUFFERS) {
        *out_count = 0;
        return NULL;
     }
-       
+
+    ret = DRI2TrackClient(pDraw, INVALID, __glXDRIinvalidateEvent);
+    if (ret && ret != BadIDChoice)
+       return NULL;
+
     private->width = *width;
     private->height = *height;
 
@@ -494,7 +508,7 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
     for (i = 0; i < *out_count; i++) {
        /* Do not send the real front buffer of a window to the client.
         */
-       if ((private->base.pDraw->type == DRAWABLE_WINDOW)
+       if ((pDraw->type == DRAWABLE_WINDOW)
            && (buffers[i]->attachment == DRI2BufferFrontLeft)) {
            continue;
        }
@@ -518,18 +532,22 @@ dri2GetBuffersWithFormat(__DRIdrawable *driDrawable,
                         int *out_count, void *loaderPrivate)
 {
     __GLXDRIdrawable *private = loaderPrivate;
+    DrawablePtr pDraw = private->base.pDraw;
     DRI2BufferPtr *buffers;
-    int i;
+    int i, ret;
     int j = 0;
 
-    buffers = DRI2GetBuffersWithFormat(private->base.pDraw,
-                                      width, height, attachments, count,
-                                      out_count);
+    buffers = DRI2GetBuffersWithFormat(pDraw, width, height, attachments,
+                                      count, out_count);
     if (*out_count > MAX_DRAWABLE_BUFFERS) {
        *out_count = 0;
        return NULL;
     }
 
+    ret = DRI2TrackClient(pDraw, INVALID, __glXDRIinvalidateEvent);
+    if (ret && ret != BadIDChoice)
+       return NULL;
+
     private->width = *width;
     private->height = *height;
 
@@ -538,7 +556,7 @@ dri2GetBuffersWithFormat(__DRIdrawable *driDrawable,
     for (i = 0; i < *out_count; i++) {
        /* Do not send the real front buffer of a window to the client.
         */
-       if ((private->base.pDraw->type == DRAWABLE_WINDOW)
+       if ((pDraw->type == DRAWABLE_WINDOW)
            && (buffers[i]->attachment == DRI2BufferFrontLeft)) {
            continue;
        }
-- 
1.6.4.4

_______________________________________________
xorg-devel mailing list
[email protected]
http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to