eliminate the context hash table
In EGL 1.4 the opaque EGLContext type is a pointer so we can just cast between public EGLContext handles and private _EGLContext pointers.
This commit is contained in:
parent
209a557574
commit
5e7dba5412
|
@ -280,10 +280,7 @@ EGLContext EGLAPIENTRY
|
|||
eglGetCurrentContext(void)
|
||||
{
|
||||
_EGLContext *ctx = _eglGetCurrentContext();
|
||||
if (ctx)
|
||||
return ctx->Handle;
|
||||
else
|
||||
return EGL_NO_CONTEXT;
|
||||
return _eglGetContextHandle(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
#include "egldisplay.h"
|
||||
#include "egldriver.h"
|
||||
#include "eglglobals.h"
|
||||
#include "eglhash.h"
|
||||
#include "eglsurface.h"
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the given _EGLContext object to defaults.
|
||||
* Initialize the given _EGLContext object to defaults and/or the values
|
||||
* in the attrib_list.
|
||||
*/
|
||||
EGLBoolean
|
||||
_eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx,
|
||||
|
@ -23,15 +23,17 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx,
|
|||
|
||||
conf = _eglLookupConfig(drv, dpy, config);
|
||||
if (!conf) {
|
||||
_eglError(EGL_BAD_CONFIG, "eglCreateContext");
|
||||
_eglError(EGL_BAD_CONFIG, "_eglInitContext");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
|
||||
switch (attrib_list[i]) {
|
||||
/* no attribs defined for now */
|
||||
case EGL_CONTEXT_CLIENT_VERSION:
|
||||
/* xxx todo */
|
||||
break;
|
||||
default:
|
||||
_eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext");
|
||||
_eglError(EGL_BAD_ATTRIBUTE, "_eglInitContext");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -46,17 +48,15 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Assign an EGLContext handle to the _EGLContext object then put it into
|
||||
* the hash table.
|
||||
/**
|
||||
* Save a new _EGLContext into the hash table.
|
||||
*/
|
||||
void
|
||||
_eglSaveContext(_EGLContext *ctx)
|
||||
{
|
||||
EGLuint key = _eglHashGenKey(_eglGlobal.Contexts);
|
||||
assert(ctx);
|
||||
ctx->Handle = (EGLContext) key;
|
||||
_eglHashInsert(_eglGlobal.Contexts, key, ctx);
|
||||
/* no-op.
|
||||
* Public EGLContext handle and private _EGLContext are the same.
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,21 +66,34 @@ _eglSaveContext(_EGLContext *ctx)
|
|||
void
|
||||
_eglRemoveContext(_EGLContext *ctx)
|
||||
{
|
||||
EGLuint key = (EGLuint) ctx->Handle;
|
||||
_eglHashRemove(_eglGlobal.Contexts, key);
|
||||
/* no-op.
|
||||
* Public EGLContext handle and private _EGLContext are the same.
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the public handle for the given private context ptr.
|
||||
* This is the inverse of _eglLookupContext().
|
||||
*/
|
||||
EGLContext
|
||||
_eglGetContextHandle(_EGLContext *ctx)
|
||||
{
|
||||
/* just a cast! */
|
||||
return (EGLContext) ctx;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the _EGLContext object that corresponds to the given
|
||||
* EGLContext handle.
|
||||
* This is the inverse of _eglGetContextHandle().
|
||||
*/
|
||||
_EGLContext *
|
||||
_eglLookupContext(EGLContext ctx)
|
||||
{
|
||||
EGLuint key = (EGLuint) ctx;
|
||||
_EGLContext *c = (_EGLContext *) _eglHashLookup(_eglGlobal.Contexts, key);
|
||||
return c;
|
||||
/* just a cast since EGLContext is just a void ptr */
|
||||
return (_EGLContext *) ctx;
|
||||
}
|
||||
|
||||
|
||||
|
@ -115,7 +128,7 @@ _eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
|
|||
}
|
||||
|
||||
_eglSaveContext(context);
|
||||
return context->Handle;
|
||||
return (EGLContext) context;
|
||||
#endif
|
||||
return EGL_NO_CONTEXT;
|
||||
}
|
||||
|
@ -129,8 +142,6 @@ _eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx)
|
|||
{
|
||||
_EGLContext *context = _eglLookupContext(ctx);
|
||||
if (context) {
|
||||
EGLuint key = (EGLuint) ctx;
|
||||
_eglHashRemove(_eglGlobal.Contexts, key);
|
||||
if (context->IsBound) {
|
||||
context->DeletePending = EGL_TRUE;
|
||||
}
|
||||
|
@ -243,7 +254,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
|||
ctx = NULL;
|
||||
}
|
||||
/* really delete context now */
|
||||
drv->API.DestroyContext(drv, dpy, oldContext->Handle);
|
||||
drv->API.DestroyContext(drv, dpy, _eglGetContextHandle(oldContext));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
*/
|
||||
struct _egl_context
|
||||
{
|
||||
EGLContext Handle; /* The public/opaque handle which names this object */
|
||||
|
||||
_EGLDisplay *Display; /* who do I belong to? */
|
||||
|
||||
_EGLConfig *Config;
|
||||
|
@ -41,6 +39,10 @@ extern void
|
|||
_eglRemoveContext(_EGLContext *ctx);
|
||||
|
||||
|
||||
extern EGLContext
|
||||
_eglGetContextHandle(_EGLContext *ctx);
|
||||
|
||||
|
||||
extern _EGLContext *
|
||||
_eglLookupContext(EGLContext ctx);
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ _eglInitGlobals(void)
|
|||
{
|
||||
if (!_eglGlobal.Initialized) {
|
||||
_eglGlobal.Displays = _eglNewHashTable();
|
||||
_eglGlobal.Contexts = _eglNewHashTable();
|
||||
_eglGlobal.Surfaces = _eglNewHashTable();
|
||||
_eglGlobal.FreeScreenHandle = 1;
|
||||
_eglGlobal.Initialized = EGL_TRUE;
|
||||
|
@ -37,7 +36,6 @@ _eglDestroyGlobals(void)
|
|||
{
|
||||
/* XXX TODO walk over table entries, deleting each */
|
||||
_eglDeleteHashTable(_eglGlobal.Displays);
|
||||
_eglDeleteHashTable(_eglGlobal.Contexts);
|
||||
_eglDeleteHashTable(_eglGlobal.Surfaces);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ struct _egl_global
|
|||
EGLBoolean Initialized;
|
||||
|
||||
_EGLHashtable *Displays;
|
||||
_EGLHashtable *Contexts;
|
||||
_EGLHashtable *Surfaces;
|
||||
|
||||
EGLScreenMESA FreeScreenHandle;
|
||||
|
|
Loading…
Reference in New Issue