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>
dev
Daniel Stone 5 years ago committed by Pekka Paalanen
parent 786490cb53
commit 61abf35ec4
  1. 9
      libweston/backend-drm/drm.c
  2. 6
      libweston/backend-fbdev/fbdev.c
  3. 7
      libweston/backend-headless/headless.c
  4. 9
      libweston/backend-rdp/rdp.c
  5. 6
      libweston/backend-wayland/wayland.c
  6. 12
      libweston/backend-x11/x11.c
  7. 5
      libweston/pixman-renderer.c
  8. 8
      libweston/pixman-renderer.h

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

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

@ -214,6 +214,10 @@ headless_output_enable_gl(struct headless_output *output)
static int static int
headless_output_enable_pixman(struct headless_output *output) 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->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)
@ -225,8 +229,7 @@ headless_output_enable_pixman(struct headless_output *output)
output->image_buf, output->image_buf,
output->base.current_mode->width * 4); output->base.current_mode->width * 4);
if (pixman_renderer_output_create(&output->base, if (pixman_renderer_output_create(&output->base, &options) < 0)
PIXMAN_RENDERER_OUTPUT_USE_SHADOW) < 0)
goto err_renderer; goto err_renderer;
pixman_renderer_output_set_buffer(&output->base, output->image); pixman_renderer_output_set_buffer(&output->base, output->image);

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

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

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

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

@ -32,12 +32,14 @@
int int
pixman_renderer_init(struct weston_compositor *ec); pixman_renderer_init(struct weston_compositor *ec);
enum pixman_renderer_output_flags { struct pixman_renderer_output_options {
PIXMAN_RENDERER_OUTPUT_USE_SHADOW = (1 << 0), /** Composite into a shadow buffer, copying to the hardware buffer */
bool use_shadow;
}; };
int 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 void
pixman_renderer_output_set_buffer(struct weston_output *output, pixman_renderer_output_set_buffer(struct weston_output *output,

Loading…
Cancel
Save