compositor-headless: Use non-cast functions to retrieve backend and output objects

This uses container_of instead of explicit cast to retrieve
backend and output objects from generic weston_backend and
weston_output pointers.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Armin Krezović 2016-08-01 19:17:55 +02:00 committed by Pekka Paalanen
parent 984781f302
commit a8fb5eaa4e
1 changed files with 16 additions and 4 deletions

View File

@ -55,6 +55,18 @@ struct headless_output {
pixman_image_t *image; pixman_image_t *image;
}; };
static inline struct headless_output *
to_headless_output(struct weston_output *base)
{
return container_of(base, struct headless_output, base);
}
static inline struct headless_backend *
to_headless_backend(struct weston_compositor *base)
{
return container_of(base->backend, struct headless_backend, base);
}
static void static void
headless_output_start_repaint_loop(struct weston_output *output) headless_output_start_repaint_loop(struct weston_output *output)
{ {
@ -80,7 +92,7 @@ static int
headless_output_repaint(struct weston_output *output_base, headless_output_repaint(struct weston_output *output_base,
pixman_region32_t *damage) pixman_region32_t *damage)
{ {
struct headless_output *output = (struct headless_output *) output_base; struct headless_output *output = to_headless_output(output_base);
struct weston_compositor *ec = output->base.compositor; struct weston_compositor *ec = output->base.compositor;
ec->renderer->repaint_output(&output->base, damage); ec->renderer->repaint_output(&output->base, damage);
@ -96,9 +108,9 @@ headless_output_repaint(struct weston_output *output_base,
static void static void
headless_output_destroy(struct weston_output *output_base) headless_output_destroy(struct weston_output *output_base)
{ {
struct headless_output *output = (struct headless_output *) output_base; struct headless_output *output = to_headless_output(output_base);
struct headless_backend *b = struct headless_backend *b =
(struct headless_backend *) output->base.compositor->backend; to_headless_backend(output->base.compositor);
wl_event_source_remove(output->finish_frame_timer); wl_event_source_remove(output->finish_frame_timer);
@ -185,7 +197,7 @@ headless_restore(struct weston_compositor *ec)
static void static void
headless_destroy(struct weston_compositor *ec) headless_destroy(struct weston_compositor *ec)
{ {
struct headless_backend *b = (struct headless_backend *) ec->backend; struct headless_backend *b = to_headless_backend(ec);
weston_compositor_shutdown(ec); weston_compositor_shutdown(ec);