summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2009-08-03 11:34:37 -0600
committerBrian Paul <brianp@vmware.com>2009-08-03 11:34:37 -0600
commit07ee01365a8bddf6f50821ecd585784498a25ff0 (patch)
tree2d788bcf6cc919b85698080f7e0a8cf447feff59
parent27148ccaba9ceee44a3d9fb4649f4a953b3062a7 (diff)
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>
-rw-r--r--src/egl/drivers/demo/demo.c4
-rw-r--r--src/egl/drivers/dri/egldri.c4
-rw-r--r--src/egl/drivers/glx/egl_glx.c2
-rw-r--r--src/egl/drivers/xdri/egl_xdri.c2
-rw-r--r--src/egl/main/eglcontext.c14
-rw-r--r--src/egl/main/eglcontext.h17
-rw-r--r--src/egl/main/eglsurface.c2
-rw-r--r--src/egl/main/eglsurface.h19
-rw-r--r--src/gallium/state_trackers/egl/egl_context.c2
-rw-r--r--src/gallium/state_trackers/egl/egl_surface.c2
-rw-r--r--src/gallium/winsys/egl_xlib/egl_xlib.c4
-rw-r--r--src/mesa/drivers/dri/fb/fb_egl.c4
12 files changed, 49 insertions, 27 deletions
diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c
index f316974d83..e8c0c1df5e 100644
--- a/src/egl/drivers/demo/demo.c
+++ b/src/egl/drivers/demo/demo.c
@@ -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;
}
diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c
index 3f9617a8f9..9e400be624 100644
--- a/src/egl/drivers/dri/egldri.c
+++ b/src/egl/drivers/dri/egldri.c
@@ -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;
}
diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c
index 207b1ea779..5ed4b6883f 100644
--- a/src/egl/drivers/glx/egl_glx.c
+++ b/src/egl/drivers/glx/egl_glx.c
@@ -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;
diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c
index e040efdd43..d8d29fcef4 100644
--- a/src/egl/drivers/xdri/egl_xdri.c
+++ b/src/egl/drivers/xdri/egl_xdri.c
@@ -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);
*/
diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index 9ab4286d3a..f8d5687f87 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -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 {
diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h
index 2fb28d38b9..4276c0980e 100644
--- a/src/egl/main/eglcontext.h
+++ b/src/egl/main/eglcontext.h
@@ -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 */
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index 9821e63628..bd263fe265 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -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;
}
diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h
index f9413eb9d7..8864176844 100644
--- a/src/egl/main/eglsurface.h
+++ b/src/egl/main/eglsurface.h
@@ -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 */
diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c
index e2da2180f7..2c8f51cf38 100644
--- a/src/gallium/state_trackers/egl/egl_context.c
+++ b/src/gallium/state_trackers/egl/egl_context.c
@@ -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);
diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c
index 86f2ea97e5..7413c9b73b 100644
--- a/src/gallium/state_trackers/egl/egl_surface.c
+++ b/src/gallium/state_trackers/egl/egl_surface.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);
diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c
index e1ddcae97b..1a1dad65f0 100644
--- a/src/gallium/winsys/egl_xlib/egl_xlib.c
+++ b/src/gallium/winsys/egl_xlib/egl_xlib.c
@@ -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);
diff --git a/src/mesa/drivers/dri/fb/fb_egl.c b/src/mesa/drivers/dri/fb/fb_egl.c
index dee67feb5a..4e41860d8c 100644
--- a/src/mesa/drivers/dri/fb/fb_egl.c
+++ b/src/mesa/drivers/dri/fb/fb_egl.c
@@ -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;
}