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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2486>
This commit is contained in:
Dor Askayo 2021-03-13 12:55:09 +02:00 committed by Marge Bot
parent 33dc8ca187
commit 01846ffd91

View File

@ -407,8 +407,6 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock,
int64_t refresh_interval_us; int64_t refresh_interval_us;
int64_t min_render_time_allowed_us; int64_t min_render_time_allowed_us;
int64_t max_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_presentation_time_us;
int64_t next_update_time_us; int64_t next_update_time_us;
@ -510,6 +508,11 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock,
refresh_interval_us; refresh_interval_us;
} }
if (frame_clock->is_next_presentation_time_valid)
{
int64_t last_next_presentation_time_us;
int64_t time_since_last_next_presentation_time_us;
/* /*
* Skip one interval if we got an early presented event. * Skip one interval if we got an early presented event.
* *
@ -527,13 +530,13 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock,
last_next_presentation_time_us = frame_clock->next_presentation_time_us; last_next_presentation_time_us = frame_clock->next_presentation_time_us;
time_since_last_next_presentation_time_us = time_since_last_next_presentation_time_us =
next_presentation_time_us - last_next_presentation_time_us; next_presentation_time_us - last_next_presentation_time_us;
if (frame_clock->is_next_presentation_time_valid && if (time_since_last_next_presentation_time_us > 0 &&
time_since_last_next_presentation_time_us > 0 &&
time_since_last_next_presentation_time_us < (refresh_interval_us / 2)) time_since_last_next_presentation_time_us < (refresh_interval_us / 2))
{ {
next_presentation_time_us = next_presentation_time_us =
frame_clock->next_presentation_time_us + refresh_interval_us; frame_clock->next_presentation_time_us + refresh_interval_us;
} }
}
while (next_presentation_time_us < now_us + min_render_time_allowed_us) while (next_presentation_time_us < now_us + min_render_time_allowed_us)
next_presentation_time_us += refresh_interval_us; next_presentation_time_us += refresh_interval_us;