Bug 1063486 - Track current point in _cairo_path_bounder_curve_to r=jmuizelaar
authorTom Klein <twointofive@gmail.com>
Sat, 30 May 2015 16:07:48 +0100
changeset 246458 495a84cefc2307f1762aa18ed2250c95d3bc9ef6
parent 246457 7a1fa81730e41322eb1f619747bddbb4c0ab25a3
child 246459 c9c7ec25b894e40523b8c7f78974a944bcc7ab54
push id28830
push usercbook@mozilla.com
push dateMon, 01 Jun 2015 13:02:44 +0000
treeherdermozilla-central@39c85ec2d644 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar
bugs1063486
milestone41.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 1063486 - Track current point in _cairo_path_bounder_curve_to r=jmuizelaar
gfx/2d/unittest/TestCairo.cpp
gfx/cairo/cairo/src/cairo-path-bounds.c
gfx/tests/gtest/moz.build
--- a/gfx/2d/unittest/TestCairo.cpp
+++ b/gfx/2d/unittest/TestCairo.cpp
@@ -44,10 +44,53 @@ TEST(Cairo, Bug825721) {
 
   // This was the crash in 825721.  Note that centerY has to be non-zero,
   // and radius has to be not only large, but in particular range.
   // 825721 has a band-aid fix, where the crash is inevitable, but does
   // not fix the cause.  The same code crashes in cairo standalone.
   TryCircle(0.0, 1.0, 5761126469220696064.0);
 }
 
+TEST(Cairo, Bug1063486) {
+
+  double x1, y1, x2, y2;
+  const double epsilon = .01;
+
+  cairo_surface_t *surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
+  ASSERT_TRUE(surf != nullptr);
+
+  cairo_t *cairo = cairo_create(surf);
+  ASSERT_TRUE(cairo != nullptr);
+
+  printf("Path 1\n");
+  cairo_move_to(cairo, -20, -10);
+  cairo_line_to(cairo, 20, -10);
+  cairo_line_to(cairo, 20, 10);
+  cairo_curve_to(cairo, 10,10, -10,10, -20,10);
+  cairo_curve_to(cairo, -30,10, -30,-10, -20,-10);
+
+  cairo_path_extents(cairo, &x1, &y1, &x2, &y2);
+
+  ASSERT_LT(std::abs(-27.5 - x1), epsilon); // the failing coordinate
+  ASSERT_LT(std::abs(-10 - y1), epsilon);
+  ASSERT_LT(std::abs(20 - x2), epsilon);
+  ASSERT_LT(std::abs(10 - y2), epsilon);
+
+  printf("Path 2\n");
+  cairo_new_path(cairo);
+  cairo_move_to(cairo, 10, 30);
+  cairo_line_to(cairo, 90, 30);
+  cairo_curve_to(cairo, 30,30, 30,30, 10,30);
+  cairo_curve_to(cairo, 0,30, 0,0, 30,5);
+
+  cairo_path_extents(cairo, &x1, &y1, &x2, &y2);
+
+  ASSERT_LT(std::abs(4.019531 - x1), epsilon); // the failing coordinate
+  ASSERT_LT(std::abs(4.437500 - y1), epsilon);
+  ASSERT_LT(std::abs(90. - x2), epsilon);
+  ASSERT_LT(std::abs(30. - y2), epsilon);
+
+  cairo_surface_destroy(surf);
+  cairo_destroy(cairo);
+}
+
 }
 }
--- a/gfx/cairo/cairo/src/cairo-path-bounds.c
+++ b/gfx/cairo/cairo/src/cairo-path-bounds.c
@@ -126,16 +126,17 @@ static cairo_status_t
 	d->y < bounder->extents.p1.y || d->y > bounder->extents.p2.y)
     {
 	return _cairo_spline_bound (_cairo_path_bounder_line_to, bounder,
 				    &bounder->current_point, b, c, d);
     }
     else
     {
 	/* All control points are within the current extents. */
+	bounder->current_point = *d;
 	return CAIRO_STATUS_SUCCESS;
     }
 }
 
 static cairo_status_t
 _cairo_path_bounder_close_path (void *closure)
 {
     return CAIRO_STATUS_SUCCESS;
--- a/gfx/tests/gtest/moz.build
+++ b/gfx/tests/gtest/moz.build
@@ -27,16 +27,17 @@ UNIFIED_SOURCES += [
 ]
 
 # Because of gkmedia on windows we won't find these
 # symbols in xul.dll.
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'windows':
     UNIFIED_SOURCES += [ '/gfx/2d/unittest/%s' % p for p in [
         'TestBase.cpp',
         'TestBugs.cpp',
+        'TestCairo.cpp',
         'TestPoint.cpp',
         'TestScaling.cpp',
     ]]
     UNIFIED_SOURCES += [
         'TestMoz2D.cpp',
         'TestRect.cpp',
     ]