Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Comments

surface: add synced objects#3151

Open
vyivel wants to merge 11 commits intoswaywm:masterfrom
vyivel:cache-everything
Open

surface: add synced objects#3151
vyivel wants to merge 11 commits intoswaywm:masterfrom
vyivel:cache-everything

Conversation

@vyivel
Copy link
Member

@vyivel vyivel commented Aug 31, 2021

Also see individual commits.

Closes #1546
Supersedes #2977, #1685 (?)
Fixes #3235

State squashing

Squashing refers to an action of combining a state with the state right before it in the queue. The older state becomes a "sum" of two states, and the newer state becomes empty.

Data structure

This PR introduces wlr_surface_synced and wlr_surface_synced_state to keep track of objects synchronized with the surface state flow. At any given moment, a surface has a current state, a pending state, and optionally a number of cached states. Thus, the following data structure is maintained:

This setup allows to perform state caching and squashing in O(k) time, where k is the number of surface-synced objects. When a state is cached, a column of cachedn+1 states is added right before the last one (pending).

Creation of a surface-synced object adds a row of syncedk+1 states and is done in O(n), where n is the number of cached states at the moment; most of the time, n is 0. Note that rows have undefined order; wlr_surface::synced and wlr_surface_state::synced must be treated as unordered sets.

Progress

  • wl_subsurface
  • xdg_surface
  • xdg_toplevel
  • zwlr_layer_surface_v1
  • zxdg_toplevel_decoration
  • zwp_pointer_constraints_v1
  • wp_presentation_feedback

There are objects which only have current state which is updated on surface commit; those don't need to be surface-synced.

Notes

  • wlr_surface.current.seq is meaningless and is always 0. It can't be set to the sequence number of the state being committed.
    Consider the following situation: currentA(seq 1)B(seq 2)pending.
    If A is unlocked and then B is unlocked, wlr_surface.current.seq is set to 1 and then 2.
    However, if B is unlocked first, it's squashed into A. A.seq can't be updated to 2, because whatever locked A still has the old sequence number. After unlocking A, wlr_surface.current.seq will be 1. To avoid this inconsistency, sequence numbers aren't updated at all and assumed to be only used for state locking.
    Note that this could be fixed in a non-breaking way by introducing wlr_surface_state.lock_seq and updating wlr_surface_state.seq on squash, if required.

  • While wlr_surface_synced_interface.precommit is called right before the current state update, wlr_surface_role.precommit is called on wl_surface.commit request. This is a bug and will be fixed in another PR.

  • *.current.committed now indicates which parts of the current state were modified by the most recent commit.

Breaking changes

This is (supposed to be) a purely internal change and shouldn't require any action from compositor developers.

@vyivel vyivel force-pushed the cache-everything branch 3 times, most recently from 11f5122 to 8a097de Compare September 11, 2021 13:48
@vyivel vyivel force-pushed the cache-everything branch 2 times, most recently from 13be55c to 7d692d9 Compare October 2, 2021 10:53
@vyivel vyivel changed the title Use wlr_surface_extension everywhere Use wlr_surface_synced everywhere Oct 7, 2021
@vyivel vyivel force-pushed the cache-everything branch 2 times, most recently from f76b5b2 to d89f58a Compare October 7, 2021 15:12
@vyivel vyivel changed the title Use wlr_surface_synced everywhere surface: add synced objects Oct 9, 2021
@vyivel vyivel force-pushed the cache-everything branch 2 times, most recently from dbb8003 to 29ae1e2 Compare October 11, 2021 16:25
@vyivel vyivel marked this pull request as ready for review October 22, 2021 10:03
Kirill Primak added 2 commits October 26, 2021 15:30
@vyivel vyivel force-pushed the cache-everything branch 2 times, most recently from bd3ff8c to eba505a Compare October 26, 2021 13:01
@vyivel
Copy link
Member Author

vyivel commented Oct 26, 2021

Replaced all loops over cached states with a loop + current/pending check where applicable.

@emersion
Copy link
Member

emersion commented Nov 1, 2021

wlroots has migrated to gitlab.freedesktop.org. This pull request has been moved to:

https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3151

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

presentation-time doesn't work correctly with surface state locking Proposal: wlr_surface_state improvements

2 participants