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 <[email protected]> --- hw/dmx/glxProxy/global.c | 7 -- hw/dmx/glxProxy/glxext.c | 174 +++++++++++--------------------------------- 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 6d4612d..64f434f 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 b469708..027e9e2 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 754ad30..3794860 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[]; - /************************************************************************/ /* -- 1.8.3.1 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
