Make GLX context lookup use dixLookupResourceByType()
This commit is contained in:
parent
66539cc05d
commit
30d81ad72e
|
@ -138,6 +138,22 @@ validGlxFBConfigForWindow(ClientPtr client, __GLXconfig *config,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
validGlxContext(ClientPtr client, XID id, int access_mode,
|
||||||
|
__GLXcontext **context, int *err)
|
||||||
|
{
|
||||||
|
*err = dixLookupResourceByType((pointer *) context, id,
|
||||||
|
__glXContextRes, client, access_mode);
|
||||||
|
if (err != Success) {
|
||||||
|
client->errorValue = id;
|
||||||
|
if (*err == BadValue)
|
||||||
|
*err = __glXError(GLXBadContext);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
__glXContextDestroy(__GLXcontext *context)
|
__glXContextDestroy(__GLXcontext *context)
|
||||||
{
|
{
|
||||||
|
@ -189,6 +205,7 @@ DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
__GLXcontext *glxc, *shareglxc;
|
__GLXcontext *glxc, *shareglxc;
|
||||||
|
int err;
|
||||||
|
|
||||||
LEGAL_NEW_RESOURCE(gcId, client);
|
LEGAL_NEW_RESOURCE(gcId, client);
|
||||||
|
|
||||||
|
@ -204,11 +221,10 @@ DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
|
||||||
if (shareList == None) {
|
if (shareList == None) {
|
||||||
shareglxc = 0;
|
shareglxc = 0;
|
||||||
} else {
|
} else {
|
||||||
shareglxc = (__GLXcontext *) LookupIDByType(shareList, __glXContextRes);
|
if (!validGlxContext(client, shareList, DixReadAccess,
|
||||||
if (!shareglxc) {
|
&shareglxc, &err))
|
||||||
client->errorValue = shareList;
|
return err;
|
||||||
return __glXError(GLXBadContext);
|
|
||||||
}
|
|
||||||
if (shareglxc->isDirect) {
|
if (shareglxc->isDirect) {
|
||||||
/*
|
/*
|
||||||
** NOTE: no support for sharing display lists between direct
|
** NOTE: no support for sharing display lists between direct
|
||||||
|
@ -321,25 +337,16 @@ int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
|
||||||
}
|
}
|
||||||
int __glXDisp_DestroyContext(__GLXclientState *cl, GLbyte *pc)
|
int __glXDisp_DestroyContext(__GLXclientState *cl, GLbyte *pc)
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
|
||||||
xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
|
xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
|
||||||
GLXContextID gcId = req->context;
|
|
||||||
__GLXcontext *glxc;
|
__GLXcontext *glxc;
|
||||||
|
int err;
|
||||||
|
|
||||||
glxc = (__GLXcontext *) LookupIDByType(gcId, __glXContextRes);
|
if (!validGlxContext(cl->client, req->context, DixDestroyAccess,
|
||||||
if (glxc) {
|
&glxc, &err))
|
||||||
/*
|
return err;
|
||||||
** Just free the resource; don't actually destroy the context,
|
|
||||||
** because it might be in use. The
|
FreeResourceByType(req->context, __glXContextRes, FALSE);
|
||||||
** destroy method will be called by the resource destruction routine
|
|
||||||
** if necessary.
|
|
||||||
*/
|
|
||||||
FreeResourceByType(gcId, __glXContextRes, FALSE);
|
|
||||||
return Success;
|
return Success;
|
||||||
} else {
|
|
||||||
client->errorValue = gcId;
|
|
||||||
return __glXError(GLXBadContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -528,7 +535,7 @@ DoMakeCurrent(__GLXclientState *cl,
|
||||||
__GLXcontext *glxc, *prevglxc;
|
__GLXcontext *glxc, *prevglxc;
|
||||||
__GLXdrawable *drawPriv = NULL;
|
__GLXdrawable *drawPriv = NULL;
|
||||||
__GLXdrawable *readPriv = NULL;
|
__GLXdrawable *readPriv = NULL;
|
||||||
GLint error;
|
int error;
|
||||||
GLuint mask;
|
GLuint mask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -569,11 +576,8 @@ DoMakeCurrent(__GLXclientState *cl,
|
||||||
if (contextId != None) {
|
if (contextId != None) {
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
glxc = (__GLXcontext *) LookupIDByType(contextId, __glXContextRes);
|
if (!validGlxContext(client, contextId, DixUseAccess, &glxc, &error))
|
||||||
if (!glxc) {
|
return error;
|
||||||
client->errorValue = contextId;
|
|
||||||
return __glXError(GLXBadContext);
|
|
||||||
}
|
|
||||||
if ((glxc != prevglxc) && glxc->isCurrent) {
|
if ((glxc != prevglxc) && glxc->isCurrent) {
|
||||||
/* Context is current to somebody else */
|
/* Context is current to somebody else */
|
||||||
return BadAccess;
|
return BadAccess;
|
||||||
|
@ -702,15 +706,10 @@ int __glXDisp_IsDirect(__GLXclientState *cl, GLbyte *pc)
|
||||||
xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
|
xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
|
||||||
xGLXIsDirectReply reply;
|
xGLXIsDirectReply reply;
|
||||||
__GLXcontext *glxc;
|
__GLXcontext *glxc;
|
||||||
|
int err;
|
||||||
|
|
||||||
/*
|
if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err))
|
||||||
** Find the GL context.
|
return err;
|
||||||
*/
|
|
||||||
glxc = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes);
|
|
||||||
if (!glxc) {
|
|
||||||
client->errorValue = req->context;
|
|
||||||
return __glXError(GLXBadContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
reply.isDirect = glxc->isDirect;
|
reply.isDirect = glxc->isDirect;
|
||||||
reply.length = 0;
|
reply.length = 0;
|
||||||
|
@ -814,19 +813,10 @@ int __glXDisp_CopyContext(__GLXclientState *cl, GLbyte *pc)
|
||||||
__GLXcontext *src, *dst;
|
__GLXcontext *src, *dst;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
/*
|
if (!validGlxContext(cl->client, source, DixReadAccess, &src, &error))
|
||||||
** Check that each context exists.
|
return error;
|
||||||
*/
|
if (!validGlxContext(cl->client, dest, DixWriteAccess, &dst, &error))
|
||||||
src = (__GLXcontext *) LookupIDByType(source, __glXContextRes);
|
return error;
|
||||||
if (!src) {
|
|
||||||
client->errorValue = source;
|
|
||||||
return __glXError(GLXBadContext);
|
|
||||||
}
|
|
||||||
dst = (__GLXcontext *) LookupIDByType(dest, __glXContextRes);
|
|
||||||
if (!dst) {
|
|
||||||
client->errorValue = dest;
|
|
||||||
return __glXError(GLXBadContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** They must be in the same address space, and same screen.
|
** They must be in the same address space, and same screen.
|
||||||
|
@ -1475,12 +1465,10 @@ DoQueryContext(__GLXclientState *cl, GLXContextID gcId)
|
||||||
int nProps;
|
int nProps;
|
||||||
int *sendBuf, *pSendBuf;
|
int *sendBuf, *pSendBuf;
|
||||||
int nReplyBytes;
|
int nReplyBytes;
|
||||||
|
int err;
|
||||||
|
|
||||||
ctx = (__GLXcontext *) LookupIDByType(gcId, __glXContextRes);
|
if (!validGlxContext(cl->client, gcId, DixReadAccess, &ctx, &err))
|
||||||
if (!ctx) {
|
return err;
|
||||||
client->errorValue = gcId;
|
|
||||||
return __glXError(GLXBadContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
nProps = 3;
|
nProps = 3;
|
||||||
reply.length = nProps << 1;
|
reply.length = nProps << 1;
|
||||||
|
|
Loading…
Reference in New Issue