add tests for large cordinates bounds when building aaclip
authorreed <reed@google.com>
Wed, 15 Oct 2014 14:05:09 +0000 (07:05 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 15 Oct 2014 14:05:09 +0000 (07:05 -0700)
BUG=skia:
TBR=

Review URL: https://codereview.chromium.org/658753002

include/core/SkRect.h
tests/AAClipTest.cpp

index 995beb8..96bf0f4 100644 (file)
@@ -75,6 +75,8 @@ struct SK_API SkIRect {
      */
     int height() const { return fBottom - fTop; }
 
+    SkISize size() const { return SkISize::Make(this->width(), this->height()); }
+
     /**
      *  Since the center of an integer rect may fall on a factional value, this
      *  method is defined to return (right + left) >> 1.
index 64e3784..6056565 100644 (file)
@@ -421,6 +421,22 @@ static void test_regressions() {
     }
 }
 
+// Building aaclip meant aa-scan-convert a path into a huge clip.
+// the old algorithm sized the supersampler to the size of the clip, which overflowed
+// its internal 16bit coordinates. The fix was to intersect the clip+path_bounds before
+// sizing the supersampler.
+//
+// Before the fix, the following code would assert in debug builds.
+//
+static void test_crbug_422693(skiatest::Reporter* reporter) {
+#if 0
+    SkRasterClip rc(SkIRect::MakeLTRB(-25000, -25000, 25000, 25000));
+    SkPath path;
+    path.addCircle(50, 50, 50);
+    rc.op(path, rc.getBounds().size(), SkRegion::kIntersect_Op, true);
+#endif
+}
+
 DEF_TEST(AAClip, reporter) {
     test_empty(reporter);
     test_path_bounds(reporter);
@@ -430,4 +446,5 @@ DEF_TEST(AAClip, reporter) {
     test_regressions();
     test_nearly_integral(reporter);
     test_really_a_rect(reporter);
+    test_crbug_422693(reporter);
 }