diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2015-11-25 08:00:14 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2015-11-25 08:00:14 +0530 |
commit | 4f625d3ab67bc14b1563f90c48cf97ca59dc1a28 (patch) | |
tree | c21358898bfb9ed2746c9bc29f1e073ffae2e26b /components/layout/layout_task.rs | |
parent | 13a96fcaf78c299beb2021d3ae9dae8d9e916762 (diff) | |
parent | e881f0feebeec31582b3fbb848aeeb8b7ed70a32 (diff) | |
download | servo-4f625d3ab67bc14b1563f90c48cf97ca59dc1a28.tar.gz servo-4f625d3ab67bc14b1563f90c48cf97ca59dc1a28.zip |
Auto merge of #8670 - pcwalton:animation-expiration, r=glennw
Write animated values into the `ComputedValues` structures when animations complete or are interrupted.
This adds a new pair of reader-writer locks. I measured the performance
of style recalculation on Wikipedia and the overhead of the locks was
not measurable.
Closes #7816.
cc @paulrouget
r? @glennw
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8670)
<!-- Reviewable:end -->
Diffstat (limited to 'components/layout/layout_task.rs')
-rw-r--r-- | components/layout/layout_task.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index b8903a6363b..411611d6a0a 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -59,7 +59,7 @@ use std::mem::transmute; use std::ops::{Deref, DerefMut}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::mpsc::{channel, Sender, Receiver}; -use std::sync::{Arc, Mutex, MutexGuard}; +use std::sync::{Arc, Mutex, MutexGuard, RwLock}; use style::computed_values::{filter, mix_blend_mode}; use style::media_queries::{Device, MediaType}; use style::selector_matching::{Stylist, USER_OR_USER_AGENT_STYLESHEETS}; @@ -194,7 +194,10 @@ pub struct LayoutTask { visible_rects: Arc<HashMap<LayerId, Rect<Au>, DefaultState<FnvHasher>>>, /// The list of currently-running animations. - running_animations: Arc<HashMap<OpaqueNode, Vec<Animation>>>, + running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>, + + /// The list of animations that have expired since the last style recalculation. + expired_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>, /// A counter for epoch messages epoch: Epoch, @@ -420,7 +423,8 @@ impl LayoutTask { outstanding_web_fonts: outstanding_web_fonts_counter, root_flow: None, visible_rects: Arc::new(HashMap::with_hash_state(Default::default())), - running_animations: Arc::new(HashMap::new()), + running_animations: Arc::new(RwLock::new(HashMap::new())), + expired_animations: Arc::new(RwLock::new(HashMap::new())), epoch: Epoch(0), viewport_size: Size2D::new(Au(0), Au(0)), rw_data: Arc::new(Mutex::new( @@ -471,6 +475,7 @@ impl LayoutTask { new_animations_sender: Mutex::new(self.new_animations_sender.clone()), goal: goal, running_animations: self.running_animations.clone(), + expired_animations: self.expired_animations.clone(), } } @@ -1137,13 +1142,13 @@ impl LayoutTask { if let Some(mut root_flow) = self.root_flow.clone() { // Perform an abbreviated style recalc that operates without access to the DOM. - let animations = &*self.running_animations; + let animations = self.running_animations.read().unwrap(); profile(time::ProfilerCategory::LayoutStyleRecalc, self.profiler_metadata(), self.time_profiler_chan.clone(), || { animation::recalc_style_for_animations(flow_ref::deref_mut(&mut root_flow), - animations) + &*animations) }); } @@ -1182,7 +1187,8 @@ impl LayoutTask { if let Some(mut root_flow) = self.root_flow.clone() { // Kick off animations if any were triggered, expire completed ones. animation::update_animation_state(&self.constellation_chan, - &mut self.running_animations, + &mut *self.running_animations.write().unwrap(), + &mut *self.expired_animations.write().unwrap(), &self.new_animations_receiver, self.id); |