summaryrefslogtreecommitdiffstats
path: root/src/egl/main/eglcontext.h
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-01-24 20:32:34 +0800
committerChia-I Wu <[email protected]>2010-01-24 20:38:16 +0800
commitecb3b3102a3022e31cf9d75ae099eddbe298517f (patch)
tree70d5476f2d46c8444b74625bedcd588e2e765ae6 /src/egl/main/eglcontext.h
parent7abf42626fe8552cf898652134f3767e591614ab (diff)
egl: Make surfaces and contexts resources.
Turn _EGLSurface and _EGLContext into _EGLResource so that they can be managed uniformly.
Diffstat (limited to 'src/egl/main/eglcontext.h')
-rw-r--r--src/egl/main/eglcontext.h56
1 files changed, 27 insertions, 29 deletions
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));
}