summaryrefslogtreecommitdiff
path: root/src/egl/main
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2009-07-17 11:53:03 -0600
committerBrian Paul <brianp@vmware.com>2009-07-17 11:53:03 -0600
commitcca31340b5a9c0b941946753a31236c7201ca87c (patch)
treecdd0c35eb777b16cd8dcd3d9442d0e9861acc07f /src/egl/main
parent18457cb263e3e062e12314e7b3d5c81a7f2ba048 (diff)
egl: Use the link functions to manage resources.
This commit uses the newly introduced link functions to manage EGL contexts and surfaces. As a result of this, the API for drivers are changed. All drivers are updated for the change. Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Diffstat (limited to 'src/egl/main')
-rw-r--r--src/egl/main/eglcontext.c45
-rw-r--r--src/egl/main/eglcontext.h12
-rw-r--r--src/egl/main/eglglobals.h1
-rw-r--r--src/egl/main/eglscreen.c15
-rw-r--r--src/egl/main/eglsurface.c68
-rw-r--r--src/egl/main/eglsurface.h13
6 files changed, 57 insertions, 97 deletions
diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index edcc6a986f..01cb116d00 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -14,11 +14,9 @@
* in the attrib_list.
*/
EGLBoolean
-_eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx,
- EGLConfig config, const EGLint *attrib_list)
+_eglInitContext(_EGLDriver *drv, _EGLContext *ctx,
+ _EGLConfig *conf, const EGLint *attrib_list)
{
- _EGLConfig *conf;
- _EGLDisplay *display = _eglLookupDisplay(dpy);
EGLint i;
const EGLenum api = eglQueryAPI();
@@ -27,7 +25,6 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx,
return EGL_FALSE;
}
- conf = _eglLookupConfig(drv, dpy, config);
if (!conf) {
_eglError(EGL_BAD_CONFIG, "_eglInitContext");
return EGL_FALSE;
@@ -49,7 +46,6 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx,
}
}
- ctx->Display = display;
ctx->Config = conf;
ctx->DrawSurface = EGL_NO_SURFACE;
ctx->ReadSurface = EGL_NO_SURFACE;
@@ -60,30 +56,6 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx,
/**
- * Save a new _EGLContext into the hash table.
- */
-void
-_eglSaveContext(_EGLContext *ctx)
-{
- /* no-op.
- * Public EGLContext handle and private _EGLContext are the same.
- */
-}
-
-
-/**
- * Remove the given _EGLContext object from the hash table.
- */
-void
-_eglRemoveContext(_EGLContext *ctx)
-{
- /* no-op.
- * Public EGLContext handle and private _EGLContext are the same.
- */
-}
-
-
-/**
* Just a placeholder/demo function. Real driver will never use this!
*/
EGLContext
@@ -92,18 +64,24 @@ _eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
{
#if 0 /* example code */
_EGLContext *context;
+ _EGLConfig *conf;
+
+ conf = _eglLookupConfig(drv, dpy, config);
+ if (!conf) {
+ _eglError(EGL_BAD_CONFIG, "eglCreateContext");
+ return EGL_NO_CONTEXT;
+ }
context = (_EGLContext *) calloc(1, sizeof(_EGLContext));
if (!context)
return EGL_NO_CONTEXT;
- if (!_eglInitContext(drv, dpy, context, config, attrib_list)) {
+ if (!_eglInitContext(drv, context, conf, attrib_list)) {
free(context);
return EGL_NO_CONTEXT;
}
- _eglSaveContext(context);
- return (EGLContext) context;
+ return _eglLinkContext(context, _eglLookupDisplay(dpy));
#endif
return EGL_NO_CONTEXT;
}
@@ -117,6 +95,7 @@ _eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx)
{
_EGLContext *context = _eglLookupContext(ctx);
if (context) {
+ _eglUnlinkContext(context);
if (context->IsBound) {
context->DeletePending = EGL_TRUE;
}
diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h
index 6e418dfbbe..8e20643177 100644
--- a/src/egl/main/eglcontext.h
+++ b/src/egl/main/eglcontext.h
@@ -29,16 +29,8 @@ struct _egl_context
extern EGLBoolean
-_eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx,
- EGLConfig config, const EGLint *attrib_list);
-
-
-extern void
-_eglSaveContext(_EGLContext *ctx);
-
-
-extern void
-_eglRemoveContext(_EGLContext *ctx);
+_eglInitContext(_EGLDriver *drv, _EGLContext *ctx,
+ _EGLConfig *config, const EGLint *attrib_list);
extern EGLContext
diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h
index fbb55c23f0..a9443cfbdd 100644
--- a/src/egl/main/eglglobals.h
+++ b/src/egl/main/eglglobals.h
@@ -13,6 +13,7 @@ struct _egl_global
{
EGLBoolean Initialized;
+ /* these are private to egldisplay.c */
_EGLHashtable *Displays;
_EGLHashtable *Surfaces;
diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c
index 9c9a8377bf..b6bde65e8b 100644
--- a/src/egl/main/eglscreen.c
+++ b/src/egl/main/eglscreen.c
@@ -128,20 +128,25 @@ _eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
{
#if 0 /* THIS IS JUST EXAMPLE CODE */
_EGLSurface *surf;
+ _EGLConfig *conf;
+
+ conf = _eglLookupConfig(drv, dpy, config);
+ if (!conf) {
+ _eglError(EGL_BAD_CONFIG, "eglCreateScreenSurfaceMESA");
+ return EGL_NO_SURFACE;
+ }
surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface));
if (!surf)
return EGL_NO_SURFACE;
- if (!_eglInitSurface(drv, dpy, surf, EGL_SCREEN_BIT_MESA,
- config, attrib_list)) {
+ if (!_eglInitSurface(drv, surf, EGL_SCREEN_BIT_MESA,
+ conf, attrib_list)) {
free(surf);
return EGL_NO_SURFACE;
}
- _eglSaveSurface(surf);
-
- return surf->Handle;
+ return _eglLinkSurface(surf, _eglLookupDisplay(dpy));
#endif
return EGL_NO_SURFACE;
}
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index 854f499fce..b122124585 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -21,12 +21,10 @@
* \return EGL_TRUE if no errors, EGL_FALSE otherwise.
*/
EGLBoolean
-_eglInitSurface(_EGLDriver *drv, EGLDisplay dpy,
- _EGLSurface *surf, EGLint type, EGLConfig config,
- const EGLint *attrib_list)
+_eglInitSurface(_EGLDriver *drv, _EGLSurface *surf, EGLint type,
+ _EGLConfig *conf, const EGLint *attrib_list)
{
const char *func;
- _EGLConfig *conf;
EGLint width = 0, height = 0, largest = 0;
EGLint texFormat = 0, texTarget = 0, mipmapTex = 0;
EGLint renderBuffer = EGL_BACK_BUFFER;
@@ -56,7 +54,6 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy,
return EGL_FALSE;
}
- conf = _eglLookupConfig(drv, dpy, config);
if (!conf) {
_eglError(EGL_BAD_CONFIG, func);
return EGL_FALSE;
@@ -212,26 +209,6 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy,
}
-void
-_eglSaveSurface(_EGLSurface *surf)
-{
- EGLuint key = _eglHashGenKey(_eglGlobal.Surfaces);
- assert(surf);
- assert(!surf->Handle);
- surf->Handle = (EGLSurface) key;
- assert(surf->Handle);
- _eglHashInsert(_eglGlobal.Surfaces, key, surf);
-}
-
-
-void
-_eglRemoveSurface(_EGLSurface *surf)
-{
- _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surf->Handle);
-}
-
-
-
EGLBoolean
_eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw)
{
@@ -340,19 +317,24 @@ _eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
{
#if 0 /* THIS IS JUST EXAMPLE CODE */
_EGLSurface *surf;
+ _EGLConfig *conf;
+
+ conf = _eglLookupConfig(drv, dpy, config);
+ if (!conf) {
+ _eglError(EGL_BAD_CONFIG, "eglCreateWindowSurface");
+ return EGL_NO_SURFACE;
+ }
surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface));
if (!surf)
return EGL_NO_SURFACE;
- if (!_eglInitSurface(drv, dpy, surf, EGL_WINDOW_BIT, config, attrib_list)) {
+ if (!_eglInitSurface(drv, surf, EGL_WINDOW_BIT, conf, attrib_list)) {
free(surf);
return EGL_NO_SURFACE;
}
- _eglSaveSurface(surf);
-
- return surf->Handle;
+ return _eglLinkSurface(surf, _eglLookupDisplay(dpy));
#endif
return EGL_NO_SURFACE;
}
@@ -367,19 +349,24 @@ _eglCreatePixmapSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
{
#if 0 /* THIS IS JUST EXAMPLE CODE */
_EGLSurface *surf;
+ _EGLConfig *conf;
+
+ conf = _eglLookupConfig(drv, dpy, config);
+ if (!conf) {
+ _eglError(EGL_BAD_CONFIG, "eglCreatePixmapSurface");
+ return EGL_NO_SURFACE;
+ }
surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface));
if (!surf)
return EGL_NO_SURFACE;
- if (!_eglInitSurface(drv, dpy, surf, EGL_PIXMAP_BIT, config, attrib_list)) {
+ if (!_eglInitSurface(drv, surf, EGL_PIXMAP_BIT, conf, attrib_list)) {
free(surf);
return EGL_NO_SURFACE;
}
- _eglSaveSurface(surf);
-
- return surf->Handle;
+ return _eglLinkSurface(surf, _eglLookupDisplay(dpy));
#endif
return EGL_NO_SURFACE;
}
@@ -394,19 +381,24 @@ _eglCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
{
#if 0 /* THIS IS JUST EXAMPLE CODE */
_EGLSurface *surf;
+ _EGLConfig *conf;
+
+ conf = _eglLookupConfig(drv, dpy, config);
+ if (!conf) {
+ _eglError(EGL_BAD_CONFIG, "eglCreatePbufferSurface");
+ return EGL_NO_SURFACE;
+ }
surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface));
if (!surf)
return EGL_NO_SURFACE;
- if (!_eglInitSurface(drv, dpy, surf, EGL_PBUFFER_BIT, config, attrib_list)) {
+ if (!_eglInitSurface(drv, surf, EGL_PBUFFER_BIT, conf, attrib_list)) {
free(surf);
return EGL_NO_SURFACE;
}
- _eglSaveSurface(surf);
-
- return surf->Handle;
+ return _eglLinkSurface(surf, _eglLookupDisplay(dpy));
#endif
return EGL_NO_SURFACE;
}
@@ -420,7 +412,7 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
{
_EGLSurface *surf = _eglLookupSurface(surface);
if (surf) {
- _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surface);
+ _eglUnlinkSurface(surf);
if (surf->IsBound) {
surf->DeletePending = EGL_TRUE;
}
diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h
index dc53669091..f6874e6278 100644
--- a/src/egl/main/eglsurface.h
+++ b/src/egl/main/eglsurface.h
@@ -43,17 +43,8 @@ struct _egl_surface
extern EGLBoolean
-_eglInitSurface(_EGLDriver *drv, EGLDisplay dpy,
- _EGLSurface *surf, EGLint type, EGLConfig config,
- const EGLint *attrib_list);
-
-
-extern void
-_eglSaveSurface(_EGLSurface *surf);
-
-
-extern void
-_eglRemoveSurface(_EGLSurface *surf);
+_eglInitSurface(_EGLDriver *drv, _EGLSurface *surf, EGLint type,
+ _EGLConfig *config, const EGLint *attrib_list);
extern EGLBoolean