907a057b4420fdef3bd46d1acdf90f5bec1b096a
[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 "eglcurrent.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
58 if (dpy->Extensions.KHR_image_base)
59 strcat(exts, "EGL_KHR_image_base ");
60 if (dpy->Extensions.KHR_image_pixmap)
61 strcat(exts, "EGL_KHR_image_pixmap ");
62 if (dpy->Extensions.KHR_image_base && dpy->Extensions.KHR_image_pixmap)
63 strcat(exts, "EGL_KHR_image ");
64
65 assert(strlen(exts) < _EGL_MAX_EXTENSIONS_LEN);
66 }
67
68
69 static void
70 _eglUpdateAPIsString(_EGLDisplay *dpy)
71 {
72 char *apis = dpy->ClientAPIs;
73
74 if (apis[0] || !dpy->ClientAPIsMask)
75 return;
76
77 if (dpy->ClientAPIsMask & EGL_OPENGL_BIT)
78 strcat(apis, "OpenGL ");
79
80 if (dpy->ClientAPIsMask & EGL_OPENGL_ES_BIT)
81 strcat(apis, "OpenGL_ES ");
82
83 if (dpy->ClientAPIsMask & EGL_OPENGL_ES2_BIT)
84 strcat(apis, "OpenGL_ES2 ");
85
86 if (dpy->ClientAPIsMask & EGL_OPENVG_BIT)
87 strcat(apis, "OpenVG ");
88
89 assert(strlen(apis) < sizeof(dpy->ClientAPIs));
90 }
91
92
93 const char *
94 _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name)
95 {
96 (void) drv;
97 (void) dpy;
98 switch (name) {
99 case EGL_VENDOR:
100 return _EGL_VENDOR_STRING;
101 case EGL_VERSION:
102 return dpy->Version;
103 case EGL_EXTENSIONS:
104 _eglUpdateExtensionsString(dpy);
105 return dpy->Extensions.String;
106 #ifdef EGL_VERSION_1_2
107 case EGL_CLIENT_APIS:
108 _eglUpdateAPIsString(dpy);
109 return dpy->ClientAPIs;
110 #endif
111 default:
112 _eglError(EGL_BAD_PARAMETER, "eglQueryString");
113 return NULL;
114 }
115 }
116
117
118 EGLBoolean
119 _eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
120 {
121 /* just a placeholder */
122 (void) drv;
123 (void) dpy;
124 (void) ctx;
125 return EGL_TRUE;
126 }
127
128
129 EGLBoolean
130 _eglWaitNative(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine)
131 {
132 /* just a placeholder */
133 (void) drv;
134 (void) dpy;
135 switch (engine) {
136 case EGL_CORE_NATIVE_ENGINE:
137 break;
138 default:
139 _eglError(EGL_BAD_PARAMETER, "eglWaitNative(engine)");
140 return EGL_FALSE;
141 }
142
143 return EGL_TRUE;
144 }