Don't use Point2D<f32> for cubic curves anymore

This commit is contained in:
Anthony Ramine 2017-07-17 16:29:47 +02:00
parent e57ed3d42f
commit 5ffa523ccd
5 changed files with 70 additions and 83 deletions

View file

@ -9,7 +9,6 @@ use Atom;
use bezier::Bezier;
use context::SharedStyleContext;
use dom::OpaqueNode;
use euclid::Point2D;
use font_metrics::FontMetricsProvider;
use properties::{self, CascadeFlags, ComputedValues, ComputedValuesInner, Importance};
use properties::animated_properties::{AnimatableLonghand, AnimatedProperty, TransitionProperty};
@ -369,18 +368,10 @@ impl PropertyAnimation {
/// Update the given animation at a given point of progress.
pub fn update(&self, style: &mut ComputedValues, time: f64) {
let solve_bezier = |(p1, p2): (Point2D<_>, Point2D<_>)| {
let epsilon = 1. / (200. * (self.duration.seconds() as f64));
let bezier = Bezier::new(
Point2D::new(p1.x as f64, p1.y as f64),
Point2D::new(p2.x as f64, p2.y as f64),
);
bezier.solve(time, epsilon)
};
let epsilon = 1. / (200. * (self.duration.seconds() as f64));
let progress = match self.timing_function {
GenericTimingFunction::CubicBezier(p1, p2) => {
solve_bezier((p1, p2))
GenericTimingFunction::CubicBezier { x1, y1, x2, y2 } => {
Bezier::new(x1, y1, x2, y2).solve(time, epsilon)
},
GenericTimingFunction::Steps(steps, StepPosition::Start) => {
(time * (steps as f64)).ceil() / (steps as f64)
@ -405,7 +396,8 @@ impl PropertyAnimation {
out
},
GenericTimingFunction::Keyword(keyword) => {
solve_bezier(keyword.to_bezier_points())
let (x1, x2, y1, y2) = keyword.to_bezier();
Bezier::new(x1, x2, y1, y2).solve(time, epsilon)
},
};