[PATCH weston 4/4] clients & tests: use eglCreatePlatformWindowSurfaceEXT when supported
Jonny Lamb
jonny.lamb at collabora.co.uk
Thu Mar 19 07:07:14 PDT 2015
Reviewed-by: Derek Foreman <derekf at osg.samsung.com>
---
clients/nested-client.c | 7 +++----
clients/simple-egl.c | 7 ++++---
clients/subsurfaces.c | 6 +++---
clients/window.c | 8 ++++----
shared/platform.h | 23 +++++++++++++++++++++++
tests/buffer-count-test.c | 7 +++----
6 files changed, 40 insertions(+), 18 deletions(-)
diff --git a/clients/nested-client.c b/clients/nested-client.c
index 96cf1c8..5195831 100644
--- a/clients/nested-client.c
+++ b/clients/nested-client.c
@@ -307,10 +307,9 @@ 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);
+ client->egl_surface = weston_platform_create_egl_window (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 33e02e7..1a0724d 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -386,9 +386,10 @@ create_surface(struct window *window)
window->geometry.width,
window->geometry.height);
window->egl_surface =
- eglCreateWindowSurface(display->egl.dpy,
- display->egl.conf,
- window->native, NULL);
+ weston_platform_create_egl_window(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 5b8fd8d..130fe4c 100644
--- a/clients/subsurfaces.c
+++ b/clients/subsurfaces.c
@@ -422,9 +422,9 @@ 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);
+ tri->egl_surface = weston_platform_create_egl_window(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 4381769..bfa5115 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -640,10 +640,10 @@ egl_window_surface_create(struct display *display,
rectangle->width,
rectangle->height);
- surface->egl_surface = eglCreateWindowSurface(display->dpy,
- display->argb_config,
- surface->egl_window,
- NULL);
+ surface->egl_surface =
+ weston_platform_create_egl_window(display->dpy,
+ display->argb_config,
+ surface->egl_window, NULL);
surface->cairo_surface =
cairo_gl_surface_create_for_egl(display->argb_device,
diff --git a/shared/platform.h b/shared/platform.h
index 7f847fa..df310c2 100644
--- a/shared/platform.h
+++ b/shared/platform.h
@@ -34,6 +34,7 @@ extern "C" {
#ifdef EGL_EXT_platform_base
static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display_ext = NULL;
+static PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC create_platform_window_surface_ext = NULL;
#ifndef EGL_PLATFORM_WAYLAND_KHR
#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
@@ -51,6 +52,8 @@ weston_platform_get_egl_proc_addresses(void)
|| strstr(extensions, "EGL_KHR_platform_wayland")) {
get_platform_display_ext =
(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
+ create_platform_window_surface_ext =
+ (void *) eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
}
}
#endif
@@ -72,6 +75,26 @@ weston_platform_get_egl_display(EGLenum platform, void *native_display,
return eglGetDisplay((EGLNativeDisplayType) native_display);
}
+static inline EGLSurface
+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();
+
+ if (create_platform_window_surface_ext)
+ return create_platform_window_surface_ext(dpy, config,
+ native_window,
+ attrib_list);
+ else
+#endif
+ return eglCreateWindowSurface(dpy, config,
+ (EGLNativeWindowType) native_window,
+ attrib_list);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/tests/buffer-count-test.c b/tests/buffer-count-test.c
index 815e1cc..23cbc6e 100644
--- a/tests/buffer-count-test.c
+++ b/tests/buffer-count-test.c
@@ -95,10 +95,9 @@ init_egl(struct test_data *test_data)
surface->width,
surface->height);
test_data->egl_surface =
- eglCreateWindowSurface(test_data->egl_dpy,
- test_data->egl_conf,
- (EGLNativeWindowType) native_window,
- NULL);
+ weston_platform_create_egl_window(test_data->egl_dpy,
+ test_data->egl_conf,
+ 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