subsurface: use cached surface state
This commit is contained in:
parent
e0258f4506
commit
8ecc557ab0
|
@ -162,7 +162,7 @@ struct wlr_subsurface {
|
||||||
|
|
||||||
struct wlr_subsurface_state current, pending;
|
struct wlr_subsurface_state current, pending;
|
||||||
|
|
||||||
struct wlr_surface_state cached;
|
uint32_t cached_seq;
|
||||||
bool has_cache;
|
bool has_cache;
|
||||||
|
|
||||||
bool synchronized;
|
bool synchronized;
|
||||||
|
|
|
@ -502,10 +502,9 @@ static void subsurface_parent_commit(struct wlr_subsurface *subsurface,
|
||||||
struct wlr_surface *surface = subsurface->surface;
|
struct wlr_surface *surface = subsurface->surface;
|
||||||
if (synchronized || subsurface->synchronized) {
|
if (synchronized || subsurface->synchronized) {
|
||||||
if (subsurface->has_cache) {
|
if (subsurface->has_cache) {
|
||||||
surface_state_move(&surface->pending, &subsurface->cached);
|
wlr_surface_unlock_cached(surface, subsurface->cached_seq);
|
||||||
surface_commit_pending(surface);
|
|
||||||
subsurface->has_cache = false;
|
subsurface->has_cache = false;
|
||||||
subsurface->cached.committed = 0;
|
subsurface->cached_seq = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_subsurface *subsurface;
|
struct wlr_subsurface *subsurface;
|
||||||
|
@ -519,17 +518,17 @@ static void subsurface_commit(struct wlr_subsurface *subsurface) {
|
||||||
struct wlr_surface *surface = subsurface->surface;
|
struct wlr_surface *surface = subsurface->surface;
|
||||||
|
|
||||||
if (subsurface_is_synchronized(subsurface)) {
|
if (subsurface_is_synchronized(subsurface)) {
|
||||||
surface_state_move(&subsurface->cached, &surface->pending);
|
|
||||||
subsurface->has_cache = true;
|
|
||||||
surface->pending.seq = subsurface->cached.seq + 1;
|
|
||||||
} else {
|
|
||||||
if (subsurface->has_cache) {
|
if (subsurface->has_cache) {
|
||||||
surface_state_move(&surface->pending, &subsurface->cached);
|
// We already lock a previous commit. The prevents any future
|
||||||
surface_commit_pending(surface);
|
// commit to be applied before we release the previous commit.
|
||||||
subsurface->has_cache = false;
|
return;
|
||||||
} else {
|
|
||||||
surface_commit_pending(surface);
|
|
||||||
}
|
}
|
||||||
|
subsurface->has_cache = true;
|
||||||
|
subsurface->cached_seq = wlr_surface_lock_pending(surface);
|
||||||
|
} else if (subsurface->has_cache) {
|
||||||
|
wlr_surface_unlock_cached(surface, subsurface->cached_seq);
|
||||||
|
subsurface->has_cache = false;
|
||||||
|
subsurface->cached_seq = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,10 +540,10 @@ static void surface_commit(struct wl_client *client,
|
||||||
wlr_subsurface_from_wlr_surface(surface) : NULL;
|
wlr_subsurface_from_wlr_surface(surface) : NULL;
|
||||||
if (subsurface != NULL) {
|
if (subsurface != NULL) {
|
||||||
subsurface_commit(subsurface);
|
subsurface_commit(subsurface);
|
||||||
} else {
|
|
||||||
surface_commit_pending(surface);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
surface_commit_pending(surface);
|
||||||
|
|
||||||
wl_list_for_each(subsurface, &surface->subsurfaces, parent_link) {
|
wl_list_for_each(subsurface, &surface->subsurfaces, parent_link) {
|
||||||
subsurface_parent_commit(subsurface, false);
|
subsurface_parent_commit(subsurface, false);
|
||||||
}
|
}
|
||||||
|
@ -653,7 +652,6 @@ static void subsurface_destroy(struct wlr_subsurface *subsurface) {
|
||||||
wlr_signal_emit_safe(&subsurface->events.destroy, subsurface);
|
wlr_signal_emit_safe(&subsurface->events.destroy, subsurface);
|
||||||
|
|
||||||
wl_list_remove(&subsurface->surface_destroy.link);
|
wl_list_remove(&subsurface->surface_destroy.link);
|
||||||
surface_state_finish(&subsurface->cached);
|
|
||||||
|
|
||||||
if (subsurface->parent) {
|
if (subsurface->parent) {
|
||||||
wl_list_remove(&subsurface->parent_link);
|
wl_list_remove(&subsurface->parent_link);
|
||||||
|
@ -1116,13 +1114,11 @@ struct wlr_subsurface *wlr_subsurface_create(struct wlr_surface *surface,
|
||||||
wl_client_post_no_memory(client);
|
wl_client_post_no_memory(client);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
surface_state_init(&subsurface->cached);
|
|
||||||
subsurface->synchronized = true;
|
subsurface->synchronized = true;
|
||||||
subsurface->surface = surface;
|
subsurface->surface = surface;
|
||||||
subsurface->resource =
|
subsurface->resource =
|
||||||
wl_resource_create(client, &wl_subsurface_interface, version, id);
|
wl_resource_create(client, &wl_subsurface_interface, version, id);
|
||||||
if (subsurface->resource == NULL) {
|
if (subsurface->resource == NULL) {
|
||||||
surface_state_finish(&subsurface->cached);
|
|
||||||
free(subsurface);
|
free(subsurface);
|
||||||
wl_client_post_no_memory(client);
|
wl_client_post_no_memory(client);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue