summaryrefslogtreecommitdiff
path: root/src/egl/main/eglsurface.h
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2010-01-24 20:32:34 +0800
committerChia-I Wu <olvaffe@gmail.com>2010-01-24 20:38:16 +0800
commitecb3b3102a3022e31cf9d75ae099eddbe298517f (patch)
tree70d5476f2d46c8444b74625bedcd588e2e765ae6 /src/egl/main/eglsurface.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/eglsurface.h')
-rw-r--r--src/egl/main/eglsurface.h56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h
index b1163293fe..da07133c2c 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));
}