Bug 853889 - Check single-box orientaton in _cairo_bentley_ottmann_tessellate_rectangular_traps and _cairo_bentley_ottmann_tessellate_boxes. r=jmuizelaar
authorTom Klein <twointofive@gmail.com>
Thu, 18 Jun 2015 13:15:00 -0400
changeset 267868 e64c57bd478fe2d31417a5e88041462253a89101
parent 267867 e8c9a6fdad6a3d138712de338ccb5f7e1041fdbb
child 267869 613a0968f68d6c1ad860f00b67141f0360103a5d
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar
bugs853889
milestone41.0a1
Bug 853889 - Check single-box orientaton in _cairo_bentley_ottmann_tessellate_rectangular_traps and _cairo_bentley_ottmann_tessellate_boxes. r=jmuizelaar The fix for _cairo_bentley_ottmann_tessellate_boxes is from cairo upstream commit 11b6c49c103d53526e9805c8906fde5dbb2eb884.
gfx/cairo/cairo/src/cairo-bentley-ottmann-rectangular.c
gfx/tests/reftest/853889-1-ref.html
gfx/tests/reftest/853889-1.html
gfx/tests/reftest/reftest.list
--- a/gfx/cairo/cairo/src/cairo-bentley-ottmann-rectangular.c
+++ b/gfx/cairo/cairo/src/cairo-bentley-ottmann-rectangular.c
@@ -669,20 +669,29 @@ cairo_status_t
 {
     rectangle_t stack_rectangles[CAIRO_STACK_ARRAY_LENGTH (rectangle_t)];
     rectangle_t *rectangles;
     rectangle_t *stack_rectangles_ptrs[ARRAY_LENGTH (stack_rectangles) + 1];
     rectangle_t **rectangles_ptrs;
     cairo_status_t status;
     int i;
 
-    if (unlikely (traps->num_traps <= 1))
-	return CAIRO_STATUS_SUCCESS;
+    assert (traps->is_rectangular);
 
-    assert (traps->is_rectangular);
+    if (unlikely (traps->num_traps <= 1)) {
+        if (traps->num_traps == 1) {
+            cairo_trapezoid_t *trap = traps->traps;
+            if (trap->left.p1.x > trap->right.p1.x) {
+                cairo_line_t tmp = trap->left;
+                trap->left = trap->right;
+                trap->right = tmp;
+          }
+        }
+        return CAIRO_STATUS_SUCCESS;
+    }
 
     dump_traps (traps, "bo-rects-traps-in.txt");
 
     rectangles = stack_rectangles;
     rectangles_ptrs = stack_rectangles_ptrs;
     if (traps->num_traps > ARRAY_LENGTH (stack_rectangles)) {
 	rectangles = _cairo_malloc_ab_plus_c (traps->num_traps,
 					  sizeof (rectangle_t) +
@@ -741,18 +750,45 @@ cairo_status_t
     rectangle_t stack_rectangles[CAIRO_STACK_ARRAY_LENGTH (rectangle_t)];
     rectangle_t *rectangles;
     rectangle_t *stack_rectangles_ptrs[ARRAY_LENGTH (stack_rectangles) + 1];
     rectangle_t **rectangles_ptrs;
     const struct _cairo_boxes_chunk *chunk;
     cairo_status_t status;
     int i, j;
 
-    if (unlikely (in->num_boxes <= 1))
+    if (unlikely (in->num_boxes == 0)) {
+	_cairo_boxes_clear (out);
 	return CAIRO_STATUS_SUCCESS;
+    }
+
+    if (in->num_boxes == 1) {
+	if (in == out) {
+	    cairo_box_t *box = &in->chunks.base[0];
+
+	    if (box->p1.x > box->p2.x) {
+		cairo_fixed_t tmp = box->p1.x;
+		box->p1.x = box->p2.x;
+		box->p2.x = tmp;
+	    }
+	} else {
+	    cairo_box_t box = in->chunks.base[0];
+
+	    if (box.p1.x > box.p2.x) {
+		cairo_fixed_t tmp = box.p1.x;
+		box.p1.x = box.p2.x;
+		box.p2.x = tmp;
+	    }
+
+	    _cairo_boxes_clear (out);
+	    status = _cairo_boxes_add (out, &box);
+	    assert (status == CAIRO_STATUS_SUCCESS);
+	}
+	return CAIRO_STATUS_SUCCESS;
+    }
 
     rectangles = stack_rectangles;
     rectangles_ptrs = stack_rectangles_ptrs;
     if (in->num_boxes > ARRAY_LENGTH (stack_rectangles)) {
 	rectangles = _cairo_malloc_ab_plus_c (in->num_boxes,
 					  sizeof (rectangle_t) +
 					  sizeof (rectangle_t *),
 					  sizeof (rectangle_t *));
new file mode 100644
--- /dev/null
+++ b/gfx/tests/reftest/853889-1-ref.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html>
+  <head><title>Testcase for bug 853889</title></head>
+  <body>
+    <svg version="1.1" xmlns="http://www.w3.org/2000/svg"
+         xmlns:xlink="http://www.w3.org/1999/xlink"
+         width="400px" height="400px">
+      <path d="M 0 0 L 0 50 L 400 50 L 400 0 Z"
+            fill="rgb(12,200,12)"></path>
+    </svg>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/gfx/tests/reftest/853889-1.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<html>
+  <head><title>Testcase for bug 853889</title></head>
+  <body>
+    <svg version="1.1" xmlns="http://www.w3.org/2000/svg"
+         xmlns:xlink="http://www.w3.org/1999/xlink"
+         width="400px" height="400px">
+
+      <path d="M 0 400 L 0 450 L 600 450 L 600 400 Z"
+            fill="rgb(200,12,12)"></path>
+      <path d="M 0 0 L 0 50 L 600 50 L 600 0 Z"
+            fill="rgb(200,12,12)"></path>
+
+      <path d="M 0 0 L 0 50 L 600 50 L 600 0 Z
+               M 0 400 L 0 450 L 600 450 L 600 400 Z"
+            fill="rgb(12,200,12)"></path>
+    </svg>
+  </body>
+</html>
--- a/gfx/tests/reftest/reftest.list
+++ b/gfx/tests/reftest/reftest.list
@@ -1,5 +1,6 @@
 # 468496-1 will also detect bugs in video drivers.
 == 468496-1.html 468496-1-ref.html
 fuzzy-if(winWidget,175,443) == 611498-1.html 611498-ref.html
 skip-if(B2G) fuzzy-if(Android&&AndroidVersion>=15,8,1000) == 709477-1.html 709477-1-ref.html # bug 773482
 skip-if(!asyncPanZoom) == 1086723.html 1086723-ref.html
+== 853889-1.html 853889-1-ref.html