pixman-renderer: Replace output-create flags with struct

pixman_renderer_output_create currently takes a flags enum bitmask for
its options. Switch this to using a structure, so we can introduce other
non-boolean options.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2020-03-06 12:46:30 +00:00 committed by Pekka Paalanen
parent 786490cb53
commit 61abf35ec4
8 changed files with 39 additions and 23 deletions

View File

@ -1179,7 +1179,9 @@ drm_output_init_pixman(struct drm_output *output, struct drm_backend *b)
uint32_t format = output->gbm_format;
uint32_t pixman_format;
unsigned int i;
uint32_t flags = 0;
const struct pixman_renderer_output_options options = {
.use_shadow = b->use_pixman_shadow,
};
switch (format) {
case DRM_FORMAT_XRGB8888:
@ -1207,10 +1209,7 @@ drm_output_init_pixman(struct drm_output *output, struct drm_backend *b)
goto err;
}
if (b->use_pixman_shadow)
flags |= PIXMAN_RENDERER_OUTPUT_USE_SHADOW;
if (pixman_renderer_output_create(&output->base, flags) < 0)
if (pixman_renderer_output_create(&output->base, &options) < 0)
goto err;
weston_log("DRM: output %s %s shadow framebuffer.\n", output->base.name,

View File

@ -528,6 +528,9 @@ fbdev_output_enable(struct weston_output *base)
struct fbdev_head *head;
int fb_fd;
struct wl_event_loop *loop;
const struct pixman_renderer_output_options options = {
.use_shadow = true,
};
head = fbdev_output_get_head(output);
@ -546,8 +549,7 @@ fbdev_output_enable(struct weston_output *base)
output->base.start_repaint_loop = fbdev_output_start_repaint_loop;
output->base.repaint = fbdev_output_repaint;
if (pixman_renderer_output_create(&output->base,
PIXMAN_RENDERER_OUTPUT_USE_SHADOW) < 0)
if (pixman_renderer_output_create(&output->base, &options) < 0)
goto out_hw_surface;
loop = wl_display_get_event_loop(backend->compositor->wl_display);

View File

@ -214,6 +214,10 @@ headless_output_enable_gl(struct headless_output *output)
static int
headless_output_enable_pixman(struct headless_output *output)
{
const struct pixman_renderer_output_options options = {
.use_shadow = true,
};
output->image_buf = malloc(output->base.current_mode->width *
output->base.current_mode->height * 4);
if (!output->image_buf)
@ -225,8 +229,7 @@ headless_output_enable_pixman(struct headless_output *output)
output->image_buf,
output->base.current_mode->width * 4);
if (pixman_renderer_output_create(&output->base,
PIXMAN_RENDERER_OUTPUT_USE_SHADOW) < 0)
if (pixman_renderer_output_create(&output->base, &options) < 0)
goto err_renderer;
pixman_renderer_output_set_buffer(&output->base, output->image);

View File

@ -468,6 +468,7 @@ rdp_switch_mode(struct weston_output *output, struct weston_mode *target_mode)
rdpSettings *settings;
pixman_image_t *new_shadow_buffer;
struct weston_mode *local_mode;
const struct pixman_renderer_output_options options = { };
local_mode = ensure_matching_mode(output, target_mode);
if (!local_mode) {
@ -484,7 +485,7 @@ rdp_switch_mode(struct weston_output *output, struct weston_mode *target_mode)
output->current_mode->flags |= WL_OUTPUT_MODE_CURRENT;
pixman_renderer_output_destroy(output);
pixman_renderer_output_create(output, 0);
pixman_renderer_output_create(output, &options);
new_shadow_buffer = pixman_image_create_bits(PIXMAN_x8r8g8b8, target_mode->width,
target_mode->height, 0, target_mode->width * 4);
@ -560,6 +561,9 @@ rdp_output_enable(struct weston_output *base)
struct rdp_output *output = to_rdp_output(base);
struct rdp_backend *b = to_rdp_backend(base->compositor);
struct wl_event_loop *loop;
const struct pixman_renderer_output_options options = {
.use_shadow = true,
};
output->shadow_surface = pixman_image_create_bits(PIXMAN_x8r8g8b8,
output->base.current_mode->width,
@ -571,8 +575,7 @@ rdp_output_enable(struct weston_output *base)
return -1;
}
if (pixman_renderer_output_create(&output->base,
PIXMAN_RENDERER_OUTPUT_USE_SHADOW) < 0) {
if (pixman_renderer_output_create(&output->base, &options) < 0) {
pixman_image_unref(output->shadow_surface);
return -1;
}

View File

@ -799,8 +799,10 @@ cleanup_window:
static int
wayland_output_init_pixman_renderer(struct wayland_output *output)
{
return pixman_renderer_output_create(&output->base,
PIXMAN_RENDERER_OUTPUT_USE_SHADOW);
const struct pixman_renderer_output_options options = {
.use_shadow = true,
};
return pixman_renderer_output_create(&output->base, &options);
}
static void

View File

@ -836,6 +836,9 @@ x11_output_switch_mode(struct weston_output *base, struct weston_mode *mode)
output->mode.height = mode->height;
if (b->use_pixman) {
const struct pixman_renderer_output_options options = {
.use_shadow = true,
};
pixman_renderer_output_destroy(&output->base);
x11_output_deinit_shm(b, output);
@ -846,8 +849,7 @@ x11_output_switch_mode(struct weston_output *base, struct weston_mode *mode)
return -1;
}
if (pixman_renderer_output_create(&output->base,
PIXMAN_RENDERER_OUTPUT_USE_SHADOW) < 0) {
if (pixman_renderer_output_create(&output->base, &options) < 0) {
weston_log("Failed to create pixman renderer for output\n");
x11_output_deinit_shm(b, output);
return -1;
@ -1014,14 +1016,16 @@ x11_output_enable(struct weston_output *base)
x11_output_wait_for_map(b, output);
if (b->use_pixman) {
const struct pixman_renderer_output_options options = {
.use_shadow = true,
};
if (x11_output_init_shm(b, output,
output->base.current_mode->width,
output->base.current_mode->height) < 0) {
weston_log("Failed to initialize SHM for the X11 output\n");
goto err;
}
if (pixman_renderer_output_create(&output->base,
PIXMAN_RENDERER_OUTPUT_USE_SHADOW) < 0) {
if (pixman_renderer_output_create(&output->base, &options) < 0) {
weston_log("Failed to create pixman renderer for output\n");
x11_output_deinit_shm(b, output);
goto err;

View File

@ -924,7 +924,8 @@ pixman_renderer_output_set_hw_extra_damage(struct weston_output *output,
}
WL_EXPORT int
pixman_renderer_output_create(struct weston_output *output, uint32_t flags)
pixman_renderer_output_create(struct weston_output *output,
const struct pixman_renderer_output_options *options)
{
struct pixman_output_state *po;
int w, h;
@ -933,7 +934,7 @@ pixman_renderer_output_create(struct weston_output *output, uint32_t flags)
if (po == NULL)
return -1;
if (flags & PIXMAN_RENDERER_OUTPUT_USE_SHADOW) {
if (options->use_shadow) {
/* set shadow image transformation */
w = output->current_mode->width;
h = output->current_mode->height;

View File

@ -32,12 +32,14 @@
int
pixman_renderer_init(struct weston_compositor *ec);
enum pixman_renderer_output_flags {
PIXMAN_RENDERER_OUTPUT_USE_SHADOW = (1 << 0),
struct pixman_renderer_output_options {
/** Composite into a shadow buffer, copying to the hardware buffer */
bool use_shadow;
};
int
pixman_renderer_output_create(struct weston_output *output, uint32_t flags);
pixman_renderer_output_create(struct weston_output *output,
const struct pixman_renderer_output_options *options);
void
pixman_renderer_output_set_buffer(struct weston_output *output,