summaryrefslogtreecommitdiff
path: root/libweston
diff options
context:
space:
mode:
authorArmin Krezović <krezovic.armin@gmail.com>2016-08-01 19:17:55 +0200
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2016-08-05 16:40:05 +0300
commita8fb5eaa4e45192aa41ac7d85da5ae217a370a1a (patch)
tree5b415a72d4e0de367084fde6e03b4669cd75b0fe /libweston
parent984781f302b12cdbc9cb252d84185676520dffc0 (diff)
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>
Diffstat (limited to 'libweston')
-rw-r--r--libweston/compositor-headless.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/libweston/compositor-headless.c b/libweston/compositor-headless.c
index e514b17c..8b51207a 100644
--- a/libweston/compositor-headless.c
+++ b/libweston/compositor-headless.c
@@ -55,6 +55,18 @@ struct headless_output {
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
headless_output_start_repaint_loop(struct weston_output *output)
{
@@ -80,7 +92,7 @@ static int
headless_output_repaint(struct weston_output *output_base,
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;
ec->renderer->repaint_output(&output->base, damage);
@@ -96,9 +108,9 @@ headless_output_repaint(struct weston_output *output_base,
static void
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 *) output->base.compositor->backend;
+ to_headless_backend(output->base.compositor);
wl_event_source_remove(output->finish_frame_timer);
@@ -185,7 +197,7 @@ headless_restore(struct weston_compositor *ec)
static void
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);