libweston: Use weston_coord_surface in weston_surface_state

Use this for the buffer attachment offset coordinates.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2023-01-30 08:58:14 -06:00
parent bd3de08b13
commit 71e38cf2ef
2 changed files with 17 additions and 27 deletions

View File

@ -1764,8 +1764,7 @@ struct weston_surface_state {
struct weston_buffer *buffer; struct weston_buffer *buffer;
struct wl_listener buffer_destroy_listener; struct wl_listener buffer_destroy_listener;
int32_t sx; struct weston_coord_surface buf_offset;
int32_t sy;
/* wl_surface.damage */ /* wl_surface.damage */
pixman_region32_t damage_surface; pixman_region32_t damage_surface;

View File

@ -748,14 +748,14 @@ surface_state_handle_buffer_destroy(struct wl_listener *listener, void *data)
} }
static void static void
weston_surface_state_init(struct weston_surface_state *state) weston_surface_state_init(struct weston_surface *surface,
struct weston_surface_state *state)
{ {
state->status = WESTON_SURFACE_CLEAN; state->status = WESTON_SURFACE_CLEAN;
state->buffer = NULL; state->buffer = NULL;
state->buffer_destroy_listener.notify = state->buffer_destroy_listener.notify =
surface_state_handle_buffer_destroy; surface_state_handle_buffer_destroy;
state->sx = 0; state->buf_offset = weston_coord_surface(0, 0, surface);
state->sy = 0;
pixman_region32_init(&state->damage_surface); pixman_region32_init(&state->damage_surface);
pixman_region32_init(&state->damage_buffer); pixman_region32_init(&state->damage_buffer);
@ -836,7 +836,7 @@ weston_surface_create(struct weston_compositor *compositor)
surface->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1); surface->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
surface->buffer_viewport.surface.width = -1; surface->buffer_viewport.surface.width = -1;
weston_surface_state_init(&surface->pending); weston_surface_state_init(surface, &surface->pending);
pixman_region32_init(&surface->damage); pixman_region32_init(&surface->damage);
pixman_region32_init(&surface->opaque); pixman_region32_init(&surface->opaque);
@ -4014,8 +4014,8 @@ surface_attach(struct wl_client *client,
} }
} else { } else {
surface->pending.status |= WESTON_SURFACE_DIRTY_POS; surface->pending.status |= WESTON_SURFACE_DIRTY_POS;
surface->pending.sx = sx; surface->pending.buf_offset = weston_coord_surface(sx, sy,
surface->pending.sy = sy; surface);
} }
/* Attach, attach, without commit in between does not send /* Attach, attach, without commit in between does not send
@ -4388,17 +4388,10 @@ weston_surface_commit_state(struct weston_surface *surface,
if ((status & (WESTON_SURFACE_DIRTY_BUFFER | WESTON_SURFACE_DIRTY_SIZE | if ((status & (WESTON_SURFACE_DIRTY_BUFFER | WESTON_SURFACE_DIRTY_SIZE |
WESTON_SURFACE_DIRTY_POS)) && WESTON_SURFACE_DIRTY_POS)) &&
surface->committed) { surface->committed)
struct weston_coord_surface new_origin; surface->committed(surface, state->buf_offset);
new_origin = weston_coord_surface(state->sx, state->buf_offset = weston_coord_surface(0, 0, surface);
state->sy,
surface);
surface->committed(surface, new_origin);
}
state->sx = 0;
state->sy = 0;
/* wl_surface.damage and wl_surface.damage_buffer; only valid /* wl_surface.damage and wl_surface.damage_buffer; only valid
* in the same cycle as wl_surface.commit */ * in the same cycle as wl_surface.commit */
@ -4620,8 +4613,7 @@ surface_offset(struct wl_client *client,
struct weston_surface *surface = wl_resource_get_user_data(resource); struct weston_surface *surface = wl_resource_get_user_data(resource);
surface->pending.status |= WESTON_SURFACE_DIRTY_POS; surface->pending.status |= WESTON_SURFACE_DIRTY_POS;
surface->pending.sx = sx; surface->pending.buf_offset = weston_coord_surface(sx, sy, surface);
surface->pending.sy = sy;
} }
static const struct wl_surface_interface surface_interface = { static const struct wl_surface_interface surface_interface = {
@ -4772,9 +4764,9 @@ weston_subsurface_commit_to_cache(struct weston_subsurface *sub)
*/ */
if (surface->pending.status & WESTON_SURFACE_DIRTY_POS) { if (surface->pending.status & WESTON_SURFACE_DIRTY_POS) {
pixman_region32_translate(&sub->cached.damage_surface, pixman_region32_translate(&sub->cached.damage_surface,
-surface->pending.sx, -surface->pending.sy); -surface->pending.buf_offset.c.x,
-surface->pending.buf_offset.c.y);
} }
pixman_region32_union(&sub->cached.damage_surface, pixman_region32_union(&sub->cached.damage_surface,
&sub->cached.damage_surface, &sub->cached.damage_surface,
&surface->pending.damage_surface); &surface->pending.damage_surface);
@ -4807,8 +4799,8 @@ weston_subsurface_commit_to_cache(struct weston_subsurface *sub)
sub->cached.protection_mode = surface->pending.protection_mode; sub->cached.protection_mode = surface->pending.protection_mode;
assert(surface->pending.acquire_fence_fd == -1); assert(surface->pending.acquire_fence_fd == -1);
assert(surface->pending.buffer_release_ref.buffer_release == NULL); assert(surface->pending.buffer_release_ref.buffer_release == NULL);
sub->cached.sx += surface->pending.sx; sub->cached.buf_offset.c = weston_coord_add(sub->cached.buf_offset.c,
sub->cached.sy += surface->pending.sy; surface->pending.buf_offset.c);
sub->cached.buffer_viewport.buffer = sub->cached.buffer_viewport.buffer =
surface->pending.buffer_viewport.buffer; surface->pending.buffer_viewport.buffer;
@ -4817,8 +4809,7 @@ weston_subsurface_commit_to_cache(struct weston_subsurface *sub)
weston_surface_state_set_buffer(&surface->pending, NULL); weston_surface_state_set_buffer(&surface->pending, NULL);
surface->pending.sx = 0; surface->pending.buf_offset = weston_coord_surface(0, 0, surface);
surface->pending.sy = 0;
pixman_region32_copy(&sub->cached.opaque, &surface->pending.opaque); pixman_region32_copy(&sub->cached.opaque, &surface->pending.opaque);
@ -5462,7 +5453,7 @@ weston_subsurface_create(uint32_t id, struct weston_surface *surface,
sub, subsurface_resource_destroy); sub, subsurface_resource_destroy);
weston_subsurface_link_surface(sub, surface); weston_subsurface_link_surface(sub, surface);
weston_subsurface_link_parent(sub, parent); weston_subsurface_link_parent(sub, parent);
weston_surface_state_init(&sub->cached); weston_surface_state_init(surface, &sub->cached);
sub->cached_buffer_ref.buffer = NULL; sub->cached_buffer_ref.buffer = NULL;
sub->synchronized = 1; sub->synchronized = 1;