[PATCH weston 4/4] clients & tests: use eglCreatePlatformWindowSurfaceEXT when supported

Jonny Lamb jonny.lamb at collabora.co.uk
Tue Feb 17 07:48:03 PST 2015


---
 clients/nested-client.c   | 18 ++++++++++++++----
 clients/simple-egl.c      | 18 ++++++++++++++----
 clients/subsurfaces.c     | 18 +++++++++++++++---
 clients/window.c          | 17 +++++++++++++----
 tests/buffer-count-test.c | 21 ++++++++++++++++-----
 5 files changed, 72 insertions(+), 20 deletions(-)

diff --git a/clients/nested-client.c b/clients/nested-client.c
index fbf5350..46decd8 100644
--- a/clients/nested-client.c
+++ b/clients/nested-client.c
@@ -241,6 +241,7 @@ static const struct wl_registry_listener registry_listener = {
 
 #ifdef EGL_EXT_platform_base
 static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
+static PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC create_platform_window = NULL;
 #endif
 
 static struct nested_client *
@@ -292,6 +293,8 @@ nested_client_create(void)
 	if (strstr(extensions, "EGL_EXT_platform_wayland")) {
 		get_platform_display =
 			(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
+		create_platform_window =
+			(void *) eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
 	} else {
 		fprintf(stderr, "error: no wayland egl support\n");
 		return NULL;
@@ -332,10 +335,17 @@ nested_client_create(void)
 	client->native = wl_egl_window_create(client->surface,
 					      client->width, client->height);
 
-	client->egl_surface =
-		eglCreateWindowSurface(client->egl_display,
-				       client->egl_config,
-				       client->native, NULL);
+	if (create_platform_window) {
+		client->egl_surface =
+			create_platform_window(client->egl_display,
+					       client->egl_config,
+					       client->native, NULL);
+	} else {
+		client->egl_surface =
+			eglCreateWindowSurface(client->egl_display,
+					       client->egl_config,
+					       client->native, NULL);
+	}
 
 	eglMakeCurrent(client->egl_display, client->egl_surface,
 		       client->egl_surface, client->egl_context);
diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index 1162eb4..7be61a8 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -127,6 +127,7 @@ static int running = 1;
 
 #ifdef EGL_EXT_platform_base
 static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
+static PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC create_platform_window = NULL;
 #endif
 
 static void
@@ -161,6 +162,8 @@ init_egl(struct display *display, struct window *window)
 	if (strstr(extensions, "EGL_EXT_platform_wayland")) {
 		get_platform_display =
 			(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
+		create_platform_window =
+			(void *) eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
 	} else {
 		fprintf(stderr, "error: no wayland egl support\n");
 		exit(1);
@@ -402,10 +405,17 @@ create_surface(struct window *window)
 		wl_egl_window_create(window->surface,
 				     window->geometry.width,
 				     window->geometry.height);
-	window->egl_surface =
-		eglCreateWindowSurface(display->egl.dpy,
-				       display->egl.conf,
-				       window->native, NULL);
+	if (create_platform_window) {
+		window->egl_surface =
+			create_platform_window(display->egl.dpy,
+					       display->egl.conf,
+					       window->native, NULL);
+	} else {
+		window->egl_surface =
+			eglCreateWindowSurface(display->egl.dpy,
+					       display->egl.conf,
+					       window->native, NULL);
+	}
 
 	if (display->shell) {
 		create_xdg_surface(window, display);
diff --git a/clients/subsurfaces.c b/clients/subsurfaces.c
index d15d5a5..5081bc7 100644
--- a/clients/subsurfaces.c
+++ b/clients/subsurfaces.c
@@ -192,6 +192,7 @@ egl_print_config_info(struct egl_state *egl)
 
 #ifdef EGL_EXT_platform_base
 static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
+static PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC create_platform_window = NULL;
 #endif
 
 static struct egl_state *
@@ -225,6 +226,8 @@ egl_state_create(struct wl_display *display)
 	if (strstr(extensions, "EGL_EXT_platform_wayland")) {
 		get_platform_display =
 			(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
+		create_platform_window =
+			(void *) eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
 	} else {
 		fprintf(stderr, "error: no wayland egl support\n");
 		exit(1);
@@ -443,9 +446,18 @@ triangle_create_egl_surface(struct triangle *tri, int width, int height)
 
 	tri->wl_surface = widget_get_wl_surface(tri->widget);
 	tri->egl_window = wl_egl_window_create(tri->wl_surface, width, height);
-	tri->egl_surface = eglCreateWindowSurface(tri->egl->dpy,
-						  tri->egl->conf,
-						  tri->egl_window, NULL);
+
+	if (create_platform_window) {
+		tri->egl_surface =
+			create_platform_window(tri->egl->dpy,
+					       tri->egl->conf,
+					       tri->egl_window, NULL);
+	} else {
+		tri->egl_surface =
+			eglCreateWindowSurface(tri->egl->dpy,
+					       tri->egl->conf,
+					       tri->egl_window, NULL);
+	}
 
 	ret = eglMakeCurrent(tri->egl->dpy, tri->egl_surface,
 			     tri->egl_surface, tri->egl->ctx);
diff --git a/clients/window.c b/clients/window.c
index dc08f59..e572af6 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -639,10 +639,17 @@ egl_window_surface_create(struct display *display,
 						   rectangle->width,
 						   rectangle->height);
 
-	surface->egl_surface = eglCreateWindowSurface(display->dpy,
-						      display->argb_config,
-						      surface->egl_window,
-						      NULL);
+	if (create_platform_window) {
+		surface->egl_surface =
+			create_platform_window(display->dpy,
+					       display->argb_config,
+					       surface->egl_window, NULL);
+	} else {
+		surface->egl_surface =
+			eglCreateWindowSurface(display->dpy,
+					       display->argb_config,
+					       surface->egl_window, NULL);
+	}
 
 	surface->cairo_surface =
 		cairo_gl_surface_create_for_egl(display->argb_device,
@@ -5395,6 +5402,8 @@ init_egl(struct display *d)
 	if (strstr(extensions, "EGL_EXT_platform_wayland")) {
 		get_platform_display =
 			(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
+		create_platform_window =
+			(void *) eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
 	} else {
 		fprintf(stderr, "error: no wayland egl support\n");
 		return -1;
diff --git a/tests/buffer-count-test.c b/tests/buffer-count-test.c
index 1912b62..e99dc70 100644
--- a/tests/buffer-count-test.c
+++ b/tests/buffer-count-test.c
@@ -44,6 +44,7 @@ struct test_data {
 
 #ifdef EGL_EXT_platform_base
 static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
+static PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC create_platform_window = NULL;
 #endif
 
 static int
@@ -79,6 +80,8 @@ init_egl(struct test_data *test_data)
 	if (strstr(extensions, "EGL_EXT_platform_wayland")) {
 		get_platform_display =
 			(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
+		create_platform_window =
+			(void *) eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
 	} else {
 		fprintf(stderr, "error: no wayland egl support\n");
 		return -1;
@@ -117,11 +120,19 @@ init_egl(struct test_data *test_data)
 		wl_egl_window_create(surface->wl_surface,
 				     surface->width,
 				     surface->height);
-	test_data->egl_surface =
-		eglCreateWindowSurface(test_data->egl_dpy,
-				       test_data->egl_conf,
-				       (EGLNativeWindowType) native_window,
-				       NULL);
+
+	if (create_platform_window) {
+		test_data->egl_surface =
+			create_platform_window(test_data->egl_dpy,
+					       test_data->egl_conf,
+					       (void *) native_window, NULL);
+	} else {
+		test_data->egl_surface =
+			eglCreateWindowSurface(test_data->egl_dpy,
+					       test_data->egl_conf,
+					       (EGLNativeWindowType) native_window,
+					       NULL);
+	}
 
 	ret = eglMakeCurrent(test_data->egl_dpy, test_data->egl_surface,
 			     test_data->egl_surface, test_data->egl_ctx);
-- 
2.1.4



More information about the wayland-devel mailing list