style: Switch animation timestamps to be doubles instead of floats.

32-bit floats are not enough to hold timestamps since the epoch and
result in jank.
This commit is contained in:
Patrick Walton 2015-08-01 17:14:14 -07:00
parent c6b043582b
commit cac01edf80
4 changed files with 60 additions and 57 deletions

View file

@ -33,15 +33,16 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation>
property_animation.update(new_style, 0.0);
// Kick off the animation.
let now = clock_ticks::precise_time_s() as f32;
let now = clock_ticks::precise_time_s();
let animation_style = new_style.get_animation();
let start_time = now + animation_style.transition_delay.0.get_mod(i).seconds();
let start_time =
now + (animation_style.transition_delay.0.get_mod(i).seconds() as f64);
new_animations_sender.send(Animation {
node: node.id(),
property_animation: property_animation,
start_time: start_time,
end_time: start_time +
animation_style.transition_duration.0.get_mod(i).seconds(),
(animation_style.transition_duration.0.get_mod(i).seconds() as f64),
}).unwrap()
}
}
@ -75,7 +76,7 @@ pub fn recalc_style_for_animation(flow: &mut Flow, animation: &Animation) {
return
}
let now = clock_ticks::precise_time_s() as f32;
let now = clock_ticks::precise_time_s() as f64;
let mut progress = (now - animation.start_time) / animation.duration();
if progress > 1.0 {
progress = 1.0
@ -100,7 +101,7 @@ pub fn recalc_style_for_animation(flow: &mut Flow, animation: &Animation) {
/// Handles animation updates.
pub fn tick_all_animations(layout_task: &LayoutTask, rw_data: &mut LayoutTaskData) {
let running_animations = mem::replace(&mut rw_data.running_animations, Vec::new());
let now = clock_ticks::precise_time_s() as f32;
let now = clock_ticks::precise_time_s() as f64;
for running_animation in running_animations.into_iter() {
layout_task.tick_animation(&running_animation, rw_data);