eglcontext.h revision 5e66d1893234b3002d71985c05253321d4cdedc4
1 2#ifndef EGLCONTEXT_INCLUDED 3#define EGLCONTEXT_INCLUDED 4 5 6#include "egltypedefs.h" 7 8 9/** 10 * "Base" class for device driver contexts. 11 */ 12struct _egl_context 13{ 14 /* Managed by EGLDisplay for linking */ 15 _EGLDisplay *Display; 16 _EGLContext *Next; 17 18 /* The bound status of the context */ 19 _EGLThreadInfo *Binding; 20 _EGLSurface *DrawSurface; 21 _EGLSurface *ReadSurface; 22 23 _EGLConfig *Config; 24 25 EGLint ClientAPI; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API */ 26 EGLint ClientVersion; /**< 1 = OpenGLES 1.x, 2 = OpenGLES 2.x */ 27 28 /* The real render buffer when a window surface is bound */ 29 EGLint WindowRenderBuffer; 30}; 31 32 33PUBLIC EGLBoolean 34_eglInitContext(_EGLDriver *drv, _EGLContext *ctx, 35 _EGLConfig *config, const EGLint *attrib_list); 36 37 38extern _EGLContext * 39_eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list); 40 41 42extern EGLBoolean 43_eglDestroyContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx); 44 45 46extern EGLBoolean 47_eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value); 48 49 50PUBLIC EGLBoolean 51_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx); 52 53 54extern EGLBoolean 55_eglCopyContextMESA(_EGLDriver *drv, EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask); 56 57 58/** 59 * Return true if the context is bound to a thread. 60 */ 61static INLINE EGLBoolean 62_eglIsContextBound(_EGLContext *ctx) 63{ 64 return (ctx->Binding != NULL); 65} 66 67 68extern EGLContext 69_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy); 70 71 72extern void 73_eglUnlinkContext(_EGLContext *ctx); 74 75 76#ifndef _EGL_SKIP_HANDLE_CHECK 77 78 79extern EGLBoolean 80_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy); 81 82 83#else /* !_EGL_SKIP_HANDLE_CHECK */ 84 85 86static INLINE EGLBoolean 87_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy) 88{ 89 _EGLContext *c = (_EGLContext *) ctx; 90 return (dpy && c && c->Display == dpy); 91} 92 93 94#endif /* _EGL_SKIP_HANDLE_CHECK */ 95 96 97/** 98 * Lookup a handle to find the linked context. 99 * Return NULL if the handle has no corresponding linked context. 100 */ 101static INLINE _EGLContext * 102_eglLookupContext(EGLContext context, _EGLDisplay *dpy) 103{ 104 _EGLContext *ctx = (_EGLContext *) context; 105 if (!_eglCheckContextHandle(context, dpy)) 106 ctx = NULL; 107 return ctx; 108} 109 110 111/** 112 * Return the handle of a linked context, or EGL_NO_CONTEXT. 113 */ 114static INLINE EGLContext 115_eglGetContextHandle(_EGLContext *ctx) 116{ 117 return (EGLContext) ((ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT); 118} 119 120 121/** 122 * Return true if the context is linked to a display. 123 */ 124static INLINE EGLBoolean 125_eglIsContextLinked(_EGLContext *ctx) 126{ 127 return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT); 128} 129 130 131#endif /* EGLCONTEXT_INCLUDED */ 132