diff options
author | Kyle Brenneman <[email protected]> | 2017-01-04 11:31:58 -0700 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-04-17 13:03:58 +0100 |
commit | ce562f9e3fab769d64b0e5453ec2b4f8710a31ce (patch) | |
tree | 5c372e39ba2c33611f145b91224f304a53ab6dd0 /src/egl/main/eglglobals.c | |
parent | 370df207cadbc1ae60415b3b953f85088e6398d4 (diff) |
EGL: Implement the libglvnd interface for EGL (v3)
The new interface mostly just sits on top of the existing library.
The only change to the existing EGL code is to split the client
extension string into platform extensions and everything else. On
non-glvnd builds, eglQueryString will just concatenate the two strings.
The EGL dispatch stubs are all generated. The script is based on the one
used to generate entrypoints in libglvnd itself.
v2: [Kyle]
- Rebased against master.
- Reworked the EGL makefile to use separate libraries
- Made the EGL code generation scripts work with Python 2 and 3.
- Change gen_egl_dispatch.py to use argparse for the command line arguments.
- Assorted formatting and style cleanup in the Python scripts.
v3: [Emil Velikov]
- Rebase
- Remove separate glvnd glx/egl configure toggles
Signed-off-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/egl/main/eglglobals.c')
-rw-r--r-- | src/egl/main/eglglobals.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index cb41063e321..baf96bb1ec5 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -29,6 +29,8 @@ #include <stdlib.h> +#include <stdio.h> +#include <string.h> #include <assert.h> #include "c11/threads.h" @@ -50,9 +52,13 @@ struct _egl_global _eglGlobal = _eglFiniDisplay }, - /* ClientExtensionString */ + /* ClientOnlyExtensionString */ "EGL_EXT_client_extensions" " EGL_EXT_platform_base" + " EGL_KHR_client_get_all_proc_addresses" + " EGL_KHR_debug", + + /* PlatformExtensionString */ #ifdef HAVE_WAYLAND_PLATFORM " EGL_EXT_platform_wayland" #endif @@ -65,8 +71,9 @@ struct _egl_global _eglGlobal = #ifdef HAVE_SURFACELESS_PLATFORM " EGL_MESA_platform_surfaceless" #endif - " EGL_KHR_client_get_all_proc_addresses" - " EGL_KHR_debug", + "", + + NULL, /* ClientExtensionsString */ NULL, /* debugCallback */ _EGL_DEBUG_BIT_CRITICAL | _EGL_DEBUG_BIT_ERROR, /* debugTypesEnabled */ @@ -101,3 +108,37 @@ _eglAddAtExitCall(void (*func)(void)) mtx_unlock(_eglGlobal.Mutex); } } + +const char * +_eglGetClientExtensionString(void) +{ + const char *ret; + + mtx_lock(_eglGlobal.Mutex); + + if (_eglGlobal.ClientExtensionString == NULL) { + size_t clientLen = strlen(_eglGlobal.ClientOnlyExtensionString); + size_t platformLen = strlen(_eglGlobal.PlatformExtensionString); + + _eglGlobal.ClientExtensionString = (char *) malloc(clientLen + platformLen + 1); + if (_eglGlobal.ClientExtensionString != NULL) { + char *ptr = _eglGlobal.ClientExtensionString; + + memcpy(ptr, _eglGlobal.ClientOnlyExtensionString, clientLen); + ptr += clientLen; + + if (platformLen > 0) { + // Note that if PlatformExtensionString is not empty, then it will + // already have a leading space. + assert(_eglGlobal.PlatformExtensionString[0] == ' '); + memcpy(ptr, _eglGlobal.PlatformExtensionString, platformLen); + ptr += platformLen; + } + *ptr = '\0'; + } + } + ret = _eglGlobal.ClientExtensionString; + + mtx_unlock(_eglGlobal.Mutex); + return ret; +} |