backend-headless: refactor into headless_output_enable_pixman

Pure refactoring. Preparing for adding GL-renderer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 5 years ago
parent b984a158d6
commit 4b0688fd77
  1. 42
      libweston/backend-headless/headless.c

@ -153,21 +153,12 @@ headless_output_destroy(struct weston_output *base)
} }
static int static int
headless_output_enable(struct weston_output *base) headless_output_enable_pixman(struct headless_output *output)
{ {
struct headless_output *output = to_headless_output(base);
struct headless_backend *b = to_headless_backend(base->compositor);
struct wl_event_loop *loop;
loop = wl_display_get_event_loop(b->compositor->wl_display);
output->finish_frame_timer =
wl_event_loop_add_timer(loop, finish_frame_handler, output);
if (b->use_pixman) {
output->image_buf = malloc(output->base.current_mode->width * output->image_buf = malloc(output->base.current_mode->width *
output->base.current_mode->height * 4); output->base.current_mode->height * 4);
if (!output->image_buf) if (!output->image_buf)
goto err_malloc; return -1;
output->image = pixman_image_create_bits(PIXMAN_x8r8g8b8, output->image = pixman_image_create_bits(PIXMAN_x8r8g8b8,
output->base.current_mode->width, output->base.current_mode->width,
@ -179,21 +170,40 @@ headless_output_enable(struct weston_output *base)
PIXMAN_RENDERER_OUTPUT_USE_SHADOW) < 0) PIXMAN_RENDERER_OUTPUT_USE_SHADOW) < 0)
goto err_renderer; goto err_renderer;
pixman_renderer_output_set_buffer(&output->base, pixman_renderer_output_set_buffer(&output->base, output->image);
output->image);
}
return 0; return 0;
err_renderer: err_renderer:
pixman_image_unref(output->image); pixman_image_unref(output->image);
free(output->image_buf); free(output->image_buf);
err_malloc:
wl_event_source_remove(output->finish_frame_timer);
return -1; return -1;
} }
static int
headless_output_enable(struct weston_output *base)
{
struct headless_output *output = to_headless_output(base);
struct headless_backend *b = to_headless_backend(base->compositor);
struct wl_event_loop *loop;
int ret = 0;
loop = wl_display_get_event_loop(b->compositor->wl_display);
output->finish_frame_timer =
wl_event_loop_add_timer(loop, finish_frame_handler, output);
if (b->use_pixman)
ret = headless_output_enable_pixman(output);
if (ret < 0) {
wl_event_source_remove(output->finish_frame_timer);
return -1;
}
return 0;
}
static int static int
headless_output_set_size(struct weston_output *base, headless_output_set_size(struct weston_output *base,
int width, int height) int width, int height)

Loading…
Cancel
Save