pixman-renderer: Replace output-create flags with struct
authorDaniel Stone <daniels@collabora.com>
Fri, 6 Mar 2020 12:46:30 +0000 (12:46 +0000)
committerPekka Paalanen <pq@iki.fi>
Fri, 20 Mar 2020 15:25:24 +0000 (15:25 +0000)
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>
libweston/backend-drm/drm.c
libweston/backend-fbdev/fbdev.c
libweston/backend-headless/headless.c
libweston/backend-rdp/rdp.c
libweston/backend-wayland/wayland.c
libweston/backend-x11/x11.c
libweston/pixman-renderer.c
libweston/pixman-renderer.h

index 11936115ba5bdec3c0a8859111eee8e99f70ea36..3c5ca65a943ab5e233e16e9f5893187678ca2ee1 100644 (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,
index ae289cc0c49fcf9f9afee00b7a018dda6d7c7aac..a43f648e89773dc97407a2bf7dab6afb9c0255e5 100644 (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);
index 76e529069e6bc6efdef347e30740fc0560598f5f..c312a0f22ec4d114a50c2bd0ac658d2db3ef3b53 100644 (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);
index ce91cedd111baec06a5d074157bfc57019add7b4..2b33d29cfbf97310849243e04a154fd685850b9c 100644 (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;
        }
index 0224865cc6d6a945b33a234916e6f9839fd056e9..60d42bf3be6902ec7b1275893c6d5c9b05d7f61e 100644 (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
index dad0849f349782712cb67edfcf173ddbd69ab127..387e97a4858104a76941669bb54b6ab2d13b71ca 100644 (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;
index 51324e9a31712da8e03fc4844d61ad5a1ac4d787..59b1f0ff225156b35ac2cdbc56be676be1eee66d 100644 (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;
index f53ae2a346b3934114b8d57222127afb11b6ce6c..2b81dde51bba0a18e789b9a4c7e1d913f357ee1b 100644 (file)
 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,