aboutsummaryrefslogtreecommitdiff
path: root/backend/headless/output.c
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-09-17 21:46:39 +0200
committeremersion <contact@emersion.fr>2018-09-18 11:01:53 +0200
commitbc34486c04a035079ea808532f311a02659642c1 (patch)
treea1d2b2539615408ddbc76be0fa8e876f577a1050 /backend/headless/output.c
parent9288c827aaf4ae8acac7a105f223dc612822b76d (diff)
backend/headless: add assertions
Diffstat (limited to 'backend/headless/output.c')
-rw-r--r--backend/headless/output.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/backend/headless/output.c b/backend/headless/output.c
index 24fc3bfd..143900d4 100644
--- a/backend/headless/output.c
+++ b/backend/headless/output.c
@@ -1,3 +1,4 @@
+#include <assert.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <stdlib.h>
@@ -7,6 +8,12 @@
#include "backend/headless.h"
#include "util/signal.h"
+static struct wlr_headless_output *headless_output_from_output(
+ struct wlr_output *wlr_output) {
+ assert(wlr_output_is_headless(wlr_output));
+ return (struct wlr_headless_output *)wlr_output;
+}
+
static EGLSurface egl_create_surface(struct wlr_egl *egl, unsigned int width,
unsigned int height) {
EGLint attribs[] = {EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE};
@@ -22,7 +29,7 @@ static EGLSurface egl_create_surface(struct wlr_egl *egl, unsigned int width,
static bool output_set_custom_mode(struct wlr_output *wlr_output, int32_t width,
int32_t height, int32_t refresh) {
struct wlr_headless_output *output =
- (struct wlr_headless_output *)wlr_output;
+ headless_output_from_output(wlr_output);
struct wlr_headless_backend *backend = output->backend;
if (refresh <= 0) {
@@ -47,13 +54,13 @@ static bool output_set_custom_mode(struct wlr_output *wlr_output, int32_t width,
static void output_transform(struct wlr_output *wlr_output,
enum wl_output_transform transform) {
struct wlr_headless_output *output =
- (struct wlr_headless_output *)wlr_output;
+ headless_output_from_output(wlr_output);
output->wlr_output.transform = transform;
}
static bool output_make_current(struct wlr_output *wlr_output, int *buffer_age) {
struct wlr_headless_output *output =
- (struct wlr_headless_output *)wlr_output;
+ headless_output_from_output(wlr_output);
return wlr_egl_make_current(&output->backend->egl, output->egl_surface,
buffer_age);
}
@@ -65,7 +72,7 @@ static bool output_swap_buffers(struct wlr_output *wlr_output,
static void output_destroy(struct wlr_output *wlr_output) {
struct wlr_headless_output *output =
- (struct wlr_headless_output *)wlr_output;
+ headless_output_from_output(wlr_output);
wl_list_remove(&output->link);
@@ -97,7 +104,7 @@ static int signal_frame(void *data) {
struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
unsigned int width, unsigned int height) {
struct wlr_headless_backend *backend =
- (struct wlr_headless_backend *)wlr_backend;
+ headless_backend_from_backend(wlr_backend);
struct wlr_headless_output *output =
calloc(1, sizeof(struct wlr_headless_output));