summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2015-09-07 12:17:40 -0700
committerJason Ekstrand <jason.ekstrand@intel.com>2015-09-08 10:57:25 -0700
commit803ed1ab0c2f3cab57f6c3ebccb1cf7189ec9f42 (patch)
treec1cd4097c7f9036d0591b0a59955ca32edcb62ad
parent76287896408841428804ab94dce2adb8b0b896e3 (diff)
compositor-x11: Make which renderer we are using an enum
Previously, we just had a use_pixman boolean but soon we will have more than two so a boolean no longer suffices.
-rw-r--r--src/compositor-x11.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 1c53e3b5..3922669e 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -65,6 +65,11 @@ static int option_height;
static int option_scale;
static int option_count;
+enum x11_renderer {
+ X11_RENDERER_PIXMAN,
+ X11_RENDERER_GL,
+};
+
struct x11_backend {
struct weston_backend base;
struct weston_compositor *compositor;
@@ -78,7 +83,7 @@ struct x11_backend {
struct xkb_keymap *xkb_keymap;
unsigned int has_xkb;
uint8_t xkb_event_base;
- int use_pixman;
+ enum x11_renderer renderer;
int has_net_wm_state_fullscreen;
@@ -501,11 +506,15 @@ x11_output_destroy(struct weston_output *output_base)
wl_event_source_remove(output->finish_frame_timer);
- if (backend->use_pixman) {
+ switch (backend->renderer) {
+ case X11_RENDERER_PIXMAN:
pixman_renderer_output_destroy(output_base);
x11_output_deinit_shm(backend, output);
- } else
+ break;
+ case X11_RENDERER_GL:
gl_renderer->output_destroy(output_base);
+ break;
+ }
xcb_destroy_window(backend->conn, output->window);
@@ -878,10 +887,12 @@ x11_backend_create_output(struct x11_backend *b, int x, int y,
x11_output_wait_for_map(b, output);
output->base.start_repaint_loop = x11_output_start_repaint_loop;
- if (b->use_pixman)
+ switch (b->renderer) {
+ case X11_RENDERER_PIXMAN:
output->base.repaint = x11_output_repaint_shm;
- else
+ case X11_RENDERER_GL:
output->base.repaint = x11_output_repaint_gl;
+ }
output->base.destroy = x11_output_destroy;
output->base.assign_planes = NULL;
output->base.set_backlight = NULL;
@@ -901,7 +912,8 @@ x11_backend_create_output(struct x11_backend *b, int x, int y,
weston_output_init(&output->base, b->compositor,
x, y, width_mm, height_mm, transform, scale);
- if (b->use_pixman) {
+ switch (b->renderer) {
+ case X11_RENDERER_PIXMAN:
if (x11_output_init_shm(b, output,
output->mode.width,
output->mode.height) < 0) {
@@ -913,7 +925,9 @@ x11_backend_create_output(struct x11_backend *b, int x, int y,
x11_output_deinit_shm(b, output);
return NULL;
}
- } else {
+ break;
+
+ case X11_RENDERER_GL: {
/* eglCreatePlatformWindowSurfaceEXT takes a Window*
* but eglCreateWindowSurface takes a Window. */
Window xid = (Window) output->window;
@@ -926,6 +940,8 @@ x11_backend_create_output(struct x11_backend *b, int x, int y,
0);
if (ret < 0)
return NULL;
+ break;
+ }
}
loop = wl_display_get_event_loop(b->compositor->wl_display);
@@ -1569,17 +1585,20 @@ x11_backend_create(struct weston_compositor *compositor,
fullscreen = 0;
}
- b->use_pixman = use_pixman;
- if (b->use_pixman) {
+ if (use_pixman) {
if (pixman_renderer_init(compositor) < 0) {
weston_log("Failed to initialize pixman renderer for X11 backend\n");
goto err_xdisplay;
}
+ b->renderer = X11_RENDERER_PIXMAN;
+ weston_log("Using pixman renderer\n");
}
- else if (init_gl_renderer(b) < 0) {
+ else if (init_gl_renderer(b) >= 0) {
+ b->renderer = X11_RENDERER_GL;
+ weston_log("Using GL renderer\n");
+ } else {
goto err_xdisplay;
}
- weston_log("Using %s renderer\n", use_pixman ? "pixman" : "gl");
b->base.destroy = x11_destroy;
b->base.restore = x11_restore;