diff options
author | Adam Jackson <ajax@redhat.com> | 2013-07-04 10:43:15 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2013-08-07 05:10:45 -0400 |
commit | d1bad16f8b747480dabc314a3dfd865d353b0201 (patch) | |
tree | 3839df4e3432693c421c5c785e5d18bebb9cac9d | |
parent | 20a828f290f32e040f2f49b537c32dafc8d0cd8b (diff) |
glxproxy: Convert to private-based client tracking
This is mostly to make things look more like glx/.
Note that the currentDrawables and currentContexts tracking is gone from
glx. We can't get rid of them yet in DMX because we're not actually
running with a full GLX under us, so there's not glXGetCurrent* to work
with.
Signed-off-by: Adam Jackson <ajax@redhat.com>
-rw-r--r-- | hw/dmx/glxProxy/global.c | 7 | ||||
-rw-r--r-- | hw/dmx/glxProxy/glxext.c | 174 | ||||
-rw-r--r-- | hw/dmx/glxProxy/glxserver.h | 7 |
3 files changed, 41 insertions, 147 deletions
diff --git a/hw/dmx/glxProxy/global.c b/hw/dmx/glxProxy/global.c index 6d4612deb..64f434f33 100644 --- a/hw/dmx/glxProxy/global.c +++ b/hw/dmx/glxProxy/global.c @@ -40,7 +40,6 @@ __GLXcontext *__glXLastContext; ** X resources. */ RESTYPE __glXContextRes; -RESTYPE __glXClientRes; RESTYPE __glXPixmapRes; RESTYPE __glXWindowRes; RESTYPE __glXPbufferRes; @@ -60,11 +59,5 @@ int __glXBadFBConfig, __glXBadPbuffer; */ xGLXSingleReply __glXReply; -/* -** A set of state for each client. The 0th one is unused because client -** indices start at 1, not 0. -*/ -__GLXclientState *__glXClients[MAXCLIENTS + 1]; - int __glXVersionMajor; int __glXVersionMinor; diff --git a/hw/dmx/glxProxy/glxext.c b/hw/dmx/glxProxy/glxext.c index b46970864..2a787c60c 100644 --- a/hw/dmx/glxProxy/glxext.c +++ b/hw/dmx/glxProxy/glxext.c @@ -47,6 +47,9 @@ #include "extinit.h" #include "glx_extinit.h" +static DevPrivateKeyRec glxClientPrivateKeyRec; +#define glxClientPrivateKey (&glxClientPrivateKeyRec) + /* ** Forward declarations. */ @@ -65,39 +68,9 @@ ResetExtension(ExtensionEntry * extEntry) } /* -** Initialize the per-client context storage. -*/ -static void -ResetClientState(int clientIndex) -{ - __GLXclientState *cl = __glXClients[clientIndex]; - Display **keep_be_displays; - int i; - - free(cl->returnBuf); - free(cl->currentContexts); - free(cl->currentDrawables); - free(cl->largeCmdBuf); - - for (i = 0; i < screenInfo.numScreens; i++) { - if (cl->be_displays[i]) - XCloseDisplay(cl->be_displays[i]); - } - - keep_be_displays = cl->be_displays; - memset(cl, 0, sizeof(__GLXclientState)); - cl->be_displays = keep_be_displays; - - free(cl->GLClientextensions); - - memset(cl->be_displays, 0, screenInfo.numScreens * sizeof(Display *)); -} - -/* ** This procedure is called when the client who created the context goes ** away OR when glXDestroyContext is called. In either case, all we do is ** flag that the ID is no longer valid, and (maybe) free the context. -** use. */ static int ContextGone(__GLXcontext * cx, XID id) @@ -111,40 +84,6 @@ ContextGone(__GLXcontext * cx, XID id) } /* -** Free a client's state. -*/ -static int -ClientGone(int clientIndex, XID id) -{ - __GLXcontext *cx; - __GLXclientState *cl = __glXClients[clientIndex]; - int i; - - if (cl) { - /* - ** Free all the contexts that are current for this client. - */ - for (i = 0; i < cl->numCurrentContexts; i++) { - cx = cl->currentContexts[i]; - if (cx) { - cx->isCurrent = GL_FALSE; - if (!cx->idExists) { - __glXFreeContext(cx); - } - } - } - /* - ** Re-initialize the client state structure. Don't free it because - ** we'll probably get another client with this index and use the struct - ** again. There is a maximum of MAXCLIENTS of these structures. - */ - ResetClientState(clientIndex); - } - - return True; -} - -/* ** Free a GLX Pixmap. */ void @@ -275,6 +214,37 @@ __glXFreeContext(__GLXcontext * cx) return GL_TRUE; } +static __GLXclientState * +glxGetClient(ClientPtr pClient) +{ + return dixLookupPrivate(&pClient->devPrivates, glxClientPrivateKey); +} + +static void +glxClientCallback(CallbackListPtr *list, void *closure, void *data) +{ + NewClientInfoRec *clientInfo = data; + ClientPtr pClient = clientInfo->client; + __GLXclientState *cl = glxGetClient(pClient); + + switch (pClient->clientState) { + case ClientStateRunning: + cl->client = pClient; + break; + + case ClientStateGone: + free(cl->returnBuf); + free(cl->largeCmdBuf); + free(cl->currentContexts); + free(cl->currentDrawables); + free(cl->GLClientextensions); + break; + + default: + break; + } +} + /* ** Initialize the GLX extension. */ @@ -299,8 +269,6 @@ GlxExtensionInit(void) __glXContextRes = CreateNewResourceType((DeleteType) ContextGone, "GLXContext"); - __glXClientRes = CreateNewResourceType((DeleteType) ClientGone, - "GLXClient"); __glXPixmapRes = CreateNewResourceType((DeleteType) PixmapGone, "GLXPixmap"); __glXWindowRes = CreateNewResourceType((DeleteType) WindowGone, @@ -308,10 +276,14 @@ GlxExtensionInit(void) __glXPbufferRes = CreateNewResourceType((DeleteType) PbufferGone, "GLXPbuffer"); - if (!__glXContextRes || !__glXClientRes || !__glXPixmapRes || + if (!__glXContextRes || !__glXPixmapRes || !__glXWindowRes || !__glXPbufferRes) return; + /* XXX client private, */ + if (!AddCallback (&ClientStateCallback, glxClientCallback, 0)) + return; + /* ** Add extension to server extensions. */ @@ -345,13 +317,6 @@ GlxExtensionInit(void) __glXBadPbuffer = extEntry->errorBase + GLXBadPbuffer; /* - ** Initialize table of client state. There is never a client 0. - */ - for (i = 1; i <= MAXCLIENTS; i++) { - __glXClients[i] = 0; - } - - /* ** Initialize screen specific data. */ __glXScreenInit(screenInfo.numScreens); @@ -392,36 +357,7 @@ __glXDispatch(ClientPtr client) __GLXclientState *cl; opcode = stuff->glxCode; - cl = __glXClients[client->index]; - if (!cl) { - cl = calloc(1, sizeof(__GLXclientState)); - __glXClients[client->index] = cl; - if (!cl) { - return BadAlloc; - } - - cl->be_displays = calloc(screenInfo.numScreens, sizeof(Display *)); - if (!cl->be_displays) { - free(cl); - return BadAlloc; - } - } - - if (!cl->inUse) { - /* - ** This is first request from this client. Associate a resource - ** with the client so we will be notified when the client dies. - */ - XID xid = FakeClientID(client->index); - - if (!AddResource(xid, __glXClientRes, (pointer) (long) client->index)) { - return BadAlloc; - } - ResetClientState(client->index); - cl->largeCmdRequestsTotal = 0; - cl->inUse = GL_TRUE; - cl->client = client; - } + cl = glxGetClient(client); /* ** Check for valid opcode. @@ -446,35 +382,7 @@ __glXSwapDispatch(ClientPtr client) __GLXclientState *cl; opcode = stuff->glxCode; - cl = __glXClients[client->index]; - if (!cl) { - cl = calloc(1, sizeof(__GLXclientState)); - __glXClients[client->index] = cl; - if (!cl) { - return BadAlloc; - } - - cl->be_displays = calloc(screenInfo.numScreens, sizeof(Display *)); - if (!cl->be_displays) { - free(cl); - return BadAlloc; - } - } - - if (!cl->inUse) { - /* - ** This is first request from this client. Associate a resource - ** with the client so we will be notified when the client dies. - */ - XID xid = FakeClientID(client->index); - - if (!AddResource(xid, __glXClientRes, (pointer) (long) client->index)) { - return BadAlloc; - } - ResetClientState(client->index); - cl->inUse = GL_TRUE; - cl->client = client; - } + cl = glxGetClient(client); /* ** Check for valid opcode. diff --git a/hw/dmx/glxProxy/glxserver.h b/hw/dmx/glxProxy/glxserver.h index 754ad30a0..3794860ae 100644 --- a/hw/dmx/glxProxy/glxserver.h +++ b/hw/dmx/glxProxy/glxserver.h @@ -98,11 +98,6 @@ typedef struct { */ struct __GLXclientStateRec { /* - ** Whether this structure is currently being used to support a client. - */ - Bool inUse; - - /* ** Buffer for returned data. */ GLbyte *returnBuf; @@ -139,8 +134,6 @@ struct __GLXclientStateRec { }; -extern __GLXclientState *__glXClients[]; - /************************************************************************/ /* |