[librsvg/librsvg-2.44] (#372): Fix mis-rendering in small arc segments



commit 5ba8f3d8200e8b3ce686e799bde4c898cb4923dc
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Nov 5 11:53:14 2018 -0600

    (#372): Fix mis-rendering in small arc segments
    
    The code was checking for division by 0.0 a bit too aggressively.  For
    small radiuses (say, 0.25 units), this gives intermediate results that
    are perfectly (and exactly!) representable within f64, but the code
    was checking for 0 too coarsely.
    
    Regenerated the test reference files for Adwaita that got minor
    rendering changes because of this.
    
    https://gitlab.gnome.org/GNOME/librsvg/issues/372

 rsvg_internals/src/path_builder.rs                 |   6 +++---
 .../adwaita/applications-science-symbolic-ref.png  | Bin 522 -> 519 bytes
 .../reftests/adwaita/mail-read-symbolic-ref.png    | Bin 509 -> 503 bytes
 .../adwaita/network-wireless-symbolic-ref.png      | Bin 419 -> 420 bytes
 .../preferences-system-time-symbolic-ref.png       | Bin 565 -> 564 bytes
 .../adwaita/user-not-tracked-symbolic-ref.png      | Bin 631 -> 630 bytes
 .../fixtures/reftests/bugs/372-small-arcs-ref.png  | Bin 0 -> 853 bytes
 tests/fixtures/reftests/bugs/372-small-arcs.svg    |  24 +++++++++++++++++++++
 8 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/rsvg_internals/src/path_builder.rs b/rsvg_internals/src/path_builder.rs
index 296e5ce8..35a19c3d 100644
--- a/rsvg_internals/src/path_builder.rs
+++ b/rsvg_internals/src/path_builder.rs
@@ -135,7 +135,7 @@ impl EllipticalArc {
 
         // Compute the transformed center (cx', cy').
         let d = (rx * y1_).powi(2) + (ry * x1_).powi(2);
-        if d.approx_eq_cairo(&0.0) {
+        if d == 0.0 {
             return ArcParameterization::Omit;
         }
         let k = {
@@ -156,7 +156,7 @@ impl EllipticalArc {
         let ux = (x1_ - cx_) / rx;
         let uy = (y1_ - cy_) / ry;
         let u_len = (ux * ux + uy * uy).abs().sqrt();
-        if u_len.approx_eq_cairo(&0.0) {
+        if u_len == 0.0 {
             return ArcParameterization::Omit;
         }
         let cos_theta1 = clamp(ux / u_len, -1.0, 1.0);
@@ -172,7 +172,7 @@ impl EllipticalArc {
         let vx = (-x1_ - cx_) / rx;
         let vy = (-y1_ - cy_) / ry;
         let v_len = (vx * vx + vy * vy).abs().sqrt();
-        if v_len.approx_eq_cairo(&0.0) {
+        if v_len == 0.0 {
             return ArcParameterization::Omit;
         }
         let dp_uv = ux * vx + uy * vy;
diff --git a/tests/fixtures/reftests/adwaita/applications-science-symbolic-ref.png 
b/tests/fixtures/reftests/adwaita/applications-science-symbolic-ref.png
index 65458134..18c0487a 100644
Binary files a/tests/fixtures/reftests/adwaita/applications-science-symbolic-ref.png and 
b/tests/fixtures/reftests/adwaita/applications-science-symbolic-ref.png differ
diff --git a/tests/fixtures/reftests/adwaita/mail-read-symbolic-ref.png 
b/tests/fixtures/reftests/adwaita/mail-read-symbolic-ref.png
index 21cb81e2..37f38b99 100644
Binary files a/tests/fixtures/reftests/adwaita/mail-read-symbolic-ref.png and 
b/tests/fixtures/reftests/adwaita/mail-read-symbolic-ref.png differ
diff --git a/tests/fixtures/reftests/adwaita/network-wireless-symbolic-ref.png 
b/tests/fixtures/reftests/adwaita/network-wireless-symbolic-ref.png
index d710c97e..56432569 100644
Binary files a/tests/fixtures/reftests/adwaita/network-wireless-symbolic-ref.png and 
b/tests/fixtures/reftests/adwaita/network-wireless-symbolic-ref.png differ
diff --git a/tests/fixtures/reftests/adwaita/preferences-system-time-symbolic-ref.png 
b/tests/fixtures/reftests/adwaita/preferences-system-time-symbolic-ref.png
index e76fdf23..3a1bb613 100644
Binary files a/tests/fixtures/reftests/adwaita/preferences-system-time-symbolic-ref.png and 
b/tests/fixtures/reftests/adwaita/preferences-system-time-symbolic-ref.png differ
diff --git a/tests/fixtures/reftests/adwaita/user-not-tracked-symbolic-ref.png 
b/tests/fixtures/reftests/adwaita/user-not-tracked-symbolic-ref.png
index c94996aa..6a74419d 100644
Binary files a/tests/fixtures/reftests/adwaita/user-not-tracked-symbolic-ref.png and 
b/tests/fixtures/reftests/adwaita/user-not-tracked-symbolic-ref.png differ
diff --git a/tests/fixtures/reftests/bugs/372-small-arcs-ref.png 
b/tests/fixtures/reftests/bugs/372-small-arcs-ref.png
new file mode 100644
index 00000000..1bd1fa8c
Binary files /dev/null and b/tests/fixtures/reftests/bugs/372-small-arcs-ref.png differ
diff --git a/tests/fixtures/reftests/bugs/372-small-arcs.svg b/tests/fixtures/reftests/bugs/372-small-arcs.svg
new file mode 100644
index 00000000..d3ce679f
--- /dev/null
+++ b/tests/fixtures/reftests/bugs/372-small-arcs.svg
@@ -0,0 +1,24 @@
+<svg xmlns="http://www.w3.org/2000/svg"; width="320" height="320" viewBox="0 0 16 16">
+    <path d="M 4.25 4
+             h .5 
+            a .25 .25 0 0 1 .25 .25
+            V 5
+            h .75
+            a .25 .25 0 0 1 .25 .25
+            v .5
+            a .25 .25 0 0 1 -.25 .25
+            H 5
+            v .75 
+            a .25 .25 0 0 1 -.25 .25
+            h -.5
+            A .25 .25 0 0 1 4 6.75
+            V 6
+            h -.75
+            A .25 .25 0 0 1 3 5.75
+            v -.5
+            A .25 .25 0 0 1 3.25 5
+            H 4
+            v -.75 
+            A .25 .25 0 0 1 4.25 4
+            z"/>
+</svg>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]