Make sure the animation always starts from the first frame, even if the

system is really busy and ClutterTimeline doesn't get a chance to call
us until it thinks several frames have passed

svn path=/trunk/; revision=147
This commit is contained in:
Dan Winship 2009-01-13 20:49:31 +00:00
parent b3860314b2
commit ca724920a3

View File

@ -64,8 +64,18 @@ ClutterFrameTicker.prototype = {
// So by dynamically adjusting the value of FRAME_RATE we can trick
// it into dealing with dropped frames.
let delta = frame - this._frame;
if (delta == 0)
// If there is a lot of setup to start the animation, then
// first frame number we get from clutter might be a long ways
// into the animation (or the animation might even be done).
// That looks bad, so we always start one frame into the
// animation then only do frame dropping from there.
let delta;
if (this._frame == 0)
delta = 1;
else
delta = frame - this._frame;
if (delta == 0) // protect against divide-by-0 if we get a frame twice
this.FRAME_RATE = this.TARGET_FRAME_RATE;
else
this.FRAME_RATE = this.TARGET_FRAME_RATE / delta;