surface: Only rebuild subsurface lists when necessary

There's no need to go through and rebuild the subsurface list every
time. In addition to being unnecessary work, it complicates things like
damage tracking.

Track a new surface dirty status indicating that the subsurface tree has
changed in some way, and only rebuild subsurface stacking when this has
occurred.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2023-06-26 20:26:08 +01:00
parent ce6afda6a2
commit c859dd1b9e
2 changed files with 12 additions and 2 deletions

View file

@ -1742,6 +1742,8 @@ enum weston_surface_status {
WESTON_SURFACE_DIRTY_BUFFER_PARAMS = 1 << 3,
/** input region has changed */
WESTON_SURFACE_DIRTY_INPUT = 1 << 4,
/** subsurfaces have been added, removed, or restacked */
WESTON_SURFACE_DIRTY_SUBSURFACE_CONFIG = 1 << 5,
};
struct weston_surface_state {

View file

@ -4268,7 +4268,8 @@ weston_surface_commit(struct weston_surface *surface)
status = weston_surface_commit_state(surface, &surface->pending);
weston_surface_commit_subsurface_order(surface);
if (status & WESTON_SURFACE_DIRTY_SUBSURFACE_CONFIG)
weston_surface_commit_subsurface_order(surface);
weston_surface_schedule_repaint(surface);
@ -4533,7 +4534,8 @@ weston_subsurface_commit_from_cache(struct weston_subsurface *sub)
weston_buffer_reference(&sub->cached_buffer_ref, NULL,
BUFFER_WILL_NOT_BE_ACCESSED);
weston_surface_commit_subsurface_order(surface);
if (status & WESTON_SURFACE_DIRTY_SUBSURFACE_CONFIG)
weston_surface_commit_subsurface_order(surface);
weston_surface_schedule_repaint(surface);
@ -4968,6 +4970,7 @@ subsurface_set_position(struct wl_client *client,
sub->position.offset = weston_coord_surface(x, y, sub->parent);
sub->position.changed = true;
sub->parent->pending.status |= WESTON_SURFACE_DIRTY_SUBSURFACE_CONFIG;
}
static struct weston_subsurface *
@ -5028,6 +5031,7 @@ subsurface_place_above(struct wl_client *client,
&sub->parent_link_pending);
sub->reordered = true;
sub->parent->pending.status |= WESTON_SURFACE_DIRTY_SUBSURFACE_CONFIG;
}
static void
@ -5052,6 +5056,7 @@ subsurface_place_below(struct wl_client *client,
&sub->parent_link_pending);
sub->reordered = true;
sub->parent->pending.status |= WESTON_SURFACE_DIRTY_SUBSURFACE_CONFIG;
}
static void
@ -5083,6 +5088,7 @@ weston_subsurface_unlink_parent(struct weston_subsurface *sub)
wl_list_remove(&sub->parent_link);
wl_list_remove(&sub->parent_link_pending);
wl_list_remove(&sub->parent_destroy_listener.link);
sub->parent->pending.status |= WESTON_SURFACE_DIRTY_SUBSURFACE_CONFIG;
sub->parent = NULL;
}
@ -5140,6 +5146,8 @@ weston_subsurface_link_parent(struct weston_subsurface *sub,
wl_signal_add(&parent->destroy_signal,
&sub->parent_destroy_listener);
parent->pending.status |= WESTON_SURFACE_DIRTY_SUBSURFACE_CONFIG;
wl_list_insert(&parent->subsurface_list, &sub->parent_link);
wl_list_insert(&parent->subsurface_list_pending,
&sub->parent_link_pending);