diff options
author | Kristian Høgsberg <krh@redhat.com> | 2008-10-07 13:49:28 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2008-10-15 00:00:44 -0400 |
commit | ced6690284fd334f225bbc94685c114ad3ab96d8 (patch) | |
tree | b5852dffc62484e4a452dcbf2569c110be97e254 /hw/xfree86/dri2/dri2ext.c | |
parent | 87a016ae00feac3fbaa7e7a518076a3852d49554 (diff) |
dri2: Update to latest protocol draft.
Mainly rename SwapBuffers to CopyRegion, which adds the xfixes region
argument and the bitmask argument to let us extend it in the future.
Diffstat (limited to 'hw/xfree86/dri2/dri2ext.c')
-rw-r--r-- | hw/xfree86/dri2/dri2ext.c | 114 |
1 files changed, 53 insertions, 61 deletions
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c index ce2290b11..595df7375 100644 --- a/hw/xfree86/dri2/dri2ext.c +++ b/hw/xfree86/dri2/dri2ext.c @@ -38,11 +38,13 @@ #include <X11/X.h> #include <X11/Xproto.h> #include <X11/extensions/dri2proto.h> +#include <X11/extensions/xfixeswire.h> #include "dixstruct.h" #include "scrnintstr.h" #include "pixmapstr.h" #include "extnsionst.h" #include "xf86drm.h" +#include "xfixes.h" #include "dri2.h" /* The only xf86 include */ @@ -52,19 +54,6 @@ static ExtensionEntry *dri2Extension; static RESTYPE dri2DrawableRes; static Bool -validScreen(ClientPtr client, int screen, ScreenPtr *pScreen) -{ - if (screen >= screenInfo.numScreens) { - client->errorValue = screen; - return FALSE; - } - - *pScreen = screenInfo.screens[screen]; - - return TRUE; -} - -static Bool validDrawable(ClientPtr client, XID drawable, DrawablePtr *pDrawable, int *status) { @@ -111,64 +100,55 @@ ProcDRI2Connect(ClientPtr client) { REQUEST(xDRI2ConnectReq); xDRI2ConnectReply rep; - ScreenPtr pScreen; - int fd; + DrawablePtr pDraw; + int fd, status; const char *driverName; - char *busId = NULL; + const char *deviceName; REQUEST_SIZE_MATCH(xDRI2ConnectReq); - if (!validScreen(client, stuff->screen, &pScreen)) - return BadValue; + if (!validDrawable(client, stuff->window, &pDraw, &status)) + return status; rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; rep.driverNameLength = 0; - rep.busIdLength = 0; + rep.deviceNameLength = 0; - if (!DRI2Connect(pScreen, &fd, &driverName)) - goto fail; - - busId = drmGetBusid(fd); - if (busId == NULL) + if (!DRI2Connect(pDraw->pScreen, + stuff->driverType, &fd, &driverName, &deviceName)) goto fail; rep.driverNameLength = strlen(driverName); - rep.busIdLength = strlen(busId); - rep.length = (rep.driverNameLength + 3) / 4 + (rep.busIdLength + 3) / 4; + rep.deviceNameLength = strlen(deviceName); + rep.length = (rep.driverNameLength + 3) / 4 + + (rep.deviceNameLength + 3) / 4; fail: WriteToClient(client, sizeof(xDRI2ConnectReply), &rep); WriteToClient(client, rep.driverNameLength, driverName); - WriteToClient(client, rep.busIdLength, busId); - drmFreeBusid(busId); + WriteToClient(client, rep.deviceNameLength, deviceName); return client->noClientException; } static int -ProcDRI2AuthConnection(ClientPtr client) +ProcDRI2Authenticate(ClientPtr client) { - REQUEST(xDRI2AuthConnectionReq); - xDRI2AuthConnectionReply rep; - ScreenPtr pScreen; + REQUEST(xDRI2AuthenticateReq); + xDRI2AuthenticateReply rep; + DrawablePtr pDraw; + int status; - REQUEST_SIZE_MATCH(xDRI2AuthConnectionReq); - if (!validScreen(client, stuff->screen, &pScreen)) - return BadValue; + REQUEST_SIZE_MATCH(xDRI2AuthenticateReq); + if (!validDrawable(client, stuff->window, &pDraw, &status)) + return status; rep.type = X_Reply; - rep.length = 0; rep.sequenceNumber = client->sequence; - rep.authenticated = 1; - - if (!DRI2AuthConnection(pScreen, stuff->magic)) { - ErrorF("DRI2: Failed to authenticate %lu\n", - (unsigned long) stuff->magic); - rep.authenticated = 0; - } - - WriteToClient(client, sizeof(xDRI2AuthConnectionReply), &rep); + rep.length = 0; + rep.authenticated = DRI2Authenticate(pDraw->pScreen, stuff->magic); + WriteToClient(client, sizeof(xDRI2AuthenticateReply), &rep); return client->noClientException; } @@ -228,7 +208,7 @@ ProcDRI2GetBuffers(ClientPtr client) if (!validDrawable(client, stuff->drawable, &pDrawable, &status)) return status; - attachments = (CARD32 *) &stuff[1]; + attachments = (unsigned int *) &stuff[1]; buffers = DRI2GetBuffers(pDrawable, &width, &height, attachments, stuff->count, &count); @@ -253,30 +233,42 @@ ProcDRI2GetBuffers(ClientPtr client) } static int -ProcDRI2SwapBuffers(ClientPtr client) +ProcDRI2CopyRegion(ClientPtr client) { - REQUEST(xDRI2SwapBuffersReq); - xDRI2SwapBuffersReply rep; + REQUEST(xDRI2CopyRegionReq); + xDRI2CopyRegionReply rep; DrawablePtr pDrawable; int status; + RegionPtr pRegion; + + REQUEST_SIZE_MATCH(xDRI2CopyRegionReq); + + /* No optional values supported for DRI2 2.0 protocol. */ + if (stuff->bitmask != 0) + return BadValue; - REQUEST_SIZE_MATCH(xDRI2SwapBuffersReq); if (!validDrawable(client, stuff->drawable, &pDrawable, &status)) return status; - /* Swap buffers need to do a round trip to make sure the X server + VERIFY_REGION(pRegion, stuff->region, client, DixReadAccess); + + status = DRI2CopyRegion(pDrawable, pRegion, stuff->dest, stuff->src); + if (status != Success) + return status; + + /* CopyRegion needs to be a round trip to make sure the X server * queues the swap buffer rendering commands before the DRI client - * continues rendering. + * continues rendering. The reply has a bitmask to signal the + * presense of optional return values as well, but we're not using + * that yet. */ - DRI2SwapBuffers(pDrawable, stuff->x, stuff->y, - stuff->width, stuff->height); - rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; + rep.bitmask = 0; - WriteToClient(client, sizeof(xDRI2SwapBuffersReply), &rep); + WriteToClient(client, sizeof(xDRI2CopyRegionReply), &rep); return client->noClientException; } @@ -297,16 +289,16 @@ ProcDRI2Dispatch (ClientPtr client) switch (stuff->data) { case X_DRI2Connect: return ProcDRI2Connect(client); - case X_DRI2AuthConnection: - return ProcDRI2AuthConnection(client); + case X_DRI2Authenticate: + return ProcDRI2Authenticate(client); case X_DRI2CreateDrawable: return ProcDRI2CreateDrawable(client); case X_DRI2DestroyDrawable: return ProcDRI2DestroyDrawable(client); case X_DRI2GetBuffers: return ProcDRI2GetBuffers(client); - case X_DRI2SwapBuffers: - return ProcDRI2SwapBuffers(client); + case X_DRI2CopyRegion: + return ProcDRI2CopyRegion(client); default: return BadRequest; } @@ -329,7 +321,7 @@ SProcDRI2Connect(ClientPtr client) swaps(&rep.sequenceNumber, n); rep.length = 0; rep.driverNameLength = 0; - rep.busIdLength = 0; + rep.deviceNameLength = 0; return client->noClientException; } |