Skip to content
  • Daniel van Vugt's avatar
    clutter/stage-cogl: Stop `schedule_update` repeatedly returning `now` · 35aa2781
    Daniel van Vugt authored and Georges Basile Stavracas Neto's avatar Georges Basile Stavracas Neto committed
    That could happen if the backend did not provide presentation timestamps,
    or if the screen was not changing other than the hardware cursor:
    
      if (stage_cogl->last_presentation_time == 0||
          stage_cogl->last_presentation_time < now - 150000)
        {
          stage_cogl->update_time = now;
          return;
        }
    
    By setting `update_time` to `now`, master_clock_get_swap_wait_time()
    returns 0:
    
      gint64 now = g_source_get_time (master_clock->source);
      if (min_update_time < now)
        {
          return 0;
        }
      else
        {
          gint64 delay_us = min_update_time - now;
          return (delay_us + 999) / 1000;
        }
    
    However, zero is a value unsupported by the default master clock
    due to:
    
      if (swap_delay != 0)
        return swap_delay;
    
    All cases are now handled by extrapolating when the next presentation
    time would be and calculating an appropriate update time to meet that.
    
    We also need to add a check for `update_time == last_update_time`, which
    is a situation that just became possible since we support old (or zero)
    values of `last_presentation_time`. This avoids getting more than one
    stage update per frame interval when input events arrive without
    triggering a stage redraw (e.g. moving the hardware cursor).
    
    !363
    35aa2781