Bug 769115 - Calculate marker orientation correctly for arc endpoints. r=jwatt
authorCameron McCormack <cam@mcc.id.au>
Sun, 08 Jul 2012 21:36:07 +1000
changeset 103923 a8b4c3e86584d00b60733eb580d36f7a50b7e772
parent 103922 fa1bf35aae2e7d838126f8031e6b9f713d556707
child 103924 f86b9868abd929ee8ddd064287979b18803b0979
push id191
push userlsblakk@mozilla.com
push dateFri, 05 Oct 2012 17:12:53 +0000
treeherdermozilla-release@ddb22ac6c03b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs769115
milestone16.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 769115 - Calculate marker orientation correctly for arc endpoints. r=jwatt
content/svg/content/src/SVGPathData.cpp
layout/reftests/svg/marker-orientation-01-ref.svg
layout/reftests/svg/marker-orientation-01.svg
layout/reftests/svg/reftest.list
--- a/content/svg/content/src/SVGPathData.cpp
+++ b/content/svg/content/src/SVGPathData.cpp
@@ -694,20 +694,19 @@ SVGPathData::GetMarkerPositioningData(ns
         ry *= s;
         root = 0.0;
       }
 
       double cxp =  root * rx * y1p / ry;  // F.6.5.2
       double cyp = -root * ry * x1p / rx;
 
       double theta, delta;
-      theta = AngleOfVector(gfxPoint((x1p-cxp)/rx, (y1p-cyp)/ry) -   // F.6.5.5
-                            gfxPoint(1.0, 0.0));
-      delta = AngleOfVector(gfxPoint((-x1p-cxp)/rx, (-y1p-cyp)/ry) - // F.6.5.6
-                            gfxPoint((x1p-cxp)/rx, (y1p-cyp)/ry));
+      theta = AngleOfVector(gfxPoint((x1p-cxp)/rx, (y1p-cyp)/ry));    // F.6.5.5
+      delta = AngleOfVector(gfxPoint((-x1p-cxp)/rx, (-y1p-cyp)/ry)) - // F.6.5.6
+              theta;
       if (!sweepFlag && delta > 0)
         delta -= 2.0 * M_PI;
       else if (sweepFlag && delta < 0)
         delta += 2.0 * M_PI;
 
       double tx1, ty1, tx2, ty2;
       tx1 = -cos(angle)*rx*sin(theta) - sin(angle)*ry*cos(theta);
       ty1 = -sin(angle)*rx*sin(theta) + cos(angle)*ry*cos(theta);
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/marker-orientation-01-ref.svg
@@ -0,0 +1,68 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink">
+  <title>Reference for test that marker orientation is correct at the end of arcs</title>
+  <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=769115 -->
+
+  <defs>
+    <g id="m1" transform="translate(-20,-20)" fill="blue">
+      <rect x="5" y="15" width="22" height="10"/>
+      <path d="M 25,10 35,20 25,30 z"/>
+    </g>
+
+    <g id="m2" transform="translate(-20,-20)" fill="red">
+      <rect x="5" y="15" width="22" height="10"/>
+      <path d="M 25,10 35,20 25,30 z"/>
+    </g>
+  </defs>
+
+  <g fill="none">
+    <!-- arcs that go from the left of the circle to... -->
+    <g>
+      <!-- ...90 degrees anti-clockwise -->
+      <use xlink:href="#m1" transform="translate(100,100)rotate(90)"/>
+      <use xlink:href="#m2" transform="rotate(-90,150,100)translate(100,100)rotate(90)"/>
+      <!-- ...180 degrees anti-clockwise -->
+      <use xlink:href="#m2" transform="rotate(-180,150,100)translate(100,100)rotate(90)"/>
+      <!-- ...270 degrees anti-clockwise -->
+      <use xlink:href="#m2" transform="rotate(-270,150,100)translate(100,100)rotate(90)"/>
+    </g>
+
+    <!-- arcs that go from the left of the circle to... -->
+    <g transform="translate(250,0)">
+      <!-- ...90 degrees anti-clockwise -->
+      <use xlink:href="#m1" transform="translate(100,100)rotate(-90)"/>
+      <use xlink:href="#m2" transform="rotate(90,150,100)translate(100,100)rotate(-90)"/>
+      <!-- ...180 degrees anti-clockwise -->
+      <use xlink:href="#m2" transform="rotate(180,150,100)translate(100,100)rotate(-90)"/>
+      <!-- ...270 degrees anti-clockwise -->
+      <use xlink:href="#m2" transform="rotate(270,150,100)translate(100,100)rotate(-90)"/>
+    </g>
+
+    <!-- arcs that go from the right of the circle to... -->
+    <g transform="translate(0,250)">
+      <!-- ...90 degrees anti-clockwise -->
+      <use xlink:href="#m1" transform="translate(200,100)rotate(90)"/>
+      <use xlink:href="#m2" transform="rotate(90,150,100)translate(200,100)rotate(90)"/>
+      <!-- ...180 degrees anti-clockwise -->
+      <use xlink:href="#m2" transform="rotate(180,150,100)translate(200,100)rotate(90)"/>
+      <!-- ...270 degrees anti-clockwise -->
+      <use xlink:href="#m2" transform="rotate(270,150,100)translate(200,100)rotate(90)"/>
+    </g>
+
+    <!-- arcs that go from the right of the circle to... -->
+    <g transform="translate(250,250)">
+      <!-- ...90 degrees clockwise -->
+      <use xlink:href="#m1" transform="translate(200,100)rotate(-90)"/>
+      <use xlink:href="#m2" transform="rotate(-90,150,100)translate(200,100)rotate(-90)"/>
+      <!-- ...180 degrees clockwise -->
+      <use xlink:href="#m2" transform="rotate(-180,150,100)translate(200,100)rotate(-90)"/>
+      <!-- ...270 degrees clockwise -->
+      <use xlink:href="#m2" transform="rotate(-270,150,100)translate(200,100)rotate(-90)"/>
+    </g>
+  </g>
+
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/marker-orientation-01.svg
@@ -0,0 +1,63 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg">
+  <title>Test that marker orientation is correct at the end of arcs</title>
+  <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=769115 -->
+
+  <marker id="m1" markerWidth="40" markerHeight="40" refX="20" refY="20"
+          markerUnits="userSpaceOnUse" orient="auto" fill="blue">
+    <rect x="5" y="15" width="22" height="10"/>
+    <path d="M 25,10 35,20 25,30 z"/>
+  </marker>
+
+  <marker id="m2" markerWidth="40" markerHeight="40" refX="20" refY="20"
+          markerUnits="userSpaceOnUse" orient="auto" fill="red">
+    <rect x="5" y="15" width="22" height="10"/>
+    <path d="M 25,10 35,20 25,30 z"/>
+  </marker>
+
+  <g fill="none">
+    <!-- arcs that go from the left of the circle to... -->
+    <g marker-end="url(#m2)">
+      <!-- ...90 degrees anti-clockwise -->
+      <path d="M100,100 A 50,50 0 1 0 150,50" marker-start="url(#m1)"/>
+      <!-- ...180 degrees anti-clockwise -->
+      <path d="M100,100 A 50,50 0 0 0 200,100"/>
+      <!-- ...270 degrees anti-clockwise -->
+      <path d="M100,100 A 50,50 0 0 0 150,150"/>
+    </g>
+
+    <!-- arcs that go from the left of the circle to... -->
+    <g marker-end="url(#m2)" transform="translate(250,0)">
+      <!-- ...90 degrees clockwise -->
+      <path d="M100,100 A 50,50 0 0 1 150,50" marker-start="url(#m1)"/>
+      <!-- ...180 degrees clockwise -->
+      <path d="M100,100 A 50,50 0 1 1 200,100"/>
+      <!-- ...270 degrees clockwise -->
+      <path d="M100,100 A 50,50 0 1 1 150,150"/>
+    </g>
+
+    <!-- arcs that go from the right of the circle to... -->
+    <g marker-end="url(#m2)" transform="translate(0,250)">
+      <!-- ...90 degrees anti-clockwise -->
+      <path d="M200,100 A 50,50 0 0 1 150,150" marker-start="url(#m1)"/>
+      <!-- ...180 degrees anti-clockwise -->
+      <path d="M200,100 A 50,50 0 0 1 100,100"/>
+      <!-- ...270 degrees anti-clockwise -->
+      <path d="M200,100 A 50,50 0 1 1 150,50"/>
+    </g>
+
+    <!-- arcs that go from the right of the circle to... -->
+    <g marker-end="url(#m2)" transform="translate(250,250)">
+      <!-- ...90 degrees anti-clockwise -->
+      <path d="M200,100 A 50,50 0 0 0 150,50" marker-start="url(#m1)"/>
+      <!-- ...180 degrees anti-clockwise -->
+      <path d="M200,100 A 50,50 0 1 0 100,100"/>
+      <!-- ...270 degrees anti-clockwise -->
+      <path d="M200,100 A 50,50 0 1 0 150,150"/>
+    </g>
+  </g>
+
+</svg>
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -164,16 +164,17 @@ fails == inline-in-xul-basic-01.xul pass
 == lang-attribute-01.svg pass.svg
 == lang-attribute-02.svg pass.svg
 == lang-attribute-03.svg pass.svg
 == linearGradient-basic-01.svg pass.svg
 == linearGradient-basic-02.svg pass.svg
 == markers-and-group-opacity-01.svg markers-and-group-opacity-01-ref.svg
 == marker-attribute-01.svg pass.svg
 == marker-viewBox-01.svg marker-viewBox-01-ref.svg
+== marker-orientation-01.svg marker-orientation-01-ref.svg
 == mask-basic-01.svg pass.svg
 == mask-basic-02.svg mask-basic-02-ref.svg
 == mask-extref-dataURI-01.svg pass.svg
 == mask-containing-masked-content-01.svg pass.svg
 == mask-transformed-01.svg mask-transformed-01-ref.svg
 == nested-viewBox-01.svg pass.svg
 == nesting-invalid-01.svg nesting-invalid-01-ref.svg
 == non-scaling-stroke-01.svg non-scaling-stroke-01-ref.svg