summaryrefslogtreecommitdiff
path: root/src/egl/main
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2009-07-17 11:56:00 -0600
committerBrian Paul <brianp@vmware.com>2009-07-17 11:56:00 -0600
commit15fdbc8361d0b865aea5e2f374b471081ed4214a (patch)
treef0d15e4fed5f445e9754934e45388522640e906c /src/egl/main
parent3f7e0d5302ed0fadd794a41af6e476d2c408adc7 (diff)
egl: Remove redundant DeletePending flag.
A context or surface that is neither linked to a display nor current to a thread should be destroyed. Therefore, an unlinked context or surface implies a pending delete automatically. Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Diffstat (limited to 'src/egl/main')
-rw-r--r--src/egl/main/eglcontext.c14
-rw-r--r--src/egl/main/eglcontext.h1
-rw-r--r--src/egl/main/egldisplay.h29
-rw-r--r--src/egl/main/eglsurface.c6
-rw-r--r--src/egl/main/eglsurface.h1
5 files changed, 35 insertions, 16 deletions
diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index 01cb116d00..9ab4286d3a 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -96,12 +96,8 @@ _eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx)
_EGLContext *context = _eglLookupContext(ctx);
if (context) {
_eglUnlinkContext(context);
- if (context->IsBound) {
- context->DeletePending = EGL_TRUE;
- }
- else {
+ if (!context->IsBound)
free(context);
- }
return EGL_TRUE;
}
else {
@@ -146,7 +142,7 @@ _eglQueryContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx,
/**
* Drivers will typically call this to do the error checking and
- * update the various IsBound and DeletePending flags.
+ * update the various flags.
* Then, the driver will do its device-dependent Make-Current stuff.
*/
EGLBoolean
@@ -212,7 +208,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
*/
if (oldDrawSurface != NULL) {
oldDrawSurface->IsBound = EGL_FALSE;
- if (oldDrawSurface->DeletePending) {
+ if (!_eglIsSurfaceLinked(oldDrawSurface)) {
/* make sure we don't try to rebind a deleted surface */
if (draw == oldDrawSurface || draw == oldReadSurface) {
draw = NULL;
@@ -223,7 +219,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
}
if (oldReadSurface != NULL && oldReadSurface != oldDrawSurface) {
oldReadSurface->IsBound = EGL_FALSE;
- if (oldReadSurface->DeletePending) {
+ if (!_eglIsSurfaceLinked(oldReadSurface)) {
/* make sure we don't try to rebind a deleted surface */
if (read == oldDrawSurface || read == oldReadSurface) {
read = NULL;
@@ -234,7 +230,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
}
if (oldContext != NULL) {
oldContext->IsBound = EGL_FALSE;
- if (oldContext->DeletePending) {
+ if (!_eglIsContextLinked(oldContext)) {
/* make sure we don't try to rebind a deleted context */
if (ctx == oldContext) {
ctx = NULL;
diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h
index 8e20643177..2fb28d38b9 100644
--- a/src/egl/main/eglcontext.h
+++ b/src/egl/main/eglcontext.h
@@ -21,7 +21,6 @@ struct _egl_context
_EGLSurface *ReadSurface;
EGLBoolean IsBound;
- EGLBoolean DeletePending;
EGLint ClientAPI; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API */
EGLint ClientVersion; /**< 1 = OpenGLES 1.x, 2 = OpenGLES 2.x */
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 30b466cb4a..372ed3cd79 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -52,6 +52,16 @@ extern _EGLDisplay *
_eglLookupDisplay(EGLDisplay dpy);
+/**
+ * Return true if the display is linked.
+ */
+static INLINE EGLBoolean
+_eglIsDisplayLinked(_EGLDisplay *dpy)
+{
+ return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY);
+}
+
+
extern _EGLDisplay *
_eglFindDisplay(NativeDisplayType nativeDisplay);
@@ -80,6 +90,15 @@ extern _EGLContext *
_eglLookupContext(EGLContext ctx);
+/**
+ * Return true if the context is linked to a display.
+ */
+static INLINE EGLBoolean
+_eglIsContextLinked(_EGLContext *ctx)
+{
+ return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT);
+}
+
extern EGLSurface
_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy);
@@ -96,4 +115,14 @@ extern _EGLSurface *
_eglLookupSurface(EGLSurface surf);
+/**
+ * Return true if the surface is linked to a display.
+ */
+static INLINE EGLBoolean
+_eglIsSurfaceLinked(_EGLSurface *surf)
+{
+ return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE);
+}
+
+
#endif /* EGLDISPLAY_INCLUDED */
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index b122124585..9821e63628 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -413,12 +413,8 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
_EGLSurface *surf = _eglLookupSurface(surface);
if (surf) {
_eglUnlinkSurface(surf);
- if (surf->IsBound) {
- surf->DeletePending = EGL_TRUE;
- }
- else {
+ if (!surf->IsBound)
free(surf);
- }
return EGL_TRUE;
}
else {
diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h
index f6874e6278..f9413eb9d7 100644
--- a/src/egl/main/eglsurface.h
+++ b/src/egl/main/eglsurface.h
@@ -19,7 +19,6 @@ struct _egl_surface
/* May need reference counting here */
EGLBoolean IsBound;
- EGLBoolean DeletePending;
EGLBoolean BoundToTexture;
EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */