Merge commit 'origin/master' into gallium-0.2
[profile/ivi/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
39
40 /**
41  * Examine the individual extension enable/disable flags and recompute
42  * the driver's Extensions string.
43  */
44 static void
45 _eglUpdateExtensionsString(_EGLDriver *drv)
46 {
47    drv->Extensions.String[0] = 0;
48
49    if (drv->Extensions.MESA_screen_surface)
50       strcat(drv->Extensions.String, "EGL_MESA_screen_surface ");
51    if (drv->Extensions.MESA_copy_context)
52       strcat(drv->Extensions.String, "EGL_MESA_copy_context ");
53    assert(strlen(drv->Extensions.String) < _EGL_MAX_EXTENSIONS_LEN);
54 }
55
56
57 static void
58 _eglUpdateAPIsString(_EGLDriver *drv)
59 {
60    _eglGlobal.ClientAPIs[0] = 0;
61
62    if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT)
63       strcat(_eglGlobal.ClientAPIs, "OpenGL ");
64
65    if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_ES_BIT)
66       strcat(_eglGlobal.ClientAPIs, "OpenGL_ES ");
67
68    if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_ES2_BIT)
69       strcat(_eglGlobal.ClientAPIs, "OpenGL_ES2 ");
70
71    if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT)
72       strcat(_eglGlobal.ClientAPIs, "OpenVG ");
73
74    assert(strlen(_eglGlobal.ClientAPIs) < sizeof(_eglGlobal.ClientAPIs));
75 }
76
77
78
79 const char *
80 _eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name)
81 {
82    (void) drv;
83    (void) dpy;
84    switch (name) {
85    case EGL_VENDOR:
86       return _EGL_VENDOR_STRING;
87    case EGL_VERSION:
88       return drv->Version;
89    case EGL_EXTENSIONS:
90       _eglUpdateExtensionsString(drv);
91       return drv->Extensions.String;
92 #ifdef EGL_VERSION_1_2
93    case EGL_CLIENT_APIS:
94       _eglUpdateAPIsString(drv);
95       return _eglGlobal.ClientAPIs;
96 #endif
97    default:
98       _eglError(EGL_BAD_PARAMETER, "eglQueryString");
99       return NULL;
100    }
101 }
102
103
104 EGLBoolean
105 _eglWaitGL(_EGLDriver *drv, EGLDisplay dpy)
106 {
107    /* just a placeholder */
108    (void) drv;
109    (void) dpy;
110    return EGL_TRUE;
111 }
112
113
114 EGLBoolean
115 _eglWaitNative(_EGLDriver *drv, EGLDisplay dpy, EGLint engine)
116 {
117    /* just a placeholder */
118    (void) drv;
119    (void) dpy;
120    switch (engine) {
121    case EGL_CORE_NATIVE_ENGINE:
122       break;
123    default:
124       _eglError(EGL_BAD_PARAMETER, "eglWaitNative(engine)");
125       return EGL_FALSE;
126    }
127
128    return EGL_TRUE;
129 }