2 #ifndef EGLCONTEXT_INCLUDED
3 #define EGLCONTEXT_INCLUDED
6 #include "egltypedefs.h"
7 #include "egldisplay.h"
11 * "Base" class for device driver contexts.
15 /* A context is a display resource */
16 _EGLResource Resource
;
18 /* The bound status of the context */
19 _EGLThreadInfo
*Binding
;
20 _EGLSurface
*DrawSurface
;
21 _EGLSurface
*ReadSurface
;
25 EGLint ClientAPI
; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API */
26 EGLint ClientVersion
; /**< 1 = OpenGLES 1.x, 2 = OpenGLES 2.x */
28 /* The real render buffer when a window surface is bound */
29 EGLint WindowRenderBuffer
;
34 _eglInitContext(_EGLDriver
*drv
, _EGLContext
*ctx
,
35 _EGLConfig
*config
, const EGLint
*attrib_list
);
39 _eglCreateContext(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLConfig
*conf
, _EGLContext
*share_list
, const EGLint
*attrib_list
);
43 _eglDestroyContext(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLContext
*ctx
);
47 _eglQueryContext(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLContext
*ctx
, EGLint attribute
, EGLint
*value
);
51 _eglMakeCurrent(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*draw
, _EGLSurface
*read
, _EGLContext
*ctx
);
55 _eglCopyContextMESA(_EGLDriver
*drv
, EGLDisplay dpy
, EGLContext source
, EGLContext dest
, EGLint mask
);
59 * Return true if the context is bound to a thread.
61 static INLINE EGLBoolean
62 _eglIsContextBound(_EGLContext
*ctx
)
64 return (ctx
->Binding
!= NULL
);
69 * Link a context to a display and return the handle of the link.
70 * The handle can be passed to client directly.
72 static INLINE EGLContext
73 _eglLinkContext(_EGLContext
*ctx
, _EGLDisplay
*dpy
)
75 _eglLinkResource(&ctx
->Resource
, _EGL_RESOURCE_CONTEXT
, dpy
);
76 return (EGLContext
) ctx
;
81 * Unlink a linked context from its display.
82 * Accessing an unlinked context should generate EGL_BAD_CONTEXT error.
85 _eglUnlinkContext(_EGLContext
*ctx
)
87 _eglUnlinkResource(&ctx
->Resource
, _EGL_RESOURCE_CONTEXT
);
92 * Lookup a handle to find the linked context.
93 * Return NULL if the handle has no corresponding linked context.
95 static INLINE _EGLContext
*
96 _eglLookupContext(EGLContext context
, _EGLDisplay
*dpy
)
98 _EGLContext
*ctx
= (_EGLContext
*) context
;
99 if (!dpy
|| !_eglCheckResource((void *) ctx
, _EGL_RESOURCE_CONTEXT
, dpy
))
106 * Return the handle of a linked context, or EGL_NO_CONTEXT.
108 static INLINE EGLContext
109 _eglGetContextHandle(_EGLContext
*ctx
)
111 _EGLResource
*res
= (_EGLResource
*) ctx
;
112 return (res
&& _eglIsResourceLinked(res
)) ?
113 (EGLContext
) ctx
: EGL_NO_CONTEXT
;
118 * Return true if the context is linked to a display.
120 static INLINE EGLBoolean
121 _eglIsContextLinked(_EGLContext
*ctx
)
123 _EGLResource
*res
= (_EGLResource
*) ctx
;
124 return (res
&& _eglIsResourceLinked(res
));
128 #endif /* EGLCONTEXT_INCLUDED */