[PATCH weston 2/2] compositor-wayland: Use damage_buffer if available
Bryce Harrington
bryce at osg.samsung.com
Fri Feb 12 04:31:20 UTC 2016
On Fri, Jan 08, 2016 at 03:00:56PM -0600, Derek Foreman wrote:
> Try to replace most usage of wl_surface.damage with
> wl_surface.damage_buffer. Some calls are beyond our control,
> such as the gl_renderer's damage handling.
>
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>
> ---
> src/compositor-wayland.c | 52 ++++++++++++++++++++++++++++++++++++++----------
> 1 file changed, 42 insertions(+), 10 deletions(-)
>
> diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
> index 4ea0b7d..77ed1e4 100644
> --- a/src/compositor-wayland.c
> +++ b/src/compositor-wayland.c
> @@ -79,6 +79,8 @@ struct wayland_backend {
> struct wl_cursor *cursor;
>
> struct wl_list input_list;
> +
> + bool use_damage_buffer;
> };
>
> struct wayland_output {
> @@ -342,6 +344,8 @@ static const struct wl_callback_listener frame_listener = {
> static void
> draw_initial_frame(struct wayland_output *output)
> {
> + struct wayland_backend *b =
> + (struct wayland_backend *) output->base.compositor->backend;
> struct wayland_shm_buffer *sb;
>
> sb = wayland_output_get_shm_buffer(output);
> @@ -352,9 +356,15 @@ draw_initial_frame(struct wayland_output *output)
> sb->output = NULL;
>
> wl_surface_attach(output->parent.surface, sb->buffer, 0, 0);
> - wl_surface_damage(output->parent.surface, 0, 0,
> - output->base.current_mode->width,
> - output->base.current_mode->height);
> +
> + if (b->use_damage_buffer)
> + wl_surface_damage(output->parent.surface, 0, 0,
> + output->base.current_mode->width,
> + output->base.current_mode->height);
> + else
> + wl_surface_damage_buffer(output->parent.surface, 0, 0,
> + output->base.current_mode->width,
> + output->base.current_mode->height);
> }
>
> static void
> @@ -515,6 +525,8 @@ wayland_output_update_shm_border(struct wayland_shm_buffer *buffer)
> static void
> wayland_shm_buffer_attach(struct wayland_shm_buffer *sb)
> {
> + struct wayland_backend *b =
> + (struct wayland_backend *) sb->output->base.compositor->backend;
> pixman_region32_t damage;
> pixman_box32_t *rects;
> int32_t ix, iy, iwidth, iheight, fwidth, fheight;
> @@ -550,10 +562,20 @@ wayland_shm_buffer_attach(struct wayland_shm_buffer *sb)
>
> rects = pixman_region32_rectangles(&damage, &n);
> wl_surface_attach(sb->output->parent.surface, sb->buffer, 0, 0);
> - for (i = 0; i < n; ++i)
> - wl_surface_damage(sb->output->parent.surface, rects[i].x1,
> - rects[i].y1, rects[i].x2 - rects[i].x1,
> - rects[i].y2 - rects[i].y1);
> + for (i = 0; i < n; ++i) {
> + if (b->use_damage_buffer)
> + wl_surface_damage_buffer(sb->output->parent.surface,
> + rects[i].x1,
> + rects[i].y1,
> + rects[i].x2 - rects[i].x1,
> + rects[i].y2 - rects[i].y1);
> + else
> + wl_surface_damage(sb->output->parent.surface,
> + rects[i].x1,
> + rects[i].y1,
> + rects[i].x2 - rects[i].x1,
> + rects[i].y2 - rects[i].y1);
> + }
>
> if (sb->output->frame)
> pixman_region32_fini(&damage);
> @@ -1265,8 +1287,13 @@ input_set_cursor(struct wayland_input *input)
> image->hotspot_x, image->hotspot_y);
>
> wl_surface_attach(input->parent.cursor.surface, buffer, 0, 0);
> - wl_surface_damage(input->parent.cursor.surface, 0, 0,
> - image->width, image->height);
> + if (input->backend->use_damage_buffer)
> + wl_surface_damage_buffer(input->parent.cursor.surface, 0, 0,
> + image->width, image->height);
> + else
> + wl_surface_damage(input->parent.cursor.surface, 0, 0,
> + image->width, image->height);
> +
> wl_surface_commit(input->parent.cursor.surface);
> }
>
> @@ -1983,9 +2010,14 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t name,
> struct wayland_backend *b = data;
>
> if (strcmp(interface, "wl_compositor") == 0) {
> + int cv = MIN(WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION, version);
> +
> b->parent.compositor =
> wl_registry_bind(registry, name,
> - &wl_compositor_interface, 1);
> + &wl_compositor_interface, cv);
> +
> + if (cv >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION)
> + b->use_damage_buffer = true;
> } else if (strcmp(interface, "wl_shell") == 0) {
> b->parent.shell =
> wl_registry_bind(registry, name,
> --
> 2.6.4
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list