Merge branch 'mesa_7_6_branch'
[mesa.git] / src / egl / main / eglmisc.c
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29 /**
30 * Small/misc EGL functions
31 */
32
33
34 #include <assert.h>
35 #include <string.h>
36 #include "eglglobals.h"
37 #include "eglmisc.h"
38 #include "egldisplay.h"
39
40
41 /**
42 * Examine the individual extension enable/disable flags and recompute
43 * the driver's Extensions string.
44 */
45 static void
46 _eglUpdateExtensionsString(_EGLDisplay *dpy)
47 {
48 char *exts = dpy->Extensions.String;
49
50 if (exts[0])
51 return;
52
53 if (dpy->Extensions.MESA_screen_surface)
54 strcat(exts, "EGL_MESA_screen_surface ");
55 if (dpy->Extensions.MESA_copy_context)
56 strcat(exts, "EGL_MESA_copy_context ");
57 assert(strlen(exts) < _EGL_MAX_EXTENSIONS_LEN);
58 }
59
60
61 static void
62 _eglUpdateAPIsString(_EGLDisplay *dpy)
63 {
64 char *apis = dpy->ClientAPIs;
65
66 if (apis[0] || !dpy->ClientAPIsMask)
67 return;
68
69 if (dpy->ClientAPIsMask & EGL_OPENGL_BIT)
70 strcat(apis, "OpenGL ");
71
72 if (dpy->ClientAPIsMask & EGL_OPENGL_ES_BIT)
73 strcat(apis, "OpenGL_ES ");
74
75 if (dpy->ClientAPIsMask & EGL_OPENGL_ES2_BIT)
76 strcat(apis, "OpenGL_ES2 ");
77
78 if (dpy->ClientAPIsMask & EGL_OPENVG_BIT)
79 strcat(apis, "OpenVG ");
80
81 assert(strlen(apis) < sizeof(dpy->ClientAPIs));
82 }
83
84
85 const char *
86 _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name)
87 {
88 (void) drv;
89 (void) dpy;
90 switch (name) {
91 case EGL_VENDOR:
92 return _EGL_VENDOR_STRING;
93 case EGL_VERSION:
94 return dpy->Version;
95 case EGL_EXTENSIONS:
96 _eglUpdateExtensionsString(dpy);
97 return dpy->Extensions.String;
98 #ifdef EGL_VERSION_1_2
99 case EGL_CLIENT_APIS:
100 _eglUpdateAPIsString(dpy);
101 return dpy->ClientAPIs;
102 #endif
103 default:
104 _eglError(EGL_BAD_PARAMETER, "eglQueryString");
105 return NULL;
106 }
107 }
108
109
110 EGLBoolean
111 _eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
112 {
113 /* just a placeholder */
114 (void) drv;
115 (void) dpy;
116 (void) ctx;
117 return EGL_TRUE;
118 }
119
120
121 EGLBoolean
122 _eglWaitNative(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine)
123 {
124 /* just a placeholder */
125 (void) drv;
126 (void) dpy;
127 switch (engine) {
128 case EGL_CORE_NATIVE_ENGINE:
129 break;
130 default:
131 _eglError(EGL_BAD_PARAMETER, "eglWaitNative(engine)");
132 return EGL_FALSE;
133 }
134
135 return EGL_TRUE;
136 }