platform: provide platform_base fallbacks and remove ifdefs
authorJonny Lamb <jonny.lamb@collabora.co.uk>
Tue, 24 Mar 2015 12:12:07 +0000 (13:12 +0100)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Thu, 26 Mar 2015 07:54:49 +0000 (09:54 +0200)
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
shared/platform.h

index fd06046b2d9981cda1c1028a7109680d57f6bdae..ea5980eb7d1feaaccd3297b87a7983d9c8ff278a 100644 (file)
 
 #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