mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
clutter/frame-clock: Simplify next_presentation_time_us calculation
When more than one refresh interval has passed since last_presentation_time_us. I honestly can't tell if the previous calculation was correct or not, but I'm confident the new one is, and it's simpler. v2: * ASCII art diagram didn't make sense anymore, try to improve (Ivan Molodetskikh) Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3330>
This commit is contained in:
parent
c58312e249
commit
9f8283a95a
@ -511,48 +511,29 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock,
|
||||
*/
|
||||
if (next_presentation_time_us < now_us)
|
||||
{
|
||||
int64_t presentation_phase_us;
|
||||
int64_t current_phase_us;
|
||||
int64_t current_refresh_interval_start_us;
|
||||
|
||||
/*
|
||||
* Let's say we're just past next_presentation_time_us.
|
||||
*
|
||||
* First, we compute presentation_phase_us. Real presentation times don't
|
||||
* have to be exact multiples of refresh_interval_us and
|
||||
* presentation_phase_us represents this difference. Next, we compute
|
||||
* current phase and the refresh interval start corresponding to now_us.
|
||||
* Finally, add presentation_phase_us and a refresh interval to get the
|
||||
* next presentation after now_us.
|
||||
*
|
||||
* last_presentation_time_us
|
||||
* / next_presentation_time_us
|
||||
* / / now_us
|
||||
* / / / new next_presentation_time_us
|
||||
* |--|-------|---o---|-------|--> presentation times
|
||||
* | __|
|
||||
* | |presentation_phase_us
|
||||
* | |
|
||||
* | | now_us - presentation_phase_us
|
||||
* | | /
|
||||
* |-------|---o---|-------|-----> integer multiples of refresh_interval_us
|
||||
* | \__/
|
||||
* | |current_phase_us
|
||||
* | \
|
||||
* | current_refresh_interval_start_us
|
||||
* 0
|
||||
* First, we calculate current_phase_us, corresponding to the time since
|
||||
* the last integer multiple of the refresh interval passed after the last
|
||||
* presentation time. Subtracting this phase from now_us and adding a
|
||||
* refresh interval gets us the next possible presentation time after
|
||||
* now_us.
|
||||
*
|
||||
* last_presentation_time_us
|
||||
* / next_presentation_time_us
|
||||
* / / now_us
|
||||
* / / / new next_presentation_time_us
|
||||
* |-------|---o---|-------|--> possible presentation times
|
||||
* \_/ \_____/
|
||||
* / \
|
||||
* current_phase_us refresh_interval_us
|
||||
*/
|
||||
|
||||
presentation_phase_us = last_presentation_time_us % refresh_interval_us;
|
||||
current_phase_us = (now_us - presentation_phase_us) % refresh_interval_us;
|
||||
current_refresh_interval_start_us =
|
||||
now_us - presentation_phase_us - current_phase_us;
|
||||
|
||||
next_presentation_time_us =
|
||||
current_refresh_interval_start_us +
|
||||
presentation_phase_us +
|
||||
refresh_interval_us;
|
||||
current_phase_us = (now_us - last_presentation_time_us) % refresh_interval_us;
|
||||
next_presentation_time_us = now_us - current_phase_us + refresh_interval_us;
|
||||
}
|
||||
|
||||
if (frame_clock->is_next_presentation_time_valid)
|
||||
|
Loading…
Reference in New Issue
Block a user