1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
30 * Small/misc EGL functions
36 #include "eglcurrent.h"
38 #include "egldisplay.h"
42 * Copy the extension into the string and update the string pointer.
45 _eglAppendExtension(char **str
, const char *ext
)
48 size_t len
= strlen(ext
);
66 * Examine the individual extension enable/disable flags and recompute
67 * the driver's Extensions string.
70 _eglUpdateExtensionsString(_EGLDisplay
*dpy
)
72 #define _EGL_CHECK_EXTENSION(ext) \
74 if (dpy->Extensions.ext) { \
75 _eglAppendExtension(&exts, "EGL_" #ext); \
76 assert(exts <= dpy->Extensions.String + _EGL_MAX_EXTENSIONS_LEN); \
80 char *exts
= dpy
->Extensions
.String
;
85 _EGL_CHECK_EXTENSION(MESA_screen_surface
);
86 _EGL_CHECK_EXTENSION(MESA_copy_context
);
87 _EGL_CHECK_EXTENSION(MESA_drm_display
);
88 _EGL_CHECK_EXTENSION(MESA_drm_image
);
90 _EGL_CHECK_EXTENSION(KHR_image_base
);
91 _EGL_CHECK_EXTENSION(KHR_image_pixmap
);
92 if (dpy
->Extensions
.KHR_image_base
&& dpy
->Extensions
.KHR_image_pixmap
)
93 _eglAppendExtension(&exts
, "EGL_KHR_image");
95 _EGL_CHECK_EXTENSION(KHR_vg_parent_image
);
96 _EGL_CHECK_EXTENSION(KHR_gl_texture_2D_image
);
97 _EGL_CHECK_EXTENSION(KHR_gl_texture_cubemap_image
);
98 _EGL_CHECK_EXTENSION(KHR_gl_texture_3D_image
);
99 _EGL_CHECK_EXTENSION(KHR_gl_renderbuffer_image
);
101 _EGL_CHECK_EXTENSION(KHR_reusable_sync
);
102 _EGL_CHECK_EXTENSION(KHR_fence_sync
);
104 _EGL_CHECK_EXTENSION(KHR_surfaceless_gles1
);
105 _EGL_CHECK_EXTENSION(KHR_surfaceless_gles2
);
106 _EGL_CHECK_EXTENSION(KHR_surfaceless_opengl
);
108 _EGL_CHECK_EXTENSION(NOK_swap_region
);
109 _EGL_CHECK_EXTENSION(NOK_texture_from_pixmap
);
110 #undef _EGL_CHECK_EXTENSION
115 _eglUpdateAPIsString(_EGLDisplay
*dpy
)
117 char *apis
= dpy
->ClientAPIs
;
119 if (apis
[0] || !dpy
->ClientAPIsMask
)
122 if (dpy
->ClientAPIsMask
& EGL_OPENGL_BIT
)
123 strcat(apis
, "OpenGL ");
125 if (dpy
->ClientAPIsMask
& EGL_OPENGL_ES_BIT
)
126 strcat(apis
, "OpenGL_ES ");
128 if (dpy
->ClientAPIsMask
& EGL_OPENGL_ES2_BIT
)
129 strcat(apis
, "OpenGL_ES2 ");
131 if (dpy
->ClientAPIsMask
& EGL_OPENVG_BIT
)
132 strcat(apis
, "OpenVG ");
134 assert(strlen(apis
) < sizeof(dpy
->ClientAPIs
));
139 _eglQueryString(_EGLDriver
*drv
, _EGLDisplay
*dpy
, EGLint name
)
145 return _EGL_VENDOR_STRING
;
149 _eglUpdateExtensionsString(dpy
);
150 return dpy
->Extensions
.String
;
151 #ifdef EGL_VERSION_1_2
152 case EGL_CLIENT_APIS
:
153 _eglUpdateAPIsString(dpy
);
154 return dpy
->ClientAPIs
;
157 _eglError(EGL_BAD_PARAMETER
, "eglQueryString");