From 1094b30627079a4f676036eb0771b08ff7e14536 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 28 Jul 2015 18:30:12 -0700 Subject: [PATCH] compositing: Tick animations right away when content enables animations. Otherwise, we have to wait for the next vsync. This was capping the framerate of the particles demo at 30 FPS in most cases. --- components/compositing/compositor.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 9fac205c680..468301317b8 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -530,7 +530,12 @@ impl IOCompositor { self.composite_if_necessary(CompositingReason::Animation); } AnimationState::AnimationCallbacksPresent => { - self.get_or_create_pipeline_details(pipeline_id).animation_callbacks_running = true; + if self.get_or_create_pipeline_details(pipeline_id).animation_callbacks_running { + return + } + self.get_or_create_pipeline_details(pipeline_id).animation_callbacks_running = + true; + self.tick_animations_for_pipeline(pipeline_id); self.composite_if_necessary(CompositingReason::Animation); } AnimationState::NoAnimationsPresent => { @@ -1072,13 +1077,15 @@ impl IOCompositor { for (pipeline_id, pipeline_details) in self.pipeline_details.iter() { if pipeline_details.animations_running || pipeline_details.animation_callbacks_running { - - self.constellation_chan.0.send(ConstellationMsg::TickAnimation(*pipeline_id)) - .unwrap(); + self.tick_animations_for_pipeline(*pipeline_id) } } } + fn tick_animations_for_pipeline(&self, pipeline_id: PipelineId) { + self.constellation_chan.0.send(ConstellationMsg::TickAnimation(pipeline_id)).unwrap() + } + fn constrain_viewport(&mut self, pipeline_id: PipelineId, constraints: ViewportConstraints) { let is_root = self.root_pipeline.as_ref().map_or(false, |root_pipeline| { root_pipeline.id == pipeline_id