Move epoch from LayoutTaskData to LayoutTask.

This commit is contained in:
Ms2ger 2015-11-06 18:06:18 +01:00
parent 4c3038f378
commit dd920a06f3

View file

@ -121,9 +121,6 @@ pub struct LayoutTaskData {
/// A queued response for the offset parent/rect of a node. /// A queued response for the offset parent/rect of a node.
pub offset_parent_response: OffsetParentResponse, pub offset_parent_response: OffsetParentResponse,
/// A counter for epoch messages
epoch: Epoch,
} }
/// Information needed by the layout task. /// Information needed by the layout task.
@ -214,6 +211,9 @@ pub struct LayoutTask {
/// The list of currently-running animations. /// The list of currently-running animations.
running_animations: Arc<HashMap<OpaqueNode, Vec<Animation>>>, running_animations: Arc<HashMap<OpaqueNode, Vec<Animation>>>,
/// A counter for epoch messages
epoch: Epoch,
/// A mutex to allow for fast, read-only RPC of layout's internal data /// A mutex to allow for fast, read-only RPC of layout's internal data
/// structures, while still letting the LayoutTask modify them. /// structures, while still letting the LayoutTask modify them.
/// ///
@ -431,6 +431,7 @@ impl LayoutTask {
root_flow: None, root_flow: None,
visible_rects: Arc::new(HashMap::with_hash_state(Default::default())), visible_rects: Arc::new(HashMap::with_hash_state(Default::default())),
running_animations: Arc::new(HashMap::new()), running_animations: Arc::new(HashMap::new()),
epoch: Epoch(0),
rw_data: Arc::new(Mutex::new( rw_data: Arc::new(Mutex::new(
LayoutTaskData { LayoutTaskData {
constellation_chan: constellation_chan, constellation_chan: constellation_chan,
@ -442,7 +443,6 @@ impl LayoutTask {
client_rect_response: Rect::zero(), client_rect_response: Rect::zero(),
resolved_style_response: None, resolved_style_response: None,
offset_parent_response: OffsetParentResponse::empty(), offset_parent_response: OffsetParentResponse::empty(),
epoch: Epoch(0),
})), })),
} }
} }
@ -612,8 +612,8 @@ impl LayoutTask {
self.collect_reports(reports_chan, possibly_locked_rw_data); self.collect_reports(reports_chan, possibly_locked_rw_data);
}, },
Msg::GetCurrentEpoch(sender) => { Msg::GetCurrentEpoch(sender) => {
let rw_data = possibly_locked_rw_data.lock(); let _rw_data = possibly_locked_rw_data.lock();
sender.send(rw_data.epoch).unwrap(); sender.send(self.epoch).unwrap();
}, },
Msg::GetWebFontLoadState(sender) => { Msg::GetWebFontLoadState(sender) => {
let _rw_data = possibly_locked_rw_data.lock(); let _rw_data = possibly_locked_rw_data.lock();
@ -1058,9 +1058,9 @@ impl LayoutTask {
debug!("Layout done!"); debug!("Layout done!");
rw_data.epoch.next(); self.epoch.next();
self.paint_chan self.paint_chan
.send(LayoutToPaintMsg::PaintInit(rw_data.epoch, paint_layer)) .send(LayoutToPaintMsg::PaintInit(self.epoch, paint_layer))
.unwrap(); .unwrap();
} }
}); });