[PATCH 2/7] pixman-renderer, gl-renderer: Destroy debug bindings on clean up
Ander Conselvan de Oliveira
ander.conselvan.de.oliveira at intel.com
Fri Oct 25 15:26:32 CEST 2013
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.
---
src/compositor-drm.c | 4 ++--
src/compositor-fbdev.c | 3 ++-
src/compositor-rpi.c | 3 ++-
src/compositor-x11.c | 4 ++--
src/gl-renderer.c | 17 +++++++++++++----
src/pixman-renderer.c | 13 ++++++++++---
6 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 461fce7..b929728 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -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);
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index dc650f0..09f165b 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -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);
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index cd24a08..f163e01 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -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();
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index d99bde5..ee3df31 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -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);
}
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 2cb24fa..0f0b5f7 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -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",
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index d6f638d..0d85e07 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -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);
--
1.7.9.5
More information about the wayland-devel
mailing list