This allows the driver to mark certain buffers, such as the real
front-buffer, to not be returned to the client.

Signed-off-by: Ian Romanick <[email protected]>
---
 glx/glxdri2.c             |    8 ++++++++
 hw/xfree86/dri2/dri2.h    |   10 ++++++++++
 hw/xfree86/dri2/dri2ext.c |   16 ++++++++++++++--
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index c896536..1e38bf1 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -406,6 +406,7 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
     __GLXDRIdrawable *private = loaderPrivate;
     DRI2BufferPtr buffers;
     int i;
+    int skip;
 
     buffers = DRI2GetBuffers(private->base.pDraw,
                             width, height, attachments, count, out_count);
@@ -419,7 +420,13 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
 
     /* This assumes the DRI2 buffer attachment tokens matches the
      * __DRIbuffer tokens. */
+    skip = 0;
     for (i = 0; i < *out_count; i++) {
+       if ((buffers[i].flags & DRI2_BUFFER_DONT_SEND) != 0) {
+           skip++;
+           continue;
+       }
+
        private->buffers[i].attachment = buffers[i].attachment;
        private->buffers[i].name = buffers[i].name;
        private->buffers[i].pitch = buffers[i].pitch;
@@ -427,6 +434,7 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
        private->buffers[i].flags = buffers[i].flags;
     }
 
+    *out_count -= skip;
     return private->buffers;
 }
 
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 847e57c..db883a5 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -44,6 +44,16 @@ typedef struct {
     void *driverPrivate;
 } DRI2BufferRec, *DRI2BufferPtr;
 
+/**
+ * \name DRI2 buffer flags
+ *
+ * Possible values for \c DRI2BufferRec::flags
+ */
+/*...@{*/
+#define DRI2_BUFFER_DONT_SEND  (1U << 0)   /**< Don't send buffer to client */
+/*...@}*/
+
+
 typedef DRI2BufferPtr  (*DRI2CreateBuffersProcPtr)(DrawablePtr pDraw,
                                                    unsigned int *attachments,
                                                    int count);
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index d6e1c96..70f64b1 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -202,6 +202,7 @@ ProcDRI2GetBuffers(ClientPtr client)
     int i, status, width, height, count;
     unsigned int *attachments;
     xDRI2Buffer buffer;
+    unsigned skip;
 
     REQUEST_FIXED_SIZE(xDRI2GetBuffersReq, stuff->count * 4);
     if (!validDrawable(client, stuff->drawable, &pDrawable, &status))
@@ -211,15 +212,26 @@ ProcDRI2GetBuffers(ClientPtr client)
     buffers = DRI2GetBuffers(pDrawable, &width, &height,
                             attachments, stuff->count, &count);
 
+    skip = 0;
+    for (i = 0; i < count; i++) {
+       if ((buffers[i].flags & DRI2_BUFFER_DONT_SEND) != 0) {
+           skip++;
+       }
+    }
+
     rep.type = X_Reply;
-    rep.length = count * sizeof(xDRI2Buffer) / 4;
+    rep.length = (count - skip) * sizeof(xDRI2Buffer) / 4;
     rep.sequenceNumber = client->sequence;
     rep.width = width;
     rep.height = height;
-    rep.count = count;
+    rep.count = count - skip;
     WriteToClient(client, sizeof(xDRI2GetBuffersReply), &rep);
 
     for (i = 0; i < count; i++) {
+       if ((buffers[i].flags & DRI2_BUFFER_DONT_SEND) != 0) {
+           continue;
+       }
+
        buffer.attachment = buffers[i].attachment;
        buffer.name = buffers[i].name;
        buffer.pitch = buffers[i].pitch;
-- 
1.6.0.6


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to