summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2015-03-24 13:12:07 +0100
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2015-03-26 09:54:49 +0200
commit0e2ab36df71508d847d6a3f22db157047e5fcb2b (patch)
treec10b4e914721595d874ddeca37b25d040e78ecab /shared
parent5c332900f716385e49966dabc96d692227d4f1b3 (diff)
downloadweston-0e2ab36df71508d847d6a3f22db157047e5fcb2b.tar.gz
platform: provide platform_base fallbacks and remove ifdefs
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'shared')
-rw-r--r--shared/platform.h47
1 files changed, 33 insertions, 14 deletions
diff --git a/shared/platform.h b/shared/platform.h
index fd06046b..ea5980eb 100644
--- a/shared/platform.h
+++ b/shared/platform.h
@@ -25,26 +25,32 @@
#include <string.h>
+#ifdef ENABLE_EGL
#include <EGL/egl.h>
#include <EGL/eglext.h>
+#endif
+
+#ifndef EGL_PLATFORM_WAYLAND_KHR
+#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
+#endif
#ifdef __cplusplus
extern "C" {
#endif
-#ifdef EGL_EXT_platform_base
-static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display_ext = NULL;
-static PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC create_platform_window_surface_ext = NULL;
+#ifdef ENABLE_EGL
-#ifndef EGL_PLATFORM_WAYLAND_KHR
-#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
+#ifndef EGL_EXT_platform_base
+typedef void (*PFNEGLGETPLATFORMDISPLAYEXTPROC) (void);
+typedef void (*PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (void);
#endif
-#endif /* EGL_EXT_platform_base */
+
+static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display_ext = NULL;
+static PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC create_platform_window_surface_ext = NULL;
static inline void
weston_platform_get_egl_proc_addresses(void)
{
-#ifdef EGL_EXT_platform_base
if (!get_platform_display_ext) {
const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
@@ -56,23 +62,20 @@ weston_platform_get_egl_proc_addresses(void)
(void *) eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
}
}
-#endif
}
static inline EGLDisplay
weston_platform_get_egl_display(EGLenum platform, void *native_display,
const EGLint *attrib_list)
{
-#ifdef EGL_EXT_platform_base
if (!get_platform_display_ext)
weston_platform_get_egl_proc_addresses();
if (get_platform_display_ext)
return get_platform_display_ext(platform,
native_display, attrib_list);
- else
-#endif
- return eglGetDisplay((EGLNativeDisplayType) native_display);
+
+ return eglGetDisplay((EGLNativeDisplayType) native_display);
}
static inline EGLSurface
@@ -80,7 +83,6 @@ weston_platform_create_egl_window(EGLDisplay dpy, EGLConfig config,
void *native_window,
const EGLint *attrib_list)
{
-#ifdef EGL_EXT_platform_base
if (!create_platform_window_surface_ext)
weston_platform_get_egl_proc_addresses();
@@ -88,13 +90,30 @@ weston_platform_create_egl_window(EGLDisplay dpy, EGLConfig config,
return create_platform_window_surface_ext(dpy, config,
native_window,
attrib_list);
-#endif
return eglCreateWindowSurface(dpy, config,
(EGLNativeWindowType) native_window,
attrib_list);
}
+#else /* ENABLE_EGL */
+
+static inline void *
+weston_platform_get_egl_display(void *platform, void *native_display,
+ const int *attrib_list)
+{
+ return NULL;
+}
+
+static inline void *
+weston_platform_create_egl_window(void *dpy, void *config,
+ void *native_window,
+ const int *attrib_list)
+{
+ return NULL;
+}
+#endif /* ENABLE_EGL */
+
#ifdef __cplusplus
}
#endif