backend-headless: refactor into headless_output_enable_pixman
Pure refactoring. Preparing for adding GL-renderer. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
@@ -153,47 +153,57 @@ 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);
|
output->image_buf = malloc(output->base.current_mode->width *
|
||||||
struct headless_backend *b = to_headless_backend(base->compositor);
|
output->base.current_mode->height * 4);
|
||||||
struct wl_event_loop *loop;
|
if (!output->image_buf)
|
||||||
|
return -1;
|
||||||
|
|
||||||
loop = wl_display_get_event_loop(b->compositor->wl_display);
|
output->image = pixman_image_create_bits(PIXMAN_x8r8g8b8,
|
||||||
output->finish_frame_timer =
|
output->base.current_mode->width,
|
||||||
wl_event_loop_add_timer(loop, finish_frame_handler, output);
|
output->base.current_mode->height,
|
||||||
|
output->image_buf,
|
||||||
|
output->base.current_mode->width * 4);
|
||||||
|
|
||||||
if (b->use_pixman) {
|
if (pixman_renderer_output_create(&output->base,
|
||||||
output->image_buf = malloc(output->base.current_mode->width *
|
PIXMAN_RENDERER_OUTPUT_USE_SHADOW) < 0)
|
||||||
output->base.current_mode->height * 4);
|
goto err_renderer;
|
||||||
if (!output->image_buf)
|
|
||||||
goto err_malloc;
|
|
||||||
|
|
||||||
output->image = pixman_image_create_bits(PIXMAN_x8r8g8b8,
|
pixman_renderer_output_set_buffer(&output->base, output->image);
|
||||||
output->base.current_mode->width,
|
|
||||||
output->base.current_mode->height,
|
|
||||||
output->image_buf,
|
|
||||||
output->base.current_mode->width * 4);
|
|
||||||
|
|
||||||
if (pixman_renderer_output_create(&output->base,
|
|
||||||
PIXMAN_RENDERER_OUTPUT_USE_SHADOW) < 0)
|
|
||||||
goto err_renderer;
|
|
||||||
|
|
||||||
pixman_renderer_output_set_buffer(&output->base,
|
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user