1 #ifndef EGLCONTEXT_INCLUDED
2 #define EGLCONTEXT_INCLUDED
5 #include "egltypedefs.h"
6 #include "egldisplay.h"
10 * "Base" class for device driver contexts.
14 /* A context is a display resource */
15 _EGLResource Resource
;
17 /* The bound status of the context */
18 _EGLThreadInfo
*Binding
;
19 _EGLSurface
*DrawSurface
;
20 _EGLSurface
*ReadSurface
;
24 EGLint ClientAPI
; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API */
25 EGLint ClientVersion
; /**< 1 = OpenGLES 1.x, 2 = OpenGLES 2.x */
27 /* The real render buffer when a window surface is bound */
28 EGLint WindowRenderBuffer
;
33 _eglInitContext(_EGLContext
*ctx
, _EGLDisplay
*dpy
,
34 _EGLConfig
*config
, const EGLint
*attrib_list
);
38 _eglQueryContext(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLContext
*ctx
, EGLint attribute
, EGLint
*value
);
42 _eglBindContext(_EGLContext
*ctx
, _EGLSurface
*draw
, _EGLSurface
*read
,
43 _EGLContext
**old_ctx
,
44 _EGLSurface
**old_draw
, _EGLSurface
**old_read
);
48 * Increment reference count for the context.
50 static INLINE _EGLContext
*
51 _eglGetContext(_EGLContext
*ctx
)
54 _eglGetResource(&ctx
->Resource
);
60 * Decrement reference count for the context.
62 static INLINE EGLBoolean
63 _eglPutContext(_EGLContext
*ctx
)
65 return (ctx
) ? _eglPutResource(&ctx
->Resource
) : EGL_FALSE
;
70 * Link a context to its display and return the handle of the link.
71 * The handle can be passed to client directly.
73 static INLINE EGLContext
74 _eglLinkContext(_EGLContext
*ctx
)
76 _eglLinkResource(&ctx
->Resource
, _EGL_RESOURCE_CONTEXT
);
77 return (EGLContext
) ctx
;
82 * Unlink a linked context from its display.
83 * Accessing an unlinked context should generate EGL_BAD_CONTEXT error.
86 _eglUnlinkContext(_EGLContext
*ctx
)
88 _eglUnlinkResource(&ctx
->Resource
, _EGL_RESOURCE_CONTEXT
);
93 * Lookup a handle to find the linked context.
94 * Return NULL if the handle has no corresponding linked context.
96 static INLINE _EGLContext
*
97 _eglLookupContext(EGLContext context
, _EGLDisplay
*dpy
)
99 _EGLContext
*ctx
= (_EGLContext
*) context
;
100 if (!dpy
|| !_eglCheckResource((void *) ctx
, _EGL_RESOURCE_CONTEXT
, dpy
))
107 * Return the handle of a linked context, or EGL_NO_CONTEXT.
109 static INLINE EGLContext
110 _eglGetContextHandle(_EGLContext
*ctx
)
112 _EGLResource
*res
= (_EGLResource
*) ctx
;
113 return (res
&& _eglIsResourceLinked(res
)) ?
114 (EGLContext
) ctx
: EGL_NO_CONTEXT
;
118 #endif /* EGLCONTEXT_INCLUDED */