From e2faf17bcc523557e44ef443b48a53f286886a53 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Mon, 6 Aug 2012 19:01:34 +0000 Subject: Even when the pts are restricted to 32K values, we can still overflow computing a fixed-point coefficient for quadratics. To avoid this, we bias these coefficients, storing 1/2 of their actual value, and then apply the 2x unbias in updateQuadratic(). Fixes http://code.google.com/p/chromium/issues/detail?id=140803 Review URL: https://codereview.appspot.com/6450099 git-svn-id: http://skia.googlecode.com/svn/trunk@4960 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tests/DrawPathTest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/DrawPathTest.cpp') diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp index f421ee87b6..8b787bb197 100644 --- a/tests/DrawPathTest.cpp +++ b/tests/DrawPathTest.cpp @@ -76,6 +76,23 @@ static void test_crbug131181(skiatest::Reporter*) { canvas->drawPath(path, paint); } +// This used to assert in debug builds (and crash writing bad memory in release) +// because we overflowed an intermediate value (B coefficient) setting up our +// stepper for the quadratic. Now we bias that value by 1/2 so we don't overflow +static void test_crbug_140803(skiatest::Reporter* reporter) { + SkBitmap bm; + bm.setConfig(SkBitmap::kARGB_8888_Config, 2700, 30*1024); + bm.allocPixels(); + SkCanvas canvas(bm); + + SkPath path; + path.moveTo(2762, 20); + path.quadTo(11, 21702, 10, 21706); + SkPaint paint; + paint.setAntiAlias(true); + canvas.drawPath(path, paint); +} + // Need to exercise drawing an inverse-path whose bounds intersect the clip, // but whose edges do not (since its a quad which draws only in the bottom half // of its bounds). @@ -208,6 +225,7 @@ static void TestDrawPath(skiatest::Reporter* reporter) { test_bigcubic(reporter); test_crbug_124652(reporter); test_crbug_140642(reporter); + test_crbug_140803(reporter); test_inversepathwithclip(reporter); // test_crbug131181(reporter); } -- cgit v1.2.3