mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Cache animation computed values when animations change
Instead of recalculating the animation style every tick of an animation, cache the computed values when animations change. In addition to being more efficient, this will allow us to return animation rules as property declarations because we don't need to consult the final style to produce them.
This commit is contained in:
parent
7df4655b60
commit
83fa1b9eaa
9 changed files with 246 additions and 169 deletions
|
@ -592,8 +592,13 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
|||
false
|
||||
}
|
||||
|
||||
fn has_css_animations(&self) -> bool {
|
||||
unreachable!("this should be only called on gecko");
|
||||
fn has_css_animations(&self, context: &SharedStyleContext) -> bool {
|
||||
context
|
||||
.animation_states
|
||||
.read()
|
||||
.get(&self.as_node().opaque())
|
||||
.map(|set| set.has_active_animation())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn has_css_transitions(&self) -> bool {
|
||||
|
|
|
@ -574,7 +574,13 @@ impl LayoutThread {
|
|||
origin: ImmutableOrigin,
|
||||
animation_timeline_value: f64,
|
||||
animation_states: ServoArc<RwLock<FxHashMap<OpaqueNode, ElementAnimationSet>>>,
|
||||
stylesheets_changed: bool,
|
||||
) -> LayoutContext<'a> {
|
||||
let traversal_flags = match stylesheets_changed {
|
||||
true => TraversalFlags::ForCSSRuleChanges,
|
||||
false => TraversalFlags::empty(),
|
||||
};
|
||||
|
||||
LayoutContext {
|
||||
id: self.id,
|
||||
origin,
|
||||
|
@ -586,7 +592,7 @@ impl LayoutThread {
|
|||
animation_states,
|
||||
registered_speculative_painters: &self.registered_painters,
|
||||
current_time_for_animations: animation_timeline_value,
|
||||
traversal_flags: TraversalFlags::empty(),
|
||||
traversal_flags,
|
||||
snapshot_map: snapshot_map,
|
||||
},
|
||||
image_cache: self.image_cache.clone(),
|
||||
|
@ -1064,6 +1070,7 @@ impl LayoutThread {
|
|||
origin,
|
||||
data.animation_timeline_value,
|
||||
data.animations.clone(),
|
||||
data.stylesheets_changed,
|
||||
);
|
||||
|
||||
let dirty_root = unsafe {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue