Bug 992731: Correctly treat a 'line' as a curve with a single inflection point stretching across the entire line. r=jwatt
authorBas Schouten <bschouten@mozilla.com>
Sat, 31 May 2014 03:13:23 +0200
changeset 185984 9f56d8be7e42b43fe6adc5b5a956e38242536593
parent 185983 16c8da443faacf70a083d3900b577221f50b1a13
child 185985 d092685332ffdcbe461d95696014004b49a353ae
push id26871
push userphilringnalda@gmail.com
push dateSun, 01 Jun 2014 03:29:42 +0000
treeherdermozilla-central@0e10c8151654 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs992731
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 992731: Correctly treat a 'line' as a curve with a single inflection point stretching across the entire line. r=jwatt
gfx/2d/Path.cpp
--- a/gfx/2d/Path.cpp
+++ b/gfx/2d/Path.cpp
@@ -370,18 +370,25 @@ FindInflectionPoints(const BezierControl
   Float c = Float(A.x) * B.y - Float(A.y) * B.x;
 
   if (a == 0) {
     // Not a quadratic equation.
     if (b == 0) {
       // Instead of a linear acceleration change we have a constant
       // acceleration change. This means the equation has no solution
       // and there are no inflection points, unless the constant is 0.
-      // In that case the curve is a straight line, but we'll let
-      // FlattenBezierCurveSegment deal with this.
+      // In that case the curve is a straight line, essentially that means
+      // the easiest way to deal with is is by saying there's an inflection
+      // point at t == 0. The inflection point approximation range found will
+      // automatically extend into infinity.
+      if (c == 0) {
+        *aCount = 1;
+        *aT1 = 0;
+        return;
+      }
       *aCount = 0;
       return;
     }
     *aT1 = -c / b;
     *aCount = 1;
     return;
   } else {
     Float discriminant = b * b - 4 * a * c;