From 4ed62d47cc0d14a6331d8e3190a9f67d0e5d7cac Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 20 Dec 2019 15:07:43 +1300 Subject: [PATCH] gl-renderer: Move EGL display creation to egl-glue.c It makes more sense for it to be there instead. Signed-off-by: Scott Anderson --- libweston/renderer-gl/egl-glue.c | 36 ++++++++++++++++++++ libweston/renderer-gl/gl-renderer-internal.h | 3 ++ libweston/renderer-gl/gl-renderer.c | 24 +------------ 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/libweston/renderer-gl/egl-glue.c b/libweston/renderer-gl/egl-glue.c index 4c426aa6..28be4ffe 100644 --- a/libweston/renderer-gl/egl-glue.c +++ b/libweston/renderer-gl/egl-glue.c @@ -455,6 +455,42 @@ gl_renderer_get_egl_config(struct gl_renderer *gr, return egl_config; } +int +gl_renderer_setup_egl_display(struct gl_renderer *gr, + void *native_display) +{ + gr->egl_display = NULL; + + /* extension_suffix is supported */ + if (gr->has_platform_base) + gr->egl_display = gr->get_platform_display(gr->platform, + native_display, + NULL); + + if (!gr->egl_display) { + weston_log("warning: either no EGL_EXT_platform_base " + "support or specific platform support; " + "falling back to eglGetDisplay.\n"); + gr->egl_display = eglGetDisplay(native_display); + } + + if (!gr->egl_display) { + weston_log("failed to create display\n"); + return -1; + } + + if (!eglInitialize(gr->egl_display, NULL, NULL)) { + weston_log("failed to initialize display\n"); + goto fail; + } + + return 0; + +fail: + gl_renderer_print_egl_error_state(); + return -1; +} + static const char * platform_to_extension(EGLenum platform) { diff --git a/libweston/renderer-gl/gl-renderer-internal.h b/libweston/renderer-gl/gl-renderer-internal.h index 9454fa03..6e1b095c 100644 --- a/libweston/renderer-gl/gl-renderer-internal.h +++ b/libweston/renderer-gl/gl-renderer-internal.h @@ -141,6 +141,9 @@ gl_renderer_get_egl_config(struct gl_renderer *gr, const uint32_t *drm_formats, unsigned drm_formats_count); +int +gl_renderer_setup_egl_display(struct gl_renderer *gr, void *native_display); + int gl_renderer_setup_egl_client_extensions(struct gl_renderer *gr); diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 29b68962..462f422c 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -3381,7 +3381,6 @@ gl_renderer_display_create(struct weston_compositor *ec, unsigned drm_formats_count) { struct gl_renderer *gr; - EGLint major, minor; gr = zalloc(sizeof *gr); if (gr == NULL) @@ -3401,30 +3400,9 @@ gl_renderer_display_create(struct weston_compositor *ec, gr->base.surface_get_content_size = gl_renderer_surface_get_content_size; gr->base.surface_copy_content = gl_renderer_surface_copy_content; - gr->egl_display = NULL; - /* extension_suffix is supported */ - if (gr->has_platform_base) - gr->egl_display = gr->get_platform_display(platform, - native_display, - NULL); - - if (!gr->egl_display) { - weston_log("warning: either no EGL_EXT_platform_base " - "support or specific platform support; " - "falling back to eglGetDisplay.\n"); - gr->egl_display = eglGetDisplay(native_display); - } - - if (!gr->egl_display) { - weston_log("failed to create display\n"); + if (gl_renderer_setup_egl_display(gr, native_display) < 0) goto fail; - } - - if (!eglInitialize(gr->egl_display, &major, &minor)) { - weston_log("failed to initialize display\n"); - goto fail_with_error; - } log_egl_info(gr->egl_display);