diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2008-05-27 14:21:25 -0600 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2008-05-27 14:21:25 -0600 |
commit | 5e7dba541298a29f175f9d077bf6f63030465d94 (patch) | |
tree | aceb7df27599a1f3e0eb8ed0da365cc47e3039ca /src | |
parent | 209a557574b9833da3d6ac299c83f4cddfff6910 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/main/eglapi.c | 5 | ||||
-rw-r--r-- | src/egl/main/eglcontext.c | 53 | ||||
-rw-r--r-- | src/egl/main/eglcontext.h | 6 | ||||
-rw-r--r-- | src/egl/main/eglglobals.c | 2 | ||||
-rw-r--r-- | src/egl/main/eglglobals.h | 1 |
5 files changed, 37 insertions, 30 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index f9b3f5921a..c57d29dda6 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -280,10 +280,7 @@ EGLContext EGLAPIENTRY eglGetCurrentContext(void) { _EGLContext *ctx = _eglGetCurrentContext(); - if (ctx) - return ctx->Handle; - else - return EGL_NO_CONTEXT; + return _eglGetContextHandle(ctx); } diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index bf26c1faa4..86d1d84334 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -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)); } } diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 82bfde151f..093f65fbfb 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -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); diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 608311d749..4bdc0329bf 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -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); } diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index c16baa2d6b..4fccd226b7 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -24,7 +24,6 @@ struct _egl_global EGLBoolean Initialized; _EGLHashtable *Displays; - _EGLHashtable *Contexts; _EGLHashtable *Surfaces; EGLScreenMESA FreeScreenHandle; |