From 3087c1f382f1cd547598dc75f47ccbc8fe1e6e0f Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Wed, 23 May 2018 08:30:04 -0400 Subject: [PATCH] tweak tolerance again for cubics Bug: 845489 Bug: skia:7995 Change-Id: I05554377bd5630b7134864b6db282358613f1030 Reviewed-on: https://skia-review.googlesource.com/129721 Reviewed-by: Cary Clark Commit-Queue: Mike Reed --- src/core/SkScan_Path.cpp | 4 +++- tests/ClipCubicTest.cpp | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp index 1854a7edd7..90a2230526 100644 --- a/src/core/SkScan_Path.cpp +++ b/src/core/SkScan_Path.cpp @@ -567,7 +567,9 @@ static bool clip_to_limit(const SkRegion& orig, SkRegion* reduced) { // // This value has been determined trial and error: pick the smallest value (after the 0.5) that // fixes any problematic cases (e.g. crbug.com/844457) -static const double kConservativeRoundBias = 0.5 + 1.0 / SK_FDot6One; +// NOTE: cubics appear to be the main reason for needing this slop. If we could (perhaps) have a +// more accurate walker for cubics, we may be able to reduce this fudge factor. +static const double kConservativeRoundBias = 0.5 + 1.5 / SK_FDot6One; /** * Round the value down. This is used to round the top and left of a rectangle, diff --git a/tests/ClipCubicTest.cpp b/tests/ClipCubicTest.cpp index 427e753322..ca2f62314d 100644 --- a/tests/ClipCubicTest.cpp +++ b/tests/ClipCubicTest.cpp @@ -212,13 +212,23 @@ DEF_TEST(test_fuzz_crbug_698714, reporter) { canvas->drawPath(path, paint); } -DEF_TEST(cubic_scan_error_crbug_844457, reporter) { +DEF_TEST(cubic_scan_error_crbug_844457_and_845489, reporter) { auto surface(SkSurface::MakeRasterN32Premul(100, 100)); + SkCanvas* canvas = surface->getCanvas(); + SkPaint p; SkPath path; path.moveTo(-30/64.0, -31/64.0); path.cubicTo(-31/64.0, -31/64,-31/64.0, -31/64,-31/64.0, 100); - path.lineTo(100,100); + path.lineTo(100, 100); + canvas->drawPath(path, p); - surface->getCanvas()->drawPath(path, SkPaint()); + // May need to define SK_RASTERIZE_EVEN_ROUNDING to trigger the need for this test + path.reset(); + path.moveTo(-30/64.0f, -31/64.0f + 1/256.0f); + path.cubicTo(-31/64.0f + 1/256.0f, -31/64.0f + 1/256.0f, + -31/64.0f + 1/256.0f, -31/64.0f + 1/256.0f, + -31/64.0f + 1/256.0f, 100); + path.lineTo(100, 100); + canvas->drawPath(path, p); }