Commit 3f9b8687 authored by Dor Askayo's avatar Dor Askayo
Browse files

clutter/frame-clock: Simplify early presented event handling

A few calculations and assignments are done unnecessarily when the
last next presentation time is invalid. This increases the cognitive
complexity of the function for no reason.

No change in behavior.
parent 1f03a209
Pipeline #414066 passed with stages
in 37 minutes and 7 seconds
......@@ -406,8 +406,6 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock,
int64_t refresh_interval_us;
int64_t min_render_time_allowed_us;
int64_t max_render_time_allowed_us;
int64_t last_next_presentation_time_us;
int64_t time_since_last_next_presentation_time_us;
int64_t next_presentation_time_us;
int64_t next_update_time_us;
......@@ -509,28 +507,30 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock,
refresh_interval_us;
}
/*
* Skip one interval if we got an early presented event.
*
* last frame this was last_presentation_time
* / frame_clock->next_presentation_time_us
* / /
* |---|-o-----|-x----->
* | \
* \ next_presentation_time_us is thus right after the last one
* but got an unexpected early presentation
* \_/
* time_since_last_next_presentation_time_us
*
*/
last_next_presentation_time_us = frame_clock->next_presentation_time_us;
time_since_last_next_presentation_time_us =
next_presentation_time_us - last_next_presentation_time_us;
if (frame_clock->is_next_presentation_time_valid &&
time_since_last_next_presentation_time_us < (refresh_interval_us / 2))
if (frame_clock->is_next_presentation_time_valid)
{
next_presentation_time_us =
frame_clock->next_presentation_time_us + refresh_interval_us;
int64_t time_since_last_next_presentation_time_us =
next_presentation_time_us - frame_clock->next_presentation_time_us;
/*
* Skip one interval if we got an early presented event.
*
* last frame this was last_presentation_time
* / frame_clock->next_presentation_time_us
* / /
* |---|-o-----|-x----->
* | \
* \ next_presentation_time_us is thus right after the last one
* but got an unexpected early presentation
* \_/
* time_since_last_next_presentation_time_us
*
*/
if (time_since_last_next_presentation_time_us < (refresh_interval_us / 2))
{
next_presentation_time_us =
frame_clock->next_presentation_time_us + refresh_interval_us;
}
}
while (next_presentation_time_us < now_us + min_render_time_allowed_us)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment