surface-state: Only walk the paint node list once in surface_attach

We have to walk it once for the dirty buffer, but we can accumulate our
changes along the way and walk it only once.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2026-03-26 14:50:15 -05:00
parent 501fdea28d
commit dd74ed6db0

View file

@ -203,6 +203,7 @@ weston_surface_attach(struct weston_surface *surface,
WESTON_TRACE_FUNC_FLOW(&surface->flow_id);
struct weston_buffer *buffer = state->buffer_ref.buffer;
struct weston_buffer *old_buffer = surface->buffer_ref.buffer;
enum weston_paint_node_status pnode_changes = WESTON_PAINT_NODE_CLEAN;
if (!buffer) {
if (weston_surface_is_mapped(surface)) {
@ -223,6 +224,8 @@ weston_surface_attach(struct weston_surface *surface,
return status;
}
pnode_changes |= WESTON_PAINT_NODE_BUFFER_DIRTY;
/* Recalculate the surface size if the buffer dimensions or the
* surface transforms (viewport, rotation/mirror, scale) have
* changed. */
@ -251,14 +254,12 @@ weston_surface_attach(struct weston_surface *surface,
buffer->format_modifier != old_buffer->format_modifier) {
surface->is_opaque = pixel_format_is_opaque(buffer->pixel_format);
status |= WESTON_SURFACE_DIRTY_BUFFER_PARAMS;
weston_surface_dirty_paint_nodes(surface,
WESTON_PAINT_NODE_BUFFER_PARAMS_DIRTY);
pnode_changes |= WESTON_PAINT_NODE_BUFFER_PARAMS_DIRTY;
}
status |= WESTON_SURFACE_DIRTY_BUFFER;
weston_surface_dirty_paint_nodes(surface,
WESTON_PAINT_NODE_BUFFER_DIRTY);
old_buffer = NULL;
weston_surface_dirty_paint_nodes(surface, pnode_changes);
weston_buffer_reference(&surface->buffer_ref, buffer,
BUFFER_MAY_BE_ACCESSED);