Move running_animations from LayoutTaskData to LayoutTask.

This commit is contained in:
Ms2ger 2015-11-06 17:51:58 +01:00
parent ee2b77e8f5
commit c469d09543
2 changed files with 11 additions and 9 deletions

View file

@ -51,6 +51,7 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Mutex<Sender<Anim
/// Processes any new animations that were discovered after style recalculation.
/// Also expire any old animations that have completed.
pub fn update_animation_state(rw_data: &mut LayoutTaskData,
running_animations: &mut Arc<HashMap<OpaqueNode, Vec<Animation>>>,
new_animations_receiver: &Receiver<Animation>,
pipeline_id: PipelineId) {
let mut new_running_animations = Vec::new();
@ -58,7 +59,7 @@ pub fn update_animation_state(rw_data: &mut LayoutTaskData,
new_running_animations.push(animation)
}
let mut running_animations_hash = (*rw_data.running_animations).clone();
let mut running_animations_hash = (**running_animations).clone();
if running_animations_hash.is_empty() && new_running_animations.is_empty() {
// Nothing to do. Return early so we don't flood the compositor with
@ -91,10 +92,10 @@ pub fn update_animation_state(rw_data: &mut LayoutTaskData,
}
}
rw_data.running_animations = Arc::new(running_animations_hash);
*running_animations = Arc::new(running_animations_hash);
let animation_state;
if rw_data.running_animations.is_empty() {
if running_animations.is_empty() {
animation_state = AnimationState::NoAnimationsPresent;
} else {
animation_state = AnimationState::AnimationsPresent;

View file

@ -122,9 +122,6 @@ pub struct LayoutTaskData {
/// A queued response for the offset parent/rect of a node.
pub offset_parent_response: OffsetParentResponse,
/// The list of currently-running animations.
pub running_animations: Arc<HashMap<OpaqueNode, Vec<Animation>>>,
/// A counter for epoch messages
epoch: Epoch,
}
@ -214,6 +211,9 @@ pub struct LayoutTask {
/// for any areas more than `DISPLAY_PORT_SIZE_FACTOR` screens away from this area.
visible_rects: Arc<HashMap<LayerId, Rect<Au>, DefaultState<FnvHasher>>>,
/// The list of currently-running animations.
running_animations: Arc<HashMap<OpaqueNode, Vec<Animation>>>,
/// A mutex to allow for fast, read-only RPC of layout's internal data
/// structures, while still letting the LayoutTask modify them.
///
@ -430,6 +430,7 @@ 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()),
rw_data: Arc::new(Mutex::new(
LayoutTaskData {
constellation_chan: constellation_chan,
@ -440,7 +441,6 @@ impl LayoutTask {
content_boxes_response: Vec::new(),
client_rect_response: Rect::zero(),
resolved_style_response: None,
running_animations: Arc::new(HashMap::new()),
offset_parent_response: OffsetParentResponse::empty(),
epoch: Epoch(0),
})),
@ -480,7 +480,7 @@ impl LayoutTask {
generation: self.generation,
new_animations_sender: Mutex::new(self.new_animations_sender.clone()),
goal: goal,
running_animations: rw_data.running_animations.clone(),
running_animations: self.running_animations.clone(),
}
}
@ -1288,7 +1288,7 @@ 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 = &*rw_data.running_animations;
let animations = &*self.running_animations;
profile(time::ProfilerCategory::LayoutStyleRecalc,
self.profiler_metadata(),
self.time_profiler_chan.clone(),
@ -1333,6 +1333,7 @@ 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(&mut *rw_data,
&mut self.running_animations,
&self.new_animations_receiver,
self.id);