gl-renderer: use eglGetPlatformDisplayEXT to get an EGLDisplay

Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 04a2331..b6fd37d 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -45,8 +45,14 @@
 #include "fullscreen-shell-client-protocol.h"
 #include "presentation_timing-server-protocol.h"
 
+#include <EGL/eglext.h>
+
 #define WINDOW_TITLE "Weston Compositor"
 
+#ifndef EGL_PLATFORM_WAYLAND_KHR
+#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
+#endif
+
 struct wayland_compositor {
 	struct weston_compositor base;
 
@@ -1961,9 +1967,17 @@
 	}
 
 	if (!c->use_pixman) {
-		if (gl_renderer->create(&c->base, c->parent.wl_display,
-				gl_renderer->alpha_attribs,
-				NULL) < 0) {
+		if (!gl_renderer->supports ||
+		    gl_renderer->supports(&c->base, "wayland") < 0) {
+			weston_log("No support for "
+			           "EGL_{KHR,EXT,MESA}_platform_wayland; "
+			           "falling back to pixman.\n");
+			c->use_pixman = 1;
+		} else if (gl_renderer->create(&c->base,
+					       EGL_PLATFORM_WAYLAND_KHR,
+					       c->parent.wl_display,
+					       gl_renderer->alpha_attribs,
+					       NULL) < 0) {
 			weston_log("Failed to initialize the GL renderer; "
 				   "falling back to pixman.\n");
 			c->use_pixman = 1;