diff options
author | Chia-I Wu <[email protected]> | 2009-07-17 11:53:03 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-07-17 11:53:03 -0600 |
commit | cca31340b5a9c0b941946753a31236c7201ca87c (patch) | |
tree | cdd0c35eb777b16cd8dcd3d9442d0e9861acc07f /src | |
parent | 18457cb263e3e062e12314e7b3d5c81a7f2ba048 (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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/drivers/demo/demo.c | 17 | ||||
-rw-r--r-- | src/egl/drivers/dri/egldri.c | 33 | ||||
-rw-r--r-- | src/egl/drivers/glx/egl_glx.c | 42 | ||||
-rw-r--r-- | src/egl/drivers/xdri/egl_xdri.c | 19 | ||||
-rw-r--r-- | src/egl/main/eglcontext.c | 45 | ||||
-rw-r--r-- | src/egl/main/eglcontext.h | 12 | ||||
-rw-r--r-- | src/egl/main/eglglobals.h | 1 | ||||
-rw-r--r-- | src/egl/main/eglscreen.c | 15 | ||||
-rw-r--r-- | src/egl/main/eglsurface.c | 68 | ||||
-rw-r--r-- | src/egl/main/eglsurface.h | 13 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/egl_context.c | 8 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/egl_surface.c | 7 | ||||
-rw-r--r-- | src/gallium/winsys/egl_xlib/egl_xlib.c | 13 | ||||
-rw-r--r-- | src/mesa/drivers/dri/fb/fb_egl.c | 10 |
14 files changed, 143 insertions, 160 deletions
diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c index 1750e976b84..fa9efa5d355 100644 --- a/src/egl/drivers/demo/demo.c +++ b/src/egl/drivers/demo/demo.c @@ -146,12 +146,12 @@ demoCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext if (!c) return EGL_NO_CONTEXT; - _eglInitContext(drv, dpy, &c->Base, config, attrib_list); + _eglInitContext(drv, &c->Base, conf, attrib_list); c->DemoStuff = 1; printf("demoCreateContext\n"); - /* generate handle and insert into hash table */ - _eglSaveContext(&c->Base); + /* link to display */ + _eglLinkContext(&c->Base, _eglLookupDisplay(dpy)); assert(_eglGetContextHandle(&c->Base)); return _eglGetContextHandle(&c->Base); @@ -213,11 +213,14 @@ demoCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) { DemoSurface *surf = (DemoSurface *) calloc(1, sizeof(DemoSurface)); + _EGLConfig *conf; + if (!surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &surf->Base, EGL_PBUFFER_BIT, - config, attrib_list)) { + conf = _eglLookupConfig(drv, dpy, config); + if (!_eglInitSurface(drv, &surf->Base, EGL_PBUFFER_BIT, + conf, attrib_list)) { free(surf); return EGL_NO_SURFACE; } @@ -232,7 +235,7 @@ static EGLBoolean demoDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { DemoSurface *fs = LookupDemoSurface(surface); - _eglRemoveSurface(&fs->Base); + _eglUnlinkSurface(&fs->Base); if (fs->Base.IsBound) { fs->Base.DeletePending = EGL_TRUE; } @@ -247,7 +250,7 @@ static EGLBoolean demoDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) { DemoContext *fc = LookupDemoContext(context); - _eglRemoveContext(&fc->Base); + _eglUnlinkContext(&fc->Base); if (fc->Base.IsBound) { fc->Base.DeletePending = EGL_TRUE; } diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index 57661cc3ab8..df45fbfbe2f 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -171,7 +171,10 @@ _eglDRICreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!c) return EGL_NO_CONTEXT; - if (!_eglInitContext(drv, dpy, &c->Base, config, attrib_list)) { + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); + + if (!_eglInitContext(drv, &c->Base, conf, attrib_list)) { free(c); return EGL_NO_CONTEXT; } @@ -189,8 +192,6 @@ _eglDRICreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, else sharePriv = NULL; - conf = _eglLookupConfig(drv, dpy, config); - assert(conf); _eglConfigToContextModesRec(conf, &visMode); c->driContext.private = disp->driScreen.createNewContext(disp, &visMode, @@ -200,8 +201,8 @@ _eglDRICreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, return EGL_FALSE; } - /* generate handle and insert into hash table */ - _eglSaveContext(&c->Base); + /* link to display */ + _eglLinkContext(&c->Base, &disp->Base); return _eglGetContextHandle(&c->Base); } @@ -237,14 +238,18 @@ _eglDRICreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) { driSurface *surf; + _EGLConfig *conf; + + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); surf = (driSurface *) calloc(1, sizeof(*surf)); if (!surf) { return EGL_NO_SURFACE; } - if (!_eglInitSurface(drv, dpy, &surf->Base, EGL_PBUFFER_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &surf->Base, EGL_PBUFFER_BIT, + conf, attrib_list)) { free(surf); return EGL_NO_SURFACE; } @@ -275,7 +280,7 @@ _eglDRICreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, #endif } - _eglSaveSurface(&surf->Base); + _eglLinkSurface(&surf->Base, _eglLookupDisplay(dpy)); return surf->Base.Handle; } @@ -287,7 +292,7 @@ _eglDRIDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) driDisplay *disp = Lookup_driDisplay(dpy); driSurface *fs = Lookup_driSurface(surface); - _eglRemoveSurface(&fs->Base); + _eglUnlinkSurface(&fs->Base); fs->drawable.destroyDrawable(disp, fs->drawable.private); @@ -307,7 +312,7 @@ _eglDRIDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) driDisplay *disp = Lookup_driDisplay(dpy); driContext *fc = Lookup_driContext(context); - _eglRemoveContext(&fc->Base); + _eglUnlinkContext(&fc->Base); fc->driContext.destroyContext(disp, 0, fc->driContext.private); @@ -340,13 +345,13 @@ _eglDRICreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, } /* init base class, do error checking, etc. */ - if (!_eglInitSurface(drv, dpy, &surface->Base, EGL_SCREEN_BIT_MESA, - cfg, attrib_list)) { + if (!_eglInitSurface(drv, &surface->Base, EGL_SCREEN_BIT_MESA, + config, attrib_list)) { free(surface); return EGL_NO_SURFACE; } - _eglSaveSurface(&surface->Base); + _eglLinkSurface(&surface->Base &disp->Base); /* @@ -363,7 +368,7 @@ _eglDRICreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, if (!disp->driScreen.createNewDrawable(disp, &visMode, drawBuf, &surface->drawable, GLX_WINDOW_BIT, empty_attribute_list)) { - _eglRemoveSurface(&surface->Base); + _eglUnlinkSurface(&surface->Base); free(surface); return EGL_NO_SURFACE; } diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 155caa413c8..661b313ae2d 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -532,7 +532,10 @@ GLX_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!GLX_ctx) return EGL_NO_CONTEXT; - if (!_eglInitContext(drv, dpy, &GLX_ctx->Base, config, attrib_list)) { + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); + + if (!_eglInitContext(drv, &GLX_ctx->Base, conf, attrib_list)) { free(GLX_ctx); return EGL_NO_CONTEXT; } @@ -546,9 +549,6 @@ GLX_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, GLX_ctx_shared = GLX_egl_context(shareCtx); } - conf = _eglLookupConfig(drv, dpy, config); - assert(conf); - #ifdef GLX_VERSION_1_3 if (GLX_drv->fbconfigs) GLX_ctx->context = glXCreateNewContext(disp->Xdpy, GLX_drv->fbconfigs[(int)config-1], GLX_RGBA_TYPE, GLX_ctx_shared ? GLX_ctx_shared->context : NULL, GL_TRUE); @@ -564,7 +564,7 @@ GLX_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, return EGL_FALSE; #endif - return _eglGetContextHandle(&GLX_ctx->Base); + return _eglLinkContext(&GLX_ctx->Base, disp); } @@ -619,18 +619,22 @@ GLX_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, _EGLDisplay *disp = _eglLookupDisplay(dpy); struct GLX_egl_surface *GLX_surf; uint width, height; + _EGLConfig *conf; + + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); GLX_surf = CALLOC_STRUCT(GLX_egl_surface); if (!GLX_surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &GLX_surf->Base, EGL_WINDOW_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &GLX_surf->Base, EGL_WINDOW_BIT, + conf, attrib_list)) { free(GLX_surf); return EGL_FALSE; } - _eglSaveSurface(&GLX_surf->Base); + _eglLinkSurface(&GLX_surf->Base, disp); GLX_surf->drawable = window; get_drawable_size(disp->Xdpy, window, &width, &height); @@ -648,19 +652,23 @@ GLX_eglCreatePixmapSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv); _EGLDisplay *disp = _eglLookupDisplay(dpy); struct GLX_egl_surface *GLX_surf; + _EGLConfig *conf; int i; + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); + GLX_surf = CALLOC_STRUCT(GLX_egl_surface); if (!GLX_surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &GLX_surf->Base, EGL_PIXMAP_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &GLX_surf->Base, EGL_PIXMAP_BIT, + conf, attrib_list)) { free(GLX_surf); return EGL_FALSE; } - _eglSaveSurface(&GLX_surf->Base); + _eglLinkSurface(&GLX_surf->Base, disp); for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { switch (attrib_list[i]) { @@ -683,20 +691,24 @@ GLX_eglCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv); _EGLDisplay *disp = _eglLookupDisplay(dpy); struct GLX_egl_surface *GLX_surf; + _EGLConfig *conf; int attribs[5]; int i = 0, j = 0; + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); + GLX_surf = CALLOC_STRUCT(GLX_egl_surface); if (!GLX_surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &GLX_surf->Base, EGL_PBUFFER_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &GLX_surf->Base, EGL_PBUFFER_BIT, + conf, attrib_list)) { free(GLX_surf); return EGL_NO_SURFACE; } - _eglSaveSurface(&GLX_surf->Base); + _eglLinkSurface(&GLX_surf->Base, disp); while(attrib_list[i] != EGL_NONE) { switch (attrib_list[i]) { @@ -726,7 +738,7 @@ GLX_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) _EGLSurface *surf = _eglLookupSurface(surface); return EGL_TRUE; if (surf) { - _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surface); + _eglUnlinkSurface(surf); if (surf->IsBound) { surf->DeletePending = EGL_TRUE; } diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 3b3e312746e..34d69def6a5 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -770,7 +770,7 @@ xdri_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!xdri_ctx) return EGL_NO_CONTEXT; - if (!_eglInitContext(drv, dpy, &xdri_ctx->Base, config, attrib_list)) { + if (!_eglInitContext(drv, &xdri_ctx->Base, &xdri_config->Base, attrib_list)) { free(xdri_ctx); return EGL_NO_CONTEXT; } @@ -794,7 +794,7 @@ xdri_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, xdri_ctx->driContext.mode = xdri_config->mode; - return _eglGetContextHandle(&xdri_ctx->Base); + return _eglLinkContext(&xdri_ctx->Base, &disp); } @@ -835,6 +835,7 @@ xdri_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list) { _EGLDisplay *disp = _eglLookupDisplay(dpy); + struct xdri_egl_config *xdri_config = lookup_config(drv, dpy, config); struct xdri_egl_surface *xdri_surf; int scrn = DefaultScreen(disp->Xdpy); uint width, height; @@ -843,8 +844,8 @@ xdri_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!xdri_surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &xdri_surf->Base, EGL_WINDOW_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &xdri_surf->Base, EGL_WINDOW_BIT, + &xdri_config->Base, attrib_list)) { free(xdri_surf); return EGL_FALSE; } @@ -856,7 +857,7 @@ xdri_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, xdri_surf->driDrawable = window; - _eglSaveSurface(&xdri_surf->Base); + _eglLinkSurface(&xdri_surf->Base, disp); get_drawable_size(disp->Xdpy, window, &width, &height); xdri_surf->Base.Width = width; @@ -888,8 +889,8 @@ xdri_eglCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!xdri_surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &xdri_surf->Base, EGL_PBUFFER_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &xdri_surf->Base, EGL_PBUFFER_BIT, + &xdri_config->Base, attrib_list)) { free(xdri_surf); return EGL_FALSE; } @@ -939,7 +940,7 @@ xdri_eglCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, xdri_surf->driDrawable = window; - _eglSaveSurface(&xdri_surf->Base); + _eglLinkSurface(&xdri_surf->Base, disp); _eglLog(_EGL_DEBUG, "XDRI: CreatePbufferSurface handle %d hDrawable %d", @@ -956,7 +957,7 @@ xdri_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { struct xdri_egl_surface *xdri_surf = lookup_surface(surface); if (xdri_surf) { - _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surface); + _eglUnlinkSurface(&xdri_surf->Base); if (xdri_surf->Base.IsBound) { xdri_surf->Base.DeletePending = EGL_TRUE; } diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index edcc6a986fe..01cb116d00e 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 6e418dfbbe6..8e206431770 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 fbb55c23f00..a9443cfbdd8 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 9c9a8377bf2..b6bde65e8b5 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 854f499fce2..b1221245856 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 dc536690910..f6874e62784 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 diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c index edd49486e5b..95dfcb9983c 100644 --- a/src/gallium/state_trackers/egl/egl_context.c +++ b/src/gallium/state_trackers/egl/egl_context.c @@ -113,7 +113,7 @@ drm_create_context(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext if (!ctx) goto err_c; - _eglInitContext(drv, dpy, &ctx->base, config, attrib_list); + _eglInitContext(drv, dpy, &ctx->base, conf, attrib_list); ctx->pipe = dev->api->create_context(dev->api, dev->screen); if (!ctx->pipe) @@ -129,8 +129,8 @@ drm_create_context(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext if (!ctx->st) goto err_gl; - /* generate handle and insert into hash table */ - _eglSaveContext(&ctx->base); + /* link to display */ + _eglLinkContext(&ctx->base, _eglLookupDisplay(dpy)); assert(_eglGetContextHandle(&ctx->base)); return _eglGetContextHandle(&ctx->base); @@ -147,7 +147,7 @@ EGLBoolean drm_destroy_context(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) { struct drm_context *c = lookup_drm_context(context); - _eglRemoveContext(&c->base); + _eglUnlinkContext(&c->base); if (c->base.IsBound) { c->base.DeletePending = EGL_TRUE; } else { diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c index de8194a46af..27b35052d1c 100644 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ b/src/gallium/state_trackers/egl/egl_surface.c @@ -232,7 +232,7 @@ drm_create_pbuffer_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!surf) goto err; - if (!_eglInitSurface(drv, dpy, &surf->base, EGL_PBUFFER_BIT, config, attrib_list)) + if (!_eglInitSurface(drv, &surf->base, EGL_PBUFFER_BIT, conf, attrib_list)) goto err_surf; surf->w = width; @@ -245,7 +245,7 @@ drm_create_pbuffer_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, (void*)surf); drm_visual_modes_destroy(visual); - _eglSaveSurface(&surf->base); + _eglLinkSurface(&surf->base, _eglLookupDisplay(dpy)); return surf->base.Handle; err_surf: @@ -364,7 +364,8 @@ EGLBoolean drm_destroy_surface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { struct drm_surface *surf = lookup_drm_surface(surface); - _eglRemoveSurface(&surf->base); + _eglUnlinkSurface(&surf->base); + if (surf->base.IsBound) { surf->base.DeletePending = EGL_TRUE; } else { diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c index c10e3c00ffc..9914dff9643 100644 --- a/src/gallium/winsys/egl_xlib/egl_xlib.c +++ b/src/gallium/winsys/egl_xlib/egl_xlib.c @@ -345,7 +345,7 @@ xlib_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, return EGL_NO_CONTEXT; /* let EGL lib init the common stuff */ - if (!_eglInitContext(drv, dpy, &ctx->Base, config, attrib_list)) { + if (!_eglInitContext(drv, &ctx->Base, conf, attrib_list)) { free(ctx); return EGL_NO_CONTEXT; } @@ -370,7 +370,7 @@ xlib_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, return EGL_NO_CONTEXT; } - _eglSaveContext(&ctx->Base); + _eglLinkContext(&ctx->Base, _eglLookupDisplay(dpy)); return _eglGetContextHandle(&ctx->Base); } @@ -381,6 +381,7 @@ xlib_eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx) { struct xlib_egl_context *context = lookup_context(ctx); if (context) { + _eglUnlinkContext(&context->Base); if (context->Base.IsBound) { context->Base.DeletePending = EGL_TRUE; } @@ -491,13 +492,13 @@ xlib_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, return EGL_NO_SURFACE; /* Let EGL lib init the common stuff */ - if (!_eglInitSurface(drv, dpy, &surf->Base, EGL_WINDOW_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &surf->Base, EGL_WINDOW_BIT, + conf, attrib_list)) { free(surf); return EGL_NO_SURFACE; } - _eglSaveSurface(&surf->Base); + _eglLinkSurface(&surf->Base, disp); /* * Now init the Xlib and gallium stuff @@ -534,7 +535,7 @@ xlib_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { struct xlib_egl_surface *surf = lookup_surface(surface); if (surf) { - _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surface); + _eglUnlinkSurface(&surf->Base); if (surf->Base.IsBound) { surf->Base.DeletePending = EGL_TRUE; } diff --git a/src/mesa/drivers/dri/fb/fb_egl.c b/src/mesa/drivers/dri/fb/fb_egl.c index 35c268441c3..c367741f52c 100644 --- a/src/mesa/drivers/dri/fb/fb_egl.c +++ b/src/mesa/drivers/dri/fb/fb_egl.c @@ -472,8 +472,8 @@ fbCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext sh c->Base.DrawSurface = EGL_NO_SURFACE; c->Base.ReadSurface = EGL_NO_SURFACE; - /* generate handle and insert into hash table */ - _eglSaveContext(&c->Base); + /* link to display */ + _eglLinkContext(&c->Base, disp); assert(c->Base.Handle); /* Init default driver functions then plug in our FBdev-specific functions @@ -604,7 +604,7 @@ static EGLBoolean fbDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { fbSurface *fs = Lookup_fbSurface(surface); - _eglRemoveSurface(&fs->Base); + _eglUnlinkSurface(&fs->Base); if (fs->Base.IsBound) { fs->Base.DeletePending = EGL_TRUE; } @@ -619,7 +619,7 @@ static EGLBoolean fbDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) { fbContext *fc = Lookup_fbContext(context); - _eglRemoveContext(&fc->Base); + _eglUnlinkContext(&fc->Base); if (fc->Base.IsBound) { fc->Base.DeletePending = EGL_TRUE; } @@ -688,7 +688,7 @@ fbCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, surface->mesa_framebuffer = _mesa_create_framebuffer(&vis); if (!surface->mesa_framebuffer) { free(surface); - _eglRemoveSurface(&surface->Base); + _eglUnlinkSurface(&surface->Base); return EGL_NO_SURFACE; } |