aboutsummaryrefslogtreecommitdiff
path: root/backend/headless/backend.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-09-18 14:44:46 -0400
committerGitHub <noreply@github.com>2018-09-18 14:44:46 -0400
commit3693fae0c44d83cab2c701bd44b80d8f6242781e (patch)
tree407d120898ff0a4c64de9a2d180ad07bd0d67e36 /backend/headless/backend.c
parent9288c827aaf4ae8acac7a105f223dc612822b76d (diff)
parent139a905924e9c6cd22613dfbbe73c4642c993e41 (diff)
Merge pull request #1248 from emersion/assert-all-the-things
Assert all the things!
Diffstat (limited to 'backend/headless/backend.c')
-rw-r--r--backend/headless/backend.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/backend/headless/backend.c b/backend/headless/backend.c
index 0138166d..cbc158f3 100644
--- a/backend/headless/backend.c
+++ b/backend/headless/backend.c
@@ -1,4 +1,4 @@
-#include "util/signal.h"
+#include <assert.h>
#include <stdlib.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_output.h>
@@ -7,10 +7,17 @@
#include <wlr/util/log.h>
#include "backend/headless.h"
#include "glapi.h"
+#include "util/signal.h"
+
+struct wlr_headless_backend *headless_backend_from_backend(
+ struct wlr_backend *wlr_backend) {
+ assert(wlr_backend_is_headless(wlr_backend));
+ return (struct wlr_headless_backend *)wlr_backend;
+}
static bool backend_start(struct wlr_backend *wlr_backend) {
struct wlr_headless_backend *backend =
- (struct wlr_headless_backend *)wlr_backend;
+ headless_backend_from_backend(wlr_backend);
wlr_log(WLR_INFO, "Starting headless backend");
struct wlr_headless_output *output;
@@ -34,7 +41,7 @@ static bool backend_start(struct wlr_backend *wlr_backend) {
static void backend_destroy(struct wlr_backend *wlr_backend) {
struct wlr_headless_backend *backend =
- (struct wlr_headless_backend *)wlr_backend;
+ headless_backend_from_backend(wlr_backend);
if (!wlr_backend) {
return;
}
@@ -62,7 +69,7 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
static struct wlr_renderer *backend_get_renderer(
struct wlr_backend *wlr_backend) {
struct wlr_headless_backend *backend =
- (struct wlr_headless_backend *)wlr_backend;
+ headless_backend_from_backend(wlr_backend);
return backend->renderer;
}
@@ -107,9 +114,8 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display,
create_renderer_func = wlr_renderer_autocreate;
}
- backend->renderer = create_renderer_func(&backend->egl, EGL_PLATFORM_SURFACELESS_MESA,
- NULL, (EGLint*)config_attribs, 0);
-
+ backend->renderer = create_renderer_func(&backend->egl,
+ EGL_PLATFORM_SURFACELESS_MESA, NULL, (EGLint*)config_attribs, 0);
if (!backend->renderer) {
wlr_log(WLR_ERROR, "Failed to create renderer");
free(backend);