Bug 1075399, part 3 - Don't insert zero length segments unless it's necessary. r=longsonr
authorJonathan Watt <jwatt@jwatt.org>
Fri, 03 Oct 2014 09:50:43 +0100
changeset 231768 a6976dea9d5667acaf4f5bb743655c4d122e2490
parent 231767 8f7fc1fdc6e42750fa16d772541425f745f4ac8a
child 231769 78b5cff9b699d6ba342d8ae2affc24e9ec95e71b
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs1075399
milestone35.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 1075399, part 3 - Don't insert zero length segments unless it's necessary. r=longsonr
content/svg/content/src/SVGPathData.cpp
--- a/content/svg/content/src/SVGPathData.cpp
+++ b/content/svg/content/src/SVGPathData.cpp
@@ -354,185 +354,183 @@ SVGPathData::BuildPath(PathBuilder* buil
       pathStart = segEnd = segStart + Point(mData[i], mData[i+1]);
       builder->MoveTo(segEnd);
       subpathHasLength = false;
       subpathContainsNonArc = false;
       break;
 
     case PATHSEG_LINETO_ABS:
       segEnd = Point(mData[i], mData[i+1]);
-      builder->LineTo(segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart);
+      if (segEnd != segStart) {
+        subpathHasLength = true;
+        builder->LineTo(segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_LINETO_REL:
       segEnd = segStart + Point(mData[i], mData[i+1]);
-      builder->LineTo(segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart);
+      if (segEnd != segStart) {
+        subpathHasLength = true;
+        builder->LineTo(segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_CURVETO_CUBIC_ABS:
       cp1 = Point(mData[i], mData[i+1]);
       cp2 = Point(mData[i+2], mData[i+3]);
       segEnd = Point(mData[i+4], mData[i+5]);
-      builder->BezierTo(cp1, cp2, segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart || segEnd != cp1 || segEnd != cp2);
+      if (segEnd != segStart || segEnd != cp1 || segEnd != cp2) {
+        subpathHasLength = true;
+        builder->BezierTo(cp1, cp2, segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_CURVETO_CUBIC_REL:
       cp1 = segStart + Point(mData[i], mData[i+1]);
       cp2 = segStart + Point(mData[i+2], mData[i+3]);
       segEnd = segStart + Point(mData[i+4], mData[i+5]);
-      builder->BezierTo(cp1, cp2, segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart || segEnd != cp1 || segEnd != cp2);
+      if (segEnd != segStart || segEnd != cp1 || segEnd != cp2) {
+        subpathHasLength = true;
+        builder->BezierTo(cp1, cp2, segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_CURVETO_QUADRATIC_ABS:
       cp1 = Point(mData[i], mData[i+1]);
       // Convert quadratic curve to cubic curve:
       tcp1 = segStart + (cp1 - segStart) * 2 / 3;
       segEnd = Point(mData[i+2], mData[i+3]); // set before setting tcp2!
       tcp2 = cp1 + (segEnd - cp1) / 3;
-      builder->BezierTo(tcp1, tcp2, segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart || segEnd != cp1);
+      if (segEnd != segStart || segEnd != cp1) {
+        subpathHasLength = true;
+        builder->BezierTo(tcp1, tcp2, segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_CURVETO_QUADRATIC_REL:
       cp1 = segStart + Point(mData[i], mData[i+1]);
       // Convert quadratic curve to cubic curve:
       tcp1 = segStart + (cp1 - segStart) * 2 / 3;
       segEnd = segStart + Point(mData[i+2], mData[i+3]); // set before setting tcp2!
       tcp2 = cp1 + (segEnd - cp1) / 3;
-      builder->BezierTo(tcp1, tcp2, segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart || segEnd != cp1);
+      if (segEnd != segStart || segEnd != cp1) {
+        subpathHasLength = true;
+        builder->BezierTo(tcp1, tcp2, segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_ARC_ABS:
     case PATHSEG_ARC_REL:
     {
       Point radii(mData[i], mData[i+1]);
       segEnd = Point(mData[i+5], mData[i+6]);
       if (segType == PATHSEG_ARC_REL) {
         segEnd += segStart;
       }
       if (segEnd != segStart) {
+        subpathHasLength = true;
         if (radii.x == 0.0f || radii.y == 0.0f) {
           builder->LineTo(segEnd);
         } else {
           nsSVGArcConverter converter(segStart, segEnd, radii, mData[i+2],
                                       mData[i+3] != 0, mData[i+4] != 0);
           while (converter.GetNextSegment(&cp1, &cp2, &segEnd)) {
             builder->BezierTo(cp1, cp2, segEnd);
           }
         }
       }
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart);
-      }
       break;
     }
 
     case PATHSEG_LINETO_HORIZONTAL_ABS:
       segEnd = Point(mData[i], segStart.y);
-      builder->LineTo(segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart);
+      if (segEnd != segStart) {
+        subpathHasLength = true;
+        builder->LineTo(segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_LINETO_HORIZONTAL_REL:
       segEnd = segStart + Point(mData[i], 0.0f);
-      builder->LineTo(segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart);
+      if (segEnd != segStart) {
+        subpathHasLength = true;
+        builder->LineTo(segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_LINETO_VERTICAL_ABS:
       segEnd = Point(segStart.x, mData[i]);
-      builder->LineTo(segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart);
+      if (segEnd != segStart) {
+        subpathHasLength = true;
+        builder->LineTo(segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_LINETO_VERTICAL_REL:
       segEnd = segStart + Point(0.0f, mData[i]);
-      builder->LineTo(segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart);
+      if (segEnd != segStart) {
+        subpathHasLength = true;
+        builder->LineTo(segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
       cp1 = SVGPathSegUtils::IsCubicType(prevSegType) ? segStart * 2 - cp2 : segStart;
       cp2 = Point(mData[i],   mData[i+1]);
       segEnd = Point(mData[i+2], mData[i+3]);
-      builder->BezierTo(cp1, cp2, segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart || segEnd != cp1 || segEnd != cp2);
+      if (segEnd != segStart || segEnd != cp1 || segEnd != cp2) {
+        subpathHasLength = true;
+        builder->BezierTo(cp1, cp2, segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
       cp1 = SVGPathSegUtils::IsCubicType(prevSegType) ? segStart * 2 - cp2 : segStart;
       cp2 = segStart + Point(mData[i], mData[i+1]);
       segEnd = segStart + Point(mData[i+2], mData[i+3]);
-      builder->BezierTo(cp1, cp2, segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart || segEnd != cp1 || segEnd != cp2);
+      if (segEnd != segStart || segEnd != cp1 || segEnd != cp2) {
+        subpathHasLength = true;
+        builder->BezierTo(cp1, cp2, segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
       cp1 = SVGPathSegUtils::IsQuadraticType(prevSegType) ? segStart * 2 - cp1 : segStart;
       // Convert quadratic curve to cubic curve:
       tcp1 = segStart + (cp1 - segStart) * 2 / 3;
       segEnd = Point(mData[i], mData[i+1]); // set before setting tcp2!
       tcp2 = cp1 + (segEnd - cp1) / 3;
-      builder->BezierTo(tcp1, tcp2, segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart || segEnd != cp1);
+      if (segEnd != segStart || segEnd != cp1) {
+        subpathHasLength = true;
+        builder->BezierTo(tcp1, tcp2, segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     case PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
       cp1 = SVGPathSegUtils::IsQuadraticType(prevSegType) ? segStart * 2 - cp1 : segStart;
       // Convert quadratic curve to cubic curve:
       tcp1 = segStart + (cp1 - segStart) * 2 / 3;
       segEnd = segStart + Point(mData[i], mData[i+1]); // changed before setting tcp2!
       tcp2 = cp1 + (segEnd - cp1) / 3;
-      builder->BezierTo(tcp1, tcp2, segEnd);
-      if (!subpathHasLength) {
-        subpathHasLength = (segEnd != segStart || segEnd != cp1);
+      if (segEnd != segStart || segEnd != cp1) {
+        subpathHasLength = true;
+        builder->BezierTo(tcp1, tcp2, segEnd);
       }
       subpathContainsNonArc = true;
       break;
 
     default:
       NS_NOTREACHED("Bad path segment type");
       return nullptr; // according to spec we'd use everything up to the bad seg anyway
     }