gl-renderer: Make dummy surface current after all outputs are gone

When all outputs are gone, there are no current read/write
surfaces associated with a context. This makes the previously
created dummy surface current until an output gets attached
to avoid any potential crashes.

v2:

- Remove unnecessary objects

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Armin Krezović 8 years ago committed by Pekka Paalanen
parent e54038497d
commit 36d699a164
  1. 22
      libweston/gl-renderer.c

@ -217,6 +217,8 @@ struct gl_renderer {
struct gl_shader *current_shader; struct gl_shader *current_shader;
struct wl_signal destroy_signal; struct wl_signal destroy_signal;
struct wl_listener output_destroy_listener;
}; };
static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL; static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
@ -2643,6 +2645,8 @@ gl_renderer_destroy(struct weston_compositor *ec)
eglTerminate(gr->egl_display); eglTerminate(gr->egl_display);
eglReleaseThread(); eglReleaseThread();
wl_list_remove(&gr->output_destroy_listener.link);
wl_array_release(&gr->vertices); wl_array_release(&gr->vertices);
wl_array_release(&gr->vtxcnt); wl_array_release(&gr->vtxcnt);
@ -2828,6 +2832,20 @@ platform_to_extension(EGLenum platform)
} }
} }
static void
output_handle_destroy(struct wl_listener *listener, void *data)
{
struct gl_renderer *gr;
struct weston_output *output = data;
gr = container_of(listener, struct gl_renderer,
output_destroy_listener);
if (wl_list_empty(&output->compositor->output_list))
eglMakeCurrent(gr->egl_display, gr->dummy_surface,
gr->dummy_surface, gr->egl_context);
}
static int static int
gl_renderer_create_pbuffer_surface(struct gl_renderer *gr) { gl_renderer_create_pbuffer_surface(struct gl_renderer *gr) {
EGLConfig pbuffer_config; EGLConfig pbuffer_config;
@ -3137,6 +3155,10 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
fan_debug_repaint_binding, fan_debug_repaint_binding,
ec); ec);
gr->output_destroy_listener.notify = output_handle_destroy;
wl_signal_add(&ec->output_destroyed_signal,
&gr->output_destroy_listener);
weston_log("GL ES 2 renderer features:\n"); weston_log("GL ES 2 renderer features:\n");
weston_log_continue(STAMP_SPACE "read-back format: %s\n", weston_log_continue(STAMP_SPACE "read-back format: %s\n",
ec->read_format == PIXMAN_a8r8g8b8 ? "BGRA" : "RGBA"); ec->read_format == PIXMAN_a8r8g8b8 ? "BGRA" : "RGBA");

Loading…
Cancel
Save