surface: change surface_finalize_state() to surface_finalize_pending()

This commit is contained in:
Kirill Primak 2021-08-26 19:45:25 +03:00 committed by Simon Ser
parent ba55c7c4ff
commit cf56596565

View file

@ -167,53 +167,54 @@ static void surface_state_viewport_src_size(struct wlr_surface_state *state,
} }
} }
static void surface_state_finalize(struct wlr_surface *surface, static void surface_finalize_pending(struct wlr_surface *surface) {
struct wlr_surface_state *state) { struct wlr_surface_state *pending = &surface->pending;
if ((state->committed & WLR_SURFACE_STATE_BUFFER)) {
if (state->buffer_resource) { if ((pending->committed & WLR_SURFACE_STATE_BUFFER)) {
wlr_buffer_unlock(state->buffer); if (pending->buffer_resource) {
state->buffer = wlr_buffer_from_resource(state->buffer_resource); wlr_buffer_unlock(pending->buffer);
if (!state->buffer) { pending->buffer = wlr_buffer_from_resource(pending->buffer_resource);
wl_resource_post_error(state->buffer_resource, 0, if (!pending->buffer) {
wl_resource_post_error(pending->buffer_resource, 0,
"unknown buffer type"); "unknown buffer type");
return; return;
} }
state->buffer_width = state->buffer->width; pending->buffer_width = pending->buffer->width;
state->buffer_height = state->buffer->height; pending->buffer_height = pending->buffer->height;
} else { } else {
state->buffer_width = state->buffer_height = 0; pending->buffer_width = pending->buffer_height = 0;
} }
} }
if (!state->viewport.has_src && if (!pending->viewport.has_src &&
(state->buffer_width % state->scale != 0 || (pending->buffer_width % pending->scale != 0 ||
state->buffer_height % state->scale != 0)) { pending->buffer_height % pending->scale != 0)) {
// TODO: send WL_SURFACE_ERROR_INVALID_SIZE error once this issue is // TODO: send WL_SURFACE_ERROR_INVALID_SIZE error once this issue is
// resolved: // resolved:
// https://gitlab.freedesktop.org/wayland/wayland/-/issues/194 // https://gitlab.freedesktop.org/wayland/wayland/-/issues/194
wlr_log(WLR_DEBUG, "Client bug: submitted a buffer whose size (%dx%d) " wlr_log(WLR_DEBUG, "Client bug: submitted a buffer whose size (%dx%d) "
"is not divisible by scale (%d)", state->buffer_width, "is not divisible by scale (%d)", pending->buffer_width,
state->buffer_height, state->scale); pending->buffer_height, pending->scale);
} }
if (state->viewport.has_dst) { if (pending->viewport.has_dst) {
if (state->buffer_width == 0 && state->buffer_height == 0) { if (pending->buffer_width == 0 && pending->buffer_height == 0) {
state->width = state->height = 0; pending->width = pending->height = 0;
} else { } else {
state->width = state->viewport.dst_width; pending->width = pending->viewport.dst_width;
state->height = state->viewport.dst_height; pending->height = pending->viewport.dst_height;
} }
} else { } else {
surface_state_viewport_src_size(state, &state->width, &state->height); surface_state_viewport_src_size(pending, &pending->width, &pending->height);
} }
pixman_region32_intersect_rect(&state->surface_damage, pixman_region32_intersect_rect(&pending->surface_damage,
&state->surface_damage, 0, 0, state->width, state->height); &pending->surface_damage, 0, 0, pending->width, pending->height);
pixman_region32_intersect_rect(&state->buffer_damage, pixman_region32_intersect_rect(&pending->buffer_damage,
&state->buffer_damage, 0, 0, state->buffer_width, &pending->buffer_damage, 0, 0, pending->buffer_width,
state->buffer_height); pending->buffer_height);
} }
static void surface_update_damage(pixman_region32_t *buffer_damage, static void surface_update_damage(pixman_region32_t *buffer_damage,
@ -496,7 +497,7 @@ static void surface_commit_state(struct wlr_surface *surface,
} }
static void surface_commit_pending(struct wlr_surface *surface) { static void surface_commit_pending(struct wlr_surface *surface) {
surface_state_finalize(surface, &surface->pending); surface_finalize_pending(surface);
if (surface->role && surface->role->precommit) { if (surface->role && surface->role->precommit) {
surface->role->precommit(surface); surface->role->precommit(surface);