mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 02:28:10 +02:00
egl: Replace IsBound by a pointer to the binding.
IsBound tells if a context or surface is current. What it does not tell is, to which thread a context is current, or to which context a surface is current. This commit replaces IsBound by a pointer to the binding thread or context. Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
This commit is contained in:
parent
27148ccaba
commit
07ee01365a
12 changed files with 49 additions and 27 deletions
|
|
@ -236,7 +236,7 @@ demoDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
{
|
||||
DemoSurface *fs = LookupDemoSurface(surface);
|
||||
_eglUnlinkSurface(&fs->Base);
|
||||
if (!fs->Base.IsBound)
|
||||
if (!_eglIsSurfaceBound(&fs->Base))
|
||||
free(fs);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
@ -247,7 +247,7 @@ demoDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context)
|
|||
{
|
||||
DemoContext *fc = LookupDemoContext(context);
|
||||
_eglUnlinkContext(&fc->Base);
|
||||
if (!fc->Base.IsBound)
|
||||
if (!_eglIsContextBound(&fc->Base))
|
||||
free(fc);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ _eglDRIDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
|
||||
fs->drawable.destroyDrawable(disp, fs->drawable.private);
|
||||
|
||||
if (!fs->Base.IsBound)
|
||||
if (!_eglIsSurfaceBound(&fs->Base))
|
||||
free(fs);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
@ -312,7 +312,7 @@ _eglDRIDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context)
|
|||
|
||||
fc->driContext.destroyContext(disp, 0, fc->driContext.private);
|
||||
|
||||
if (!fc->Base.IsBound)
|
||||
if (!_eglIsContextBound(&fc->Base))
|
||||
free(fc);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -739,7 +739,7 @@ GLX_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
return EGL_TRUE;
|
||||
if (surf) {
|
||||
_eglUnlinkSurface(surf);
|
||||
if (!surf->IsBound)
|
||||
if (!_eglIsSurfaceBound(surf))
|
||||
free(surf);
|
||||
|
||||
return EGL_TRUE;
|
||||
|
|
|
|||
|
|
@ -958,7 +958,7 @@ xdri_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
struct xdri_egl_surface *xdri_surf = lookup_surface(surface);
|
||||
if (xdri_surf) {
|
||||
_eglUnlinkSurface(&xdri_surf->Base);
|
||||
if (!xdri_surf->Base.IsBound) {
|
||||
if (!_eglIsSurfaceBound(&xdri_surf->Base)) {
|
||||
/*
|
||||
st_unreference_framebuffer(surf->Framebuffer);
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ _eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx)
|
|||
_EGLContext *context = _eglLookupContext(ctx);
|
||||
if (context) {
|
||||
_eglUnlinkContext(context);
|
||||
if (!context->IsBound)
|
||||
if (!_eglIsContextBound(context))
|
||||
free(context);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
@ -207,7 +207,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
|||
* check if the old context or surfaces need to be deleted
|
||||
*/
|
||||
if (oldDrawSurface != NULL) {
|
||||
oldDrawSurface->IsBound = EGL_FALSE;
|
||||
oldDrawSurface->Binding = NULL;
|
||||
if (!_eglIsSurfaceLinked(oldDrawSurface)) {
|
||||
/* make sure we don't try to rebind a deleted surface */
|
||||
if (draw == oldDrawSurface || draw == oldReadSurface) {
|
||||
|
|
@ -218,7 +218,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
|||
}
|
||||
}
|
||||
if (oldReadSurface != NULL && oldReadSurface != oldDrawSurface) {
|
||||
oldReadSurface->IsBound = EGL_FALSE;
|
||||
oldReadSurface->Binding = NULL;
|
||||
if (!_eglIsSurfaceLinked(oldReadSurface)) {
|
||||
/* make sure we don't try to rebind a deleted surface */
|
||||
if (read == oldDrawSurface || read == oldReadSurface) {
|
||||
|
|
@ -229,7 +229,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
|||
}
|
||||
}
|
||||
if (oldContext != NULL) {
|
||||
oldContext->IsBound = EGL_FALSE;
|
||||
oldContext->Binding = NULL;
|
||||
if (!_eglIsContextLinked(oldContext)) {
|
||||
/* make sure we don't try to rebind a deleted context */
|
||||
if (ctx == oldContext) {
|
||||
|
|
@ -248,9 +248,9 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
|||
}
|
||||
ctx->DrawSurface = draw;
|
||||
ctx->ReadSurface = read;
|
||||
ctx->IsBound = EGL_TRUE;
|
||||
draw->IsBound = EGL_TRUE;
|
||||
read->IsBound = EGL_TRUE;
|
||||
ctx->Binding = t;
|
||||
draw->Binding = ctx;
|
||||
read->Binding = ctx;
|
||||
t->CurrentContexts[apiIndex] = ctx;
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ struct _egl_context
|
|||
_EGLDisplay *Display;
|
||||
_EGLContext *Next;
|
||||
|
||||
_EGLConfig *Config;
|
||||
|
||||
/* The bound status of the context */
|
||||
_EGLThreadInfo *Binding;
|
||||
_EGLSurface *DrawSurface;
|
||||
_EGLSurface *ReadSurface;
|
||||
|
||||
EGLBoolean IsBound;
|
||||
_EGLConfig *Config;
|
||||
|
||||
EGLint ClientAPI; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API */
|
||||
EGLint ClientVersion; /**< 1 = OpenGLES 1.x, 2 = OpenGLES 2.x */
|
||||
|
|
@ -51,4 +51,15 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface rea
|
|||
extern EGLBoolean
|
||||
_eglCopyContextMESA(_EGLDriver *drv, EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask);
|
||||
|
||||
|
||||
/**
|
||||
* Return true if the context is bound to a thread.
|
||||
*/
|
||||
static INLINE EGLBoolean
|
||||
_eglIsContextBound(_EGLContext *ctx)
|
||||
{
|
||||
return (ctx->Binding != NULL);
|
||||
}
|
||||
|
||||
|
||||
#endif /* EGLCONTEXT_INCLUDED */
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
_EGLSurface *surf = _eglLookupSurface(surface);
|
||||
if (surf) {
|
||||
_eglUnlinkSurface(surf);
|
||||
if (!surf->IsBound)
|
||||
if (!_eglIsSurfaceBound(surf))
|
||||
free(surf);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ struct _egl_surface
|
|||
_EGLSurface *Next;
|
||||
EGLSurface Handle;
|
||||
|
||||
_EGLConfig *Config;
|
||||
|
||||
/* May need reference counting here */
|
||||
EGLBoolean IsBound;
|
||||
/* The bound status of the surface */
|
||||
_EGLContext *Binding;
|
||||
EGLBoolean BoundToTexture;
|
||||
|
||||
_EGLConfig *Config;
|
||||
|
||||
EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */
|
||||
EGLint Width, Height;
|
||||
EGLint TextureFormat, TextureTarget;
|
||||
|
|
@ -100,5 +100,16 @@ _eglCreatePbufferFromClientBuffer(_EGLDriver *drv, EGLDisplay dpy,
|
|||
#endif /* EGL_VERSION_1_2 */
|
||||
|
||||
|
||||
/**
|
||||
* Return true if the surface is bound to a thread.
|
||||
* A surface bound to a texutre is not considered bound by
|
||||
* this function.
|
||||
*/
|
||||
static INLINE EGLBoolean
|
||||
_eglIsSurfaceBound(_EGLSurface *surf)
|
||||
{
|
||||
return (surf->Binding != NULL);
|
||||
}
|
||||
|
||||
|
||||
#endif /* EGLSURFACE_INCLUDED */
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ drm_destroy_context(_EGLDriver *drv, EGLDisplay dpy, EGLContext context)
|
|||
{
|
||||
struct drm_context *c = lookup_drm_context(context);
|
||||
_eglUnlinkContext(&c->base);
|
||||
if (!c->base.IsBound) {
|
||||
if (!_eglIsContextBound(&c->base)) {
|
||||
st_destroy_context(c->st);
|
||||
c->pipe->destroy(c->pipe);
|
||||
free(c);
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ drm_destroy_surface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
struct drm_surface *surf = lookup_drm_surface(surface);
|
||||
_eglUnlinkSurface(&surf->base);
|
||||
|
||||
if (!surf->base.IsBound) {
|
||||
if (!_eglIsSurfaceBound(&surf->base)) {
|
||||
if (surf->screen)
|
||||
drm_takedown_shown_screen(drv, surf->screen);
|
||||
st_unreference_framebuffer(surf->stfb);
|
||||
|
|
|
|||
|
|
@ -382,7 +382,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) {
|
||||
if (!_eglIsContextBound(&context->Base)) {
|
||||
/* API-dependent clean-up */
|
||||
switch (context->Base.ClientAPI) {
|
||||
case EGL_OPENGL_ES_API:
|
||||
|
|
@ -533,7 +533,7 @@ xlib_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
struct xlib_egl_surface *surf = lookup_surface(surface);
|
||||
if (surf) {
|
||||
_eglUnlinkSurface(&surf->Base);
|
||||
if (!surf->Base.IsBound) {
|
||||
if (!_eglIsSurfaceBound(&surf->Base)) {
|
||||
XFreeGC(surf->Dpy, surf->Gc);
|
||||
st_unreference_framebuffer(surf->Framebuffer);
|
||||
free(surf);
|
||||
|
|
|
|||
|
|
@ -605,7 +605,7 @@ fbDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
{
|
||||
fbSurface *fs = Lookup_fbSurface(surface);
|
||||
_eglUnlinkSurface(&fs->Base);
|
||||
if (!fs->Base.IsBound)
|
||||
if (!_eglIsSurfaceBound(&fs->Base))
|
||||
free(fs);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
@ -616,7 +616,7 @@ fbDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context)
|
|||
{
|
||||
fbContext *fc = Lookup_fbContext(context);
|
||||
_eglUnlinkContext(&fc->Base);
|
||||
if (!fc->Base.IsBound)
|
||||
if (!_eglIsContextBound(&fc->Base))
|
||||
free(fc);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue