summaryrefslogtreecommitdiff
path: root/src/glx/x11/dri2.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-08-13 11:46:25 -0400
committerKristian Høgsberg <krh@redhat.com>2008-08-29 12:13:14 -0400
commitf56b569e9af356c11869ee49a4669bb01b75397e (patch)
tree5fd52ee856b106c8b97027061737d366de2d1c2b /src/glx/x11/dri2.c
parent7a2ab6d05573508389b38f8f1fa261ba56062865 (diff)
DRI2: Drop sarea, implement swap buffers in the X server.
Diffstat (limited to 'src/glx/x11/dri2.c')
-rw-r--r--src/glx/x11/dri2.c113
1 files changed, 81 insertions, 32 deletions
diff --git a/src/glx/x11/dri2.c b/src/glx/x11/dri2.c
index e7044ab424..dc60af90c1 100644
--- a/src/glx/x11/dri2.c
+++ b/src/glx/x11/dri2.c
@@ -122,7 +122,11 @@ Bool DRI2Connect(Display *dpy, int screen,
return False;
}
- *sareaHandle = rep.sareaHandle;
+ if (rep.driverNameLength == 0 && rep.busIdLength == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
*driverName = Xmalloc(rep.driverNameLength + 1);
if (*driverName == NULL) {
@@ -150,7 +154,7 @@ Bool DRI2Connect(Display *dpy, int screen,
UnlockDisplay(dpy);
SyncHandle();
- return rep.sareaHandle != 0;
+ return True;
}
Bool DRI2AuthConnection(Display *dpy, int screen, drm_magic_t magic)
@@ -179,74 +183,119 @@ Bool DRI2AuthConnection(Display *dpy, int screen, drm_magic_t magic)
return rep.authenticated;
}
-Bool DRI2CreateDrawable(Display *dpy, XID drawable,
- unsigned int *handle, unsigned int *head)
+void DRI2CreateDrawable(Display *dpy, XID drawable)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2CreateDrawableReply rep;
xDRI2CreateDrawableReq *req;
- XextCheckExtension (dpy, info, dri2ExtensionName, False);
+ XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
LockDisplay(dpy);
GetReq(DRI2CreateDrawable, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2CreateDrawable;
req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+DRI2Buffer *DRI2GetBuffers(Display *dpy, XID drawable,
+ int *width, int *height,
+ unsigned int *attachments, int count,
+ int *outCount)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+ xDRI2GetBuffersReply rep;
+ xDRI2GetBuffersReq *req;
+ DRI2Buffer *buffers;
+ xDRI2Buffer repBuffer;
+ CARD32 *p;
+ int i;
+
+ XextCheckExtension (dpy, info, dri2ExtensionName, False);
+
+ LockDisplay(dpy);
+ GetReqExtra(DRI2GetBuffers, count * 4, req);
+ req->reqType = info->codes->major_opcode;
+ req->dri2ReqType = X_DRI2GetBuffers;
+ req->drawable = drawable;
+ req->count = count;
+ p = (CARD32 *) &req[1];
+ for (i = 0; i < count; i++)
+ p[i] = attachments[i];
+
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
- return False;
+ return NULL;
+ }
+
+ *width = rep.width;
+ *height = rep.height;
+ *outCount = rep.count;
+
+ buffers = Xmalloc(count * sizeof buffers[0]);
+ if (buffers == NULL) {
+ _XEatData(dpy, rep.count * sizeof repBuffer);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ for (i = 0; i < rep.count; i++) {
+ _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
+ buffers[i].attachment = repBuffer.attachment;
+ buffers[i].name = repBuffer.name;
+ buffers[i].pitch = repBuffer.pitch;
+ buffers[i].cpp = repBuffer.cpp;
+ buffers[i].flags = repBuffer.flags;
}
+
UnlockDisplay(dpy);
SyncHandle();
- *handle = rep.handle;
- *head = rep.head;
-
- return True;
+ return buffers;
}
-void DRI2DestroyDrawable(Display *dpy, XID drawable)
+void DRI2SwapBuffers(Display *dpy, XID drawable,
+ int x, int y, int width, int height)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2DestroyDrawableReq *req;
+ xDRI2SwapBuffersReq *req;
+ xDRI2SwapBuffersReply rep;
XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
- XSync(dpy, GL_FALSE);
-
LockDisplay(dpy);
- GetReq(DRI2DestroyDrawable, req);
+ GetReq(DRI2SwapBuffers, req);
req->reqType = info->codes->major_opcode;
- req->dri2ReqType = X_DRI2DestroyDrawable;
+ req->dri2ReqType = X_DRI2SwapBuffers;
req->drawable = drawable;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+
+ _XReply(dpy, (xReply *)&rep, 0, xFalse);
+
UnlockDisplay(dpy);
SyncHandle();
}
-Bool DRI2ReemitDrawableInfo(Display *dpy, XID drawable, unsigned int *head)
+void DRI2DestroyDrawable(Display *dpy, XID drawable)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2ReemitDrawableInfoReply rep;
- xDRI2ReemitDrawableInfoReq *req;
+ xDRI2DestroyDrawableReq *req;
- XextCheckExtension (dpy, info, dri2ExtensionName, False);
+ XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
+
+ XSync(dpy, GL_FALSE);
LockDisplay(dpy);
- GetReq(DRI2ReemitDrawableInfo, req);
+ GetReq(DRI2DestroyDrawable, req);
req->reqType = info->codes->major_opcode;
- req->dri2ReqType = X_DRI2ReemitDrawableInfo;
+ req->dri2ReqType = X_DRI2DestroyDrawable;
req->drawable = drawable;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
UnlockDisplay(dpy);
SyncHandle();
-
- *head = rep.head;
-
- return True;
}