From 77254154782fbe3557e2db712ea023526b99a8c6 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 20 Dec 2019 14:39:38 +1300 Subject: [PATCH] gl-renderer: Move get_platform_display to EGL client setup This is to put more of the EGL client extension handling in the same place. This also adds a boolean to check if EGL_EXT_platform_base is supported, similar to other extensions we check. Signed-off-by: Scott Anderson --- libweston/renderer-gl/egl-glue.c | 8 +++++-- libweston/renderer-gl/gl-renderer-internal.h | 3 +++ libweston/renderer-gl/gl-renderer.c | 24 ++++---------------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/libweston/renderer-gl/egl-glue.c b/libweston/renderer-gl/egl-glue.c index aea2b23c..1620ab4e 100644 --- a/libweston/renderer-gl/egl-glue.c +++ b/libweston/renderer-gl/egl-glue.c @@ -466,11 +466,15 @@ gl_renderer_setup_egl_client_extensions(struct gl_renderer *gr) return; } - if (weston_check_egl_extension(extensions, "EGL_EXT_platform_base")) + if (weston_check_egl_extension(extensions, "EGL_EXT_platform_base")) { + gr->get_platform_display = + (void *) eglGetProcAddress("eglGetPlatformDisplayEXT"); gr->create_platform_window = (void *) eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT"); - else + gr->has_platform_base = true; + } else { weston_log("warning: EGL_EXT_platform_base not supported.\n"); + } } int diff --git a/libweston/renderer-gl/gl-renderer-internal.h b/libweston/renderer-gl/gl-renderer-internal.h index f38bc344..b8127f93 100644 --- a/libweston/renderer-gl/gl-renderer-internal.h +++ b/libweston/renderer-gl/gl-renderer-internal.h @@ -63,7 +63,10 @@ struct gl_renderer { PFNEGLCREATEIMAGEKHRPROC create_image; PFNEGLDESTROYIMAGEKHRPROC destroy_image; PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC swap_buffers_with_damage; + + PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display; PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC create_platform_window; + bool has_platform_base; bool has_unpack_subimage; diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index d481134a..e5285e28 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -209,8 +209,6 @@ struct timeline_render_point { struct wl_event_source *event_source; }; -static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL; - static inline const char * dump_format(uint32_t format, char out[4]) { @@ -3495,22 +3493,10 @@ gl_renderer_display_create(struct weston_compositor *ec, gr->egl_display = NULL; /* extension_suffix is supported */ - if (supports) { - if (!get_platform_display) { - get_platform_display = (void *) eglGetProcAddress( - "eglGetPlatformDisplayEXT"); - } - - /* also wrap this in the supports check because - * eglGetProcAddress can return non-NULL and still not - * support the feature at runtime, so ensure the - * appropriate extension checks have been done. */ - if (get_platform_display && platform) { - gr->egl_display = get_platform_display(platform, - native_display, - NULL); - } - } + if (gr->has_platform_base && supports) + gr->egl_display = gr->get_platform_display(platform, + native_display, + NULL); if (!gr->egl_display) { weston_log("warning: either no EGL_EXT_platform_base " @@ -3519,7 +3505,7 @@ gl_renderer_display_create(struct weston_compositor *ec, gr->egl_display = eglGetDisplay(native_display); } - if (gr->egl_display == EGL_NO_DISPLAY) { + if (!gr->egl_display) { weston_log("failed to create display\n"); goto fail; }