summaryrefslogtreecommitdiff
path: root/src/pixman-renderer.c
diff options
context:
space:
mode:
authorAnder Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>2013-10-25 16:26:33 +0300
committerKristian Høgsberg <krh@bitplanet.net>2013-10-25 12:21:51 -0700
commitaa398ae1f333306e25f681846749696bf1936f8e (patch)
treebb23c34aaffe29315d5902e17b526ec8f9357365 /src/pixman-renderer.c
parent6b16214fb93cdea23f2f79409070fd16b6845a5b (diff)
downloadweston-aa398ae1f333306e25f681846749696bf1936f8e.tar.gz
compositor: Let renderers create and destroy surface state on their own
Remove create_surface() and destroy_surface() from the renderer interface and change the renderers to create surface state on demand and destroy it using the weston_surface's destroy signal. Also make sure the surfaces' renderer state is reset to NULL on destruction. This is a step towards runtime switchable renderers. (rpi-renderer changes are only compile-tested)
Diffstat (limited to 'src/pixman-renderer.c')
-rw-r--r--src/pixman-renderer.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index 0d85e07f..98a910ce 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -37,8 +37,12 @@ struct pixman_output_state {
};
struct pixman_surface_state {
+ struct weston_surface *surface;
+
pixman_image_t *image;
struct weston_buffer_reference buffer_ref;
+
+ struct wl_listener surface_destroy_listener;
};
struct pixman_renderer {
@@ -55,9 +59,15 @@ get_output_state(struct weston_output *output)
return (struct pixman_output_state *)output->renderer_state;
}
+static int
+pixman_renderer_create_surface(struct weston_surface *surface);
+
static inline struct pixman_surface_state *
get_surface_state(struct weston_surface *surface)
{
+ if (!surface->renderer_state)
+ pixman_renderer_create_surface(surface);
+
return (struct pixman_surface_state *)surface->renderer_state;
}
@@ -582,6 +592,24 @@ pixman_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
wl_shm_buffer_get_stride(shm_buffer));
}
+static void
+surface_state_handle_surface_destroy(struct wl_listener *listener, void *data)
+{
+ struct pixman_surface_state *ps;
+
+ ps = container_of(listener, struct pixman_surface_state,
+ surface_destroy_listener);
+
+ ps->surface->renderer_state = NULL;
+
+ if (ps->image) {
+ pixman_image_unref(ps->image);
+ ps->image = NULL;
+ }
+ weston_buffer_reference(&ps->buffer_ref, NULL);
+ free(ps);
+}
+
static int
pixman_renderer_create_surface(struct weston_surface *surface)
{
@@ -593,6 +621,13 @@ pixman_renderer_create_surface(struct weston_surface *surface)
surface->renderer_state = ps;
+ ps->surface = surface;
+
+ ps->surface_destroy_listener.notify =
+ surface_state_handle_surface_destroy;
+ wl_signal_add(&surface->destroy_signal,
+ &ps->surface_destroy_listener);
+
return 0;
}
@@ -617,19 +652,6 @@ pixman_renderer_surface_set_color(struct weston_surface *es,
}
static void
-pixman_renderer_destroy_surface(struct weston_surface *surface)
-{
- struct pixman_surface_state *ps = get_surface_state(surface);
-
- if (ps->image) {
- pixman_image_unref(ps->image);
- ps->image = NULL;
- }
- weston_buffer_reference(&ps->buffer_ref, NULL);
- free(ps);
-}
-
-static void
pixman_renderer_destroy(struct weston_compositor *ec)
{
struct pixman_renderer *pr = get_renderer(ec);
@@ -676,9 +698,7 @@ pixman_renderer_init(struct weston_compositor *ec)
renderer->base.repaint_output = pixman_renderer_repaint_output;
renderer->base.flush_damage = pixman_renderer_flush_damage;
renderer->base.attach = pixman_renderer_attach;
- renderer->base.create_surface = pixman_renderer_create_surface;
renderer->base.surface_set_color = pixman_renderer_surface_set_color;
- renderer->base.destroy_surface = pixman_renderer_destroy_surface;
renderer->base.destroy = pixman_renderer_destroy;
ec->renderer = &renderer->base;
ec->capabilities |= WESTON_CAP_ROTATION_ANY;