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