[PATCH weston 4/4] clients & tests: use eglCreatePlatformWindowSurfaceEXT when supported
Jonny Lamb
jonny.lamb at collabora.co.uk
Wed Feb 25 04:42:13 PST 2015
---
clients/nested-client.c | 22 ++++++++++++++++++----
clients/simple-egl.c | 22 ++++++++++++++++++----
clients/subsurfaces.c | 22 +++++++++++++++++++---
clients/window.c | 22 ++++++++++++++++++----
tests/buffer-count-test.c | 25 ++++++++++++++++++++-----
5 files changed, 93 insertions(+), 20 deletions(-)
diff --git a/clients/nested-client.c b/clients/nested-client.c
index 9f373b1..1c04266 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
#ifndef EGL_PLATFORM_WAYLAND_KHR
@@ -297,6 +298,8 @@ nested_client_create(void)
|| strstr(extensions, "EGL_KHR_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;
@@ -339,10 +342,21 @@ 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);
+#ifdef EGL_EXT_platform_base
+ if (create_platform_window) {
+ client->egl_surface =
+ create_platform_window(client->egl_display,
+ client->egl_config,
+ client->native, NULL);
+ } else {
+#endif
+ client->egl_surface =
+ eglCreateWindowSurface(client->egl_display,
+ client->egl_config,
+ client->native, NULL);
+#ifdef EGL_EXT_platform_base
+ }
+#endif
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 20c3f27..8ac71b6 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
#ifndef EGL_PLATFORM_WAYLAND_KHR
@@ -166,6 +167,8 @@ init_egl(struct display *display, struct window *window)
|| strstr(extensions, "EGL_KHR_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);
@@ -409,10 +412,21 @@ 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);
+#ifdef EGL_EXT_platform_base
+ if (create_platform_window) {
+ window->egl_surface =
+ create_platform_window(display->egl.dpy,
+ display->egl.conf,
+ window->native, NULL);
+ } else {
+#endif
+ window->egl_surface =
+ eglCreateWindowSurface(display->egl.dpy,
+ display->egl.conf,
+ window->native, NULL);
+#ifdef EGL_EXT_platform_base
+ }
+#endif
if (display->shell) {
create_xdg_surface(window, display);
diff --git a/clients/subsurfaces.c b/clients/subsurfaces.c
index fedc1bf..ae6c90e 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
#ifndef EGL_PLATFORM_WAYLAND_KHR
@@ -230,6 +231,8 @@ egl_state_create(struct wl_display *display)
|| strstr(extensions, "EGL_KHR_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);
@@ -452,9 +455,22 @@ 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);
+
+#ifdef EGL_EXT_platform_base
+ if (create_platform_window) {
+ tri->egl_surface =
+ create_platform_window(tri->egl->dpy,
+ tri->egl->conf,
+ tri->egl_window, NULL);
+ } else {
+#endif
+ tri->egl_surface =
+ eglCreateWindowSurface(tri->egl->dpy,
+ tri->egl->conf,
+ tri->egl_window, NULL);
+#ifdef EGL_EXT_platform_base
+ }
+#endif
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 dcff578..4b95399 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -639,10 +639,21 @@ egl_window_surface_create(struct display *display,
rectangle->width,
rectangle->height);
- surface->egl_surface = eglCreateWindowSurface(display->dpy,
- display->argb_config,
- surface->egl_window,
- NULL);
+#ifdef EGL_EXT_platform_base
+ if (create_platform_window) {
+ surface->egl_surface =
+ create_platform_window(display->dpy,
+ display->argb_config,
+ surface->egl_window, NULL);
+ } else {
+#endif
+ surface->egl_surface =
+ eglCreateWindowSurface(display->dpy,
+ display->argb_config,
+ surface->egl_window, NULL);
+#ifdef EGL_EXT_platform_base
+ }
+#endif
surface->cairo_surface =
cairo_gl_surface_create_for_egl(display->argb_device,
@@ -5351,6 +5362,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
#ifndef EGL_PLATFORM_WAYLAND_KHR
@@ -5400,6 +5412,8 @@ init_egl(struct display *d)
|| strstr(extensions, "EGL_KHR_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 06f0db3..529d450 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
@@ -80,6 +81,8 @@ init_egl(struct test_data *test_data)
|| strstr(extensions, "EGL_KHR_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;
@@ -120,11 +123,23 @@ 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);
+
+#ifdef EGL_EXT_platform_base
+ if (create_platform_window) {
+ test_data->egl_surface =
+ create_platform_window(test_data->egl_dpy,
+ test_data->egl_conf,
+ (void *) native_window, NULL);
+ } else {
+#endif
+ test_data->egl_surface =
+ eglCreateWindowSurface(test_data->egl_dpy,
+ test_data->egl_conf,
+ (EGLNativeWindowType) native_window,
+ NULL);
+#ifdef EGL_EXT_platform_base
+ }
+#endif
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