gallium: add target-helpers/wrap_screen.c to C_SOURCES
[mesa/mesa-lb.git] / src / egl / main / eglcontext.h
blobcfe92dd9f5c4c37234169810c1a5c02c93113f4f
1 #ifndef EGLCONTEXT_INCLUDED
2 #define EGLCONTEXT_INCLUDED
5 #include "egltypedefs.h"
6 #include "egldisplay.h"
9 /**
10 * "Base" class for device driver contexts.
12 struct _egl_context
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;
22 _EGLConfig *Config;
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;
32 PUBLIC EGLBoolean
33 _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy,
34 _EGLConfig *config, const EGLint *attrib_list);
37 extern _EGLContext *
38 _eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list);
41 extern EGLBoolean
42 _eglDestroyContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx);
45 extern EGLBoolean
46 _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value);
49 PUBLIC EGLBoolean
50 _eglBindContext(_EGLContext **ctx, _EGLSurface **draw, _EGLSurface **read);
53 extern EGLBoolean
54 _eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx);
57 extern EGLBoolean
58 _eglCopyContextMESA(_EGLDriver *drv, EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask);
61 /**
62 * Return true if the context is bound to a thread.
64 * The binding is considered a reference to the context. Drivers should not
65 * destroy a context when it is bound.
67 static INLINE EGLBoolean
68 _eglIsContextBound(_EGLContext *ctx)
70 return (ctx->Binding != NULL);
74 /**
75 * Link a context to a display and return the handle of the link.
76 * The handle can be passed to client directly.
78 static INLINE EGLContext
79 _eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy)
81 _eglLinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT, dpy);
82 return (EGLContext) ctx;
86 /**
87 * Unlink a linked context from its display.
88 * Accessing an unlinked context should generate EGL_BAD_CONTEXT error.
90 static INLINE void
91 _eglUnlinkContext(_EGLContext *ctx)
93 _eglUnlinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT);
97 /**
98 * Lookup a handle to find the linked context.
99 * Return NULL if the handle has no corresponding linked context.
101 static INLINE _EGLContext *
102 _eglLookupContext(EGLContext context, _EGLDisplay *dpy)
104 _EGLContext *ctx = (_EGLContext *) context;
105 if (!dpy || !_eglCheckResource((void *) ctx, _EGL_RESOURCE_CONTEXT, dpy))
106 ctx = NULL;
107 return ctx;
112 * Return the handle of a linked context, or EGL_NO_CONTEXT.
114 static INLINE EGLContext
115 _eglGetContextHandle(_EGLContext *ctx)
117 _EGLResource *res = (_EGLResource *) ctx;
118 return (res && _eglIsResourceLinked(res)) ?
119 (EGLContext) ctx : EGL_NO_CONTEXT;
124 * Return true if the context is linked to a display.
126 * The link is considered a reference to the context (the display is owning the
127 * context). Drivers should not destroy a context when it is linked.
129 static INLINE EGLBoolean
130 _eglIsContextLinked(_EGLContext *ctx)
132 _EGLResource *res = (_EGLResource *) ctx;
133 return (res && _eglIsResourceLinked(res));
137 #endif /* EGLCONTEXT_INCLUDED */