pixman-renderer, gl-renderer: Destroy debug bindings on clean up

Also make sure backends destroy the renderers before shutting down the
compositor to avoid a double call to weston_binding_destroy().

This is a step towards making renderers switchable during runtime.
This commit is contained in:
Ander Conselvan de Oliveira 2013-10-25 16:26:32 +03:00 committed by Kristian Høgsberg
parent c68b1085ed
commit 6b16214fb9
6 changed files with 31 additions and 13 deletions

View File

@ -2312,10 +2312,10 @@ drm_destroy(struct weston_compositor *ec)
destroy_sprites(d);
weston_compositor_shutdown(ec);
ec->renderer->destroy(ec);
weston_compositor_shutdown(ec);
if (d->gbm)
gbm_device_destroy(d->gbm);

View File

@ -798,11 +798,12 @@ fbdev_compositor_destroy(struct weston_compositor *base)
udev_input_destroy(&compositor->input);
compositor->base.renderer->destroy(&compositor->base);
/* Destroy the output. */
weston_compositor_shutdown(&compositor->base);
/* Chain up. */
compositor->base.renderer->destroy(&compositor->base);
weston_launcher_destroy(compositor->base.launcher);
free(compositor);

View File

@ -652,10 +652,11 @@ rpi_compositor_destroy(struct weston_compositor *base)
wl_list_for_each_safe(seat, next, &compositor->base.seat_list, link)
evdev_input_destroy(seat);
compositor->base.renderer->destroy(&compositor->base);
/* destroys outputs, too */
weston_compositor_shutdown(&compositor->base);
compositor->base.renderer->destroy(&compositor->base);
weston_launcher_destroy(compositor->base.launcher);
bcm_host_deinit();

View File

@ -1443,10 +1443,10 @@ x11_destroy(struct weston_compositor *ec)
wl_event_source_remove(compositor->xcb_source);
x11_input_destroy(compositor);
weston_compositor_shutdown(ec); /* destroys outputs, too */
ec->renderer->destroy(ec);
weston_compositor_shutdown(ec); /* destroys outputs, too */
XCloseDisplay(compositor->dpy);
free(ec);
}

View File

@ -85,6 +85,8 @@ struct gl_renderer {
struct weston_renderer base;
int fragment_shader_debug;
int fan_debug;
struct weston_binding *fragment_binding;
struct weston_binding *fan_binding;
EGLDisplay egl_display;
EGLContext egl_context;
@ -1567,6 +1569,9 @@ gl_renderer_destroy(struct weston_compositor *ec)
wl_array_release(&gr->indices);
wl_array_release(&gr->vtxcnt);
weston_binding_destroy(gr->fragment_binding);
weston_binding_destroy(gr->fan_binding);
free(gr);
}
@ -1859,10 +1864,14 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
if (compile_shaders(ec))
return -1;
weston_compositor_add_debug_binding(ec, KEY_S,
fragment_debug_binding, ec);
weston_compositor_add_debug_binding(ec, KEY_F,
fan_debug_repaint_binding, ec);
gr->fragment_binding =
weston_compositor_add_debug_binding(ec, KEY_S,
fragment_debug_binding,
ec);
gr->fan_binding =
weston_compositor_add_debug_binding(ec, KEY_F,
fan_debug_repaint_binding,
ec);
weston_log("GL ES 2 renderer features:\n");
weston_log_continue(STAMP_SPACE "read-back format: %s\n",

View File

@ -43,8 +43,10 @@ struct pixman_surface_state {
struct pixman_renderer {
struct weston_renderer base;
int repaint_debug;
pixman_image_t *debug_color;
struct weston_binding *debug_binding;
};
static inline struct pixman_output_state *
@ -630,7 +632,11 @@ pixman_renderer_destroy_surface(struct weston_surface *surface)
static void
pixman_renderer_destroy(struct weston_compositor *ec)
{
free(ec->renderer);
struct pixman_renderer *pr = get_renderer(ec);
weston_binding_destroy(pr->debug_binding);
free(pr);
ec->renderer = NULL;
}
@ -678,8 +684,9 @@ pixman_renderer_init(struct weston_compositor *ec)
ec->capabilities |= WESTON_CAP_ROTATION_ANY;
ec->capabilities |= WESTON_CAP_CAPTURE_YFLIP;
weston_compositor_add_debug_binding(ec, KEY_R,
debug_binding, ec);
renderer->debug_binding =
weston_compositor_add_debug_binding(ec, KEY_R,
debug_binding, ec);
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_RGB565);