Bug 1063486 - Track current point in _cairo_path_bounder_curve_to r=jmuizelaar

This commit is contained in:
Tom Klein 2015-05-30 16:07:48 +01:00
parent 1e9c1097ad
commit d98692ef21
3 changed files with 45 additions and 0 deletions

View File

@ -49,5 +49,48 @@ TEST(Cairo, Bug825721) {
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);
}
}
}

View File

@ -131,6 +131,7 @@ _cairo_path_bounder_curve_to (void *closure,
else
{
/* All control points are within the current extents. */
bounder->current_point = *d;
return CAIRO_STATUS_SUCCESS;
}
}

View File

@ -32,6 +32,7 @@ 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',
]]