mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Add new layer messages for passing motion path info.
This also includes the implementation of SetAnimatable, FromAnimatable, and merge the final matrix with motion path. Besides, we always use PathBuilderSkia for calculating the gfx::Path for web-renderer. Differential Revision: https://phabricator.services.mozilla.com/D50011
This commit is contained in:
parent
fc1233f3d2
commit
d99606a841
1 changed files with 7 additions and 4 deletions
|
@ -46,7 +46,7 @@ impl SVGPathData {
|
||||||
|
|
||||||
/// Create a normalized copy of this path by converting each relative
|
/// Create a normalized copy of this path by converting each relative
|
||||||
/// command to an absolute command.
|
/// command to an absolute command.
|
||||||
fn normalize(&self) -> Box<[PathCommand]> {
|
pub fn normalize(&self) -> Self {
|
||||||
let mut state = PathTraversalState {
|
let mut state = PathTraversalState {
|
||||||
subpath_start: CoordPair::new(0.0, 0.0),
|
subpath_start: CoordPair::new(0.0, 0.0),
|
||||||
pos: CoordPair::new(0.0, 0.0),
|
pos: CoordPair::new(0.0, 0.0),
|
||||||
|
@ -56,7 +56,8 @@ impl SVGPathData {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|seg| seg.normalize(&mut state))
|
.map(|seg| seg.normalize(&mut state))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
result.into_boxed_slice()
|
|
||||||
|
SVGPathData(crate::ArcSlice::from_iter(result.into_iter()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,8 +120,9 @@ impl Animate for SVGPathData {
|
||||||
// re-normalize again.
|
// re-normalize again.
|
||||||
let result = self
|
let result = self
|
||||||
.normalize()
|
.normalize()
|
||||||
|
.0
|
||||||
.iter()
|
.iter()
|
||||||
.zip(other.normalize().iter())
|
.zip(other.normalize().0.iter())
|
||||||
.map(|(a, b)| a.animate(&b, procedure))
|
.map(|(a, b)| a.animate(&b, procedure))
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
@ -134,8 +136,9 @@ impl ComputeSquaredDistance for SVGPathData {
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
self.normalize()
|
self.normalize()
|
||||||
|
.0
|
||||||
.iter()
|
.iter()
|
||||||
.zip(other.normalize().iter())
|
.zip(other.normalize().0.iter())
|
||||||
.map(|(this, other)| this.compute_squared_distance(&other))
|
.map(|(this, other)| this.compute_squared_distance(&other))
|
||||||
.sum()
|
.sum()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue