summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/egl/main/eglapi.c6
-rw-r--r--src/egl/main/eglcontext.c69
-rw-r--r--src/egl/main/eglcontext.h56
-rw-r--r--src/egl/main/eglcurrent.c2
-rw-r--r--src/egl/main/egldisplay.c34
-rw-r--r--src/egl/main/egldisplay.h5
-rw-r--r--src/egl/main/eglsurface.c70
-rw-r--r--src/egl/main/eglsurface.h56
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.c2
9 files changed, 79 insertions, 221 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 6e8f444d7fa..26ed45c6fe5 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -526,7 +526,7 @@ eglSwapInterval(EGLDisplay dpy, EGLint interval)
_EGLSurface *surf;
_EGL_DECLARE_DD(dpy);
- if (!ctx || !_eglIsContextLinked(ctx) || ctx->Display != disp)
+ if (!ctx || !_eglIsContextLinked(ctx) || ctx->Resource.Display != disp)
return _eglError(EGL_BAD_CONTEXT, __FUNCTION__);
surf = ctx->DrawSurface;
@@ -573,7 +573,7 @@ eglWaitClient(void)
return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__);
/* a valid current context implies an initialized current display */
- disp = ctx->Display;
+ disp = ctx->Resource.Display;
drv = disp->Driver;
assert(drv);
@@ -617,7 +617,7 @@ eglWaitNative(EGLint engine)
return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__);
/* a valid current context implies an initialized current display */
- disp = ctx->Display;
+ disp = ctx->Resource.Display;
drv = disp->Driver;
assert(drv);
diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index 41960f54262..ee4b1b59f5b 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -251,72 +251,3 @@ _eglCopyContextMESA(_EGLDriver *drv, EGLDisplay dpy, EGLContext source,
*/
return EGL_FALSE;
}
-
-
-/**
- * Link a context to a display and return the handle of the link.
- * The handle can be passed to client directly.
- */
-EGLContext
-_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy)
-{
- ctx->Display = dpy;
- ctx->Next = dpy->ContextList;
- dpy->ContextList = ctx;
- return (EGLContext) ctx;
-}
-
-
-/**
- * Unlink a linked context from its display.
- * Accessing an unlinked context should generate EGL_BAD_CONTEXT error.
- */
-void
-_eglUnlinkContext(_EGLContext *ctx)
-{
- _EGLContext *prev;
-
- prev = ctx->Display->ContextList;
- if (prev != ctx) {
- while (prev) {
- if (prev->Next == ctx)
- break;
- prev = prev->Next;
- }
- assert(prev);
- prev->Next = ctx->Next;
- }
- else {
- ctx->Display->ContextList = ctx->Next;
- }
-
- ctx->Next = NULL;
- ctx->Display = NULL;
-}
-
-
-#ifndef _EGL_SKIP_HANDLE_CHECK
-
-
-/**
- * Return EGL_TRUE if the given handle is a valid handle to a context.
- */
-EGLBoolean
-_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy)
-{
- _EGLContext *cur = NULL;
-
- if (dpy)
- cur = dpy->ContextList;
- while (cur) {
- if (cur == (_EGLContext *) ctx) {
- assert(cur->Display == dpy);
- break;
- }
- cur = cur->Next;
- }
- return (cur != NULL);
-}
-
-
-#endif /* !_EGL_SKIP_HANDLE_CHECK */
diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h
index 0dcec92488c..b81dc1ed820 100644
--- a/src/egl/main/eglcontext.h
+++ b/src/egl/main/eglcontext.h
@@ -4,6 +4,7 @@
#include "egltypedefs.h"
+#include "egldisplay.h"
/**
@@ -11,9 +12,8 @@
*/
struct _egl_context
{
- /* Managed by EGLDisplay for linking */
- _EGLDisplay *Display;
- _EGLContext *Next;
+ /* A context is a display resource */
+ _EGLResource Resource;
/* The bound status of the context */
_EGLThreadInfo *Binding;
@@ -65,33 +65,27 @@ _eglIsContextBound(_EGLContext *ctx)
}
-extern EGLContext
-_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy);
-
-
-extern void
-_eglUnlinkContext(_EGLContext *ctx);
-
-
-#ifndef _EGL_SKIP_HANDLE_CHECK
-
-
-extern EGLBoolean
-_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy);
-
-
-#else /* !_EGL_SKIP_HANDLE_CHECK */
-
-
-static INLINE EGLBoolean
-_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy)
+/**
+ * Link a context to a display and return the handle of the link.
+ * The handle can be passed to client directly.
+ */
+static INLINE EGLContext
+_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy)
{
- _EGLContext *c = (_EGLContext *) ctx;
- return (dpy && c && c->Display == dpy);
+ _eglLinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT, dpy);
+ return (EGLContext) ctx;
}
-#endif /* _EGL_SKIP_HANDLE_CHECK */
+/**
+ * Unlink a linked context from its display.
+ * Accessing an unlinked context should generate EGL_BAD_CONTEXT error.
+ */
+static INLINE void
+_eglUnlinkContext(_EGLContext *ctx)
+{
+ _eglUnlinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT);
+}
/**
@@ -101,8 +95,9 @@ _eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy)
static INLINE _EGLContext *
_eglLookupContext(EGLContext context, _EGLDisplay *dpy)
{
+ _EGLResource *res = (_EGLResource *) context;
_EGLContext *ctx = (_EGLContext *) context;
- if (!_eglCheckContextHandle(context, dpy))
+ if (!res || !dpy || !_eglCheckResource(res, _EGL_RESOURCE_CONTEXT, dpy))
ctx = NULL;
return ctx;
}
@@ -114,7 +109,9 @@ _eglLookupContext(EGLContext context, _EGLDisplay *dpy)
static INLINE EGLContext
_eglGetContextHandle(_EGLContext *ctx)
{
- return (EGLContext) ((ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT);
+ _EGLResource *res = (_EGLResource *) ctx;
+ return (res && _eglIsResourceLinked(res)) ?
+ (EGLContext) ctx : EGL_NO_CONTEXT;
}
@@ -124,7 +121,8 @@ _eglGetContextHandle(_EGLContext *ctx)
static INLINE EGLBoolean
_eglIsContextLinked(_EGLContext *ctx)
{
- return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT);
+ _EGLResource *res = (_EGLResource *) ctx;
+ return (res && _eglIsResourceLinked(res));
}
diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c
index df506151b58..f91631240fd 100644
--- a/src/egl/main/eglcurrent.c
+++ b/src/egl/main/eglcurrent.c
@@ -246,7 +246,7 @@ _eglGetCurrentDisplay(void)
_EGLThreadInfo *t = _eglGetCurrentThread();
_EGLContext *ctx = t->CurrentContexts[t->CurrentAPIIndex];
if (ctx)
- return ctx->Display;
+ return ctx->Resource.Display;
else
return NULL;
}
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index ef144f7f07a..c978adb47f5 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -26,12 +26,18 @@ _eglFiniDisplay(void)
/* atexit function is called with global mutex locked */
dpyList = _eglGlobal.DisplayList;
while (dpyList) {
+ EGLint i;
+
/* pop list head */
dpy = dpyList;
dpyList = dpyList->Next;
- if (dpy->ContextList || dpy->SurfaceList)
- _eglLog(_EGL_DEBUG, "Display %p is destroyed with resources", dpy);
+ for (i = 0; i < _EGL_NUM_RESOURCES; i++) {
+ if (dpy->ResourceLists[i]) {
+ _eglLog(_EGL_DEBUG, "Display %p is destroyed with resources", dpy);
+ break;
+ }
+ }
free(dpy);
}
@@ -135,29 +141,27 @@ _eglFindDisplay(NativeDisplayType nativeDisplay)
void
_eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *display)
{
- _EGLContext *contexts;
- _EGLSurface *surfaces;
-
- contexts = display->ContextList;
- surfaces = display->SurfaceList;
+ _EGLResource *list;
- while (contexts) {
- _EGLContext *ctx = contexts;
- contexts = contexts->Next;
+ list = display->ResourceLists[_EGL_RESOURCE_CONTEXT];
+ while (list) {
+ _EGLContext *ctx = (_EGLContext *) list;
+ list = list->Next;
_eglUnlinkContext(ctx);
drv->API.DestroyContext(drv, display, ctx);
}
- assert(!display->ContextList);
+ assert(!display->ResourceLists[_EGL_RESOURCE_CONTEXT]);
- while (surfaces) {
- _EGLSurface *surf = surfaces;
- surfaces = surfaces->Next;
+ list = display->ResourceLists[_EGL_RESOURCE_SURFACE];
+ while (list) {
+ _EGLSurface *surf = (_EGLSurface *) list;
+ list = list->Next;
_eglUnlinkSurface(surf);
drv->API.DestroySurface(drv, display, surf);
}
- assert(!display->SurfaceList);
+ assert(!display->ResourceLists[_EGL_RESOURCE_SURFACE]);
}
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index c1069d7c59a..60ed7bcc039 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -63,10 +63,7 @@ struct _egl_display
EGLint NumConfigs;
_EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */
- /* lists of linked contexts and surface */
- _EGLContext *ContextList;
- _EGLSurface *SurfaceList;
-
+ /* lists of resources */
_EGLResource *ResourceLists[_EGL_NUM_RESOURCES];
};
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index 5e9a3417a65..940a1b760cf 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -511,73 +511,3 @@ _eglCreatePbufferFromClientBuffer(_EGLDriver *drv, _EGLDisplay *dpy,
}
#endif /* EGL_VERSION_1_2 */
-
-
-/**
- * Link a surface to a display and return the handle of the link.
- * The handle can be passed to client directly.
- */
-EGLSurface
-_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy)
-{
- surf->Display = dpy;
- surf->Next = dpy->SurfaceList;
- dpy->SurfaceList = surf;
- return (EGLSurface) surf;
-}
-
-
-/**
- * Unlink a linked surface from its display.
- * Accessing an unlinked surface should generate EGL_BAD_SURFACE error.
- */
-void
-_eglUnlinkSurface(_EGLSurface *surf)
-{
- _EGLSurface *prev;
-
- prev = surf->Display->SurfaceList;
- if (prev != surf) {
- while (prev) {
- if (prev->Next == surf)
- break;
- prev = prev->Next;
- }
- assert(prev);
- prev->Next = surf->Next;
- }
- else {
- prev = NULL;
- surf->Display->SurfaceList = surf->Next;
- }
-
- surf->Next = NULL;
- surf->Display = NULL;
-}
-
-
-#ifndef _EGL_SKIP_HANDLE_CHECK
-
-
-/**
- * Return EGL_TRUE if the given handle is a valid handle to a surface.
- */
-EGLBoolean
-_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy)
-{
- _EGLSurface *cur = NULL;
-
- if (dpy)
- cur = dpy->SurfaceList;
- while (cur) {
- if (cur == (_EGLSurface *) surf) {
- assert(cur->Display == dpy);
- break;
- }
- cur = cur->Next;
- }
- return (cur != NULL);
-}
-
-
-#endif /* !_EGL_SKIP_HANDLE_CHECK */
diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h
index b1163293fe6..da07133c2c1 100644
--- a/src/egl/main/eglsurface.h
+++ b/src/egl/main/eglsurface.h
@@ -3,6 +3,7 @@
#include "egltypedefs.h"
+#include "egldisplay.h"
/**
@@ -10,9 +11,8 @@
*/
struct _egl_surface
{
- /* Managed by EGLDisplay for linking */
- _EGLDisplay *Display;
- _EGLSurface *Next;
+ /* A surface is a display resource */
+ _EGLResource Resource;
/* The bound status of the surface */
_EGLContext *Binding;
@@ -111,33 +111,27 @@ _eglIsSurfaceBound(_EGLSurface *surf)
}
-extern EGLSurface
-_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy);
-
-
-extern void
-_eglUnlinkSurface(_EGLSurface *surf);
-
-
-#ifndef _EGL_SKIP_HANDLE_CHECK
-
-
-extern EGLBoolean
-_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy);
-
-
-#else /* !_EGL_SKIP_HANDLE_CHECK */
-
-
-static INLINE EGLBoolean
-_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy)
+/**
+ * Link a surface to a display and return the handle of the link.
+ * The handle can be passed to client directly.
+ */
+static INLINE EGLSurface
+_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy)
{
- _EGLSurface *s = (_EGLSurface *) surf;
- return (dpy && s && s->Display == dpy);
+ _eglLinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE, dpy);
+ return (EGLSurface) surf;
}
-#endif /* _EGL_SKIP_HANDLE_CHECK */
+/**
+ * Unlink a linked surface from its display.
+ * Accessing an unlinked surface should generate EGL_BAD_SURFACE error.
+ */
+static INLINE void
+_eglUnlinkSurface(_EGLSurface *surf)
+{
+ _eglUnlinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE);
+}
/**
@@ -147,8 +141,9 @@ _eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy)
static INLINE _EGLSurface *
_eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
{
+ _EGLResource *res = (_EGLResource *) surface;
_EGLSurface *surf = (_EGLSurface *) surface;
- if (!_eglCheckSurfaceHandle(surf, dpy))
+ if (!res || !dpy || !_eglCheckResource(res, _EGL_RESOURCE_SURFACE, dpy))
surf = NULL;
return surf;
}
@@ -160,7 +155,9 @@ _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
static INLINE EGLSurface
_eglGetSurfaceHandle(_EGLSurface *surf)
{
- return (EGLSurface) ((surf && surf->Display) ? surf : EGL_NO_SURFACE);
+ _EGLResource *res = (_EGLResource *) surf;
+ return (res && _eglIsResourceLinked(res)) ?
+ (EGLSurface) surf : EGL_NO_SURFACE;
}
@@ -170,7 +167,8 @@ _eglGetSurfaceHandle(_EGLSurface *surf)
static INLINE EGLBoolean
_eglIsSurfaceLinked(_EGLSurface *surf)
{
- return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE);
+ _EGLResource *res = (_EGLResource *) surf;
+ return (res && _eglIsResourceLinked(res));
}
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index 2ac6215646c..dc26f95cee6 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -543,7 +543,7 @@ egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private)
* Set force_validate to skip an unnecessary check.
*/
gctx->force_validate = EGL_TRUE;
- egl_g3d_validate_context(gctx->base.Display, &gctx->base);
+ egl_g3d_validate_context(gctx->base.Resource.Display, &gctx->base);
}
static EGLBoolean