[PATCH 3/3] dri2: Support named DRI2Drawable references

Chris Wilson chris at chris-wilson.co.uk
Sat Feb 21 13:31:10 PST 2015


Allow the Client to manage its references to the DRI2Drawable by
providing named references whose lifetimes can be managed with
DRI2CreateDrawable2 and DRI2DestroyDrawable2. This stops the Client from
relying on such references being cleaned up along with the Drawable. As
each stale reference still causes an invalidate event to be sent, the
overhead of sending those unnecessary events quickly mounts.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 hw/xfree86/dri2/dri2ext.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 8e70bc5..270280b 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -194,6 +194,24 @@ ProcDRI2CreateDrawable(ClientPtr client)
 }
 
 static int
+ProcDRI2CreateDrawable2(ClientPtr client)
+{
+    REQUEST(xDRI2CreateDrawable2Req);
+    DrawablePtr pDrawable;
+    int status;
+
+    REQUEST_SIZE_MATCH(xDRI2CreateDrawable2Req);
+    LEGAL_NEW_RESOURCE(stuff->pid, client);
+
+    if (!validDrawable(client, stuff->drawable, DixAddAccess,
+                       &pDrawable, &status))
+        return status;
+
+    return DRI2CreateDrawable(client, pDrawable, stuff->pid,
+                              DRI2InvalidateBuffersEvent, client);
+}
+
+static int
 ProcDRI2DestroyDrawable(ClientPtr client)
 {
     REQUEST(xDRI2DestroyDrawableReq);
@@ -209,6 +227,21 @@ ProcDRI2DestroyDrawable(ClientPtr client)
 }
 
 static int
+ProcDRI2DestroyDrawable2(ClientPtr client)
+{
+    REQUEST(xDRI2DestroyDrawable2Req);
+    DrawablePtr pDrawable;
+    int status;
+
+    REQUEST_SIZE_MATCH(xDRI2DestroyDrawable2Req);
+    if (!validDrawable(client, stuff->drawable, DixRemoveAccess,
+                       &pDrawable, &status))
+        return status;
+
+    return DRI2DestroyDrawable(client, pDrawable, stuff->pid);
+}
+
+static int
 send_buffers_reply(ClientPtr client, DrawablePtr pDrawable,
                    DRI2BufferPtr * buffers, int count, int width, int height)
 {
@@ -601,8 +634,12 @@ ProcDRI2Dispatch(ClientPtr client)
         return ProcDRI2Authenticate(client);
     case X_DRI2CreateDrawable:
         return ProcDRI2CreateDrawable(client);
+    case X_DRI2CreateDrawable2:
+        return ProcDRI2CreateDrawable2(client);
     case X_DRI2DestroyDrawable:
         return ProcDRI2DestroyDrawable(client);
+    case X_DRI2DestroyDrawable2:
+        return ProcDRI2DestroyDrawable2(client);
     case X_DRI2GetBuffers:
         return ProcDRI2GetBuffers(client);
     case X_DRI2CopyRegion:
-- 
2.1.4



More information about the xorg-devel mailing list