diff options
-rw-r--r-- | tests/CanvasTest.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp index 06e06f0934..95030a3e42 100644 --- a/tests/CanvasTest.cpp +++ b/tests/CanvasTest.cpp @@ -876,3 +876,25 @@ DEF_TEST(Canvas_SaveLayerWithNullBoundsAndZeroBoundsImageFilter, r) { REPORTER_ASSERT(r, canvas.getDeviceClipBounds().isEmpty()); canvas.restore(); } + +#include "SkPaintImageFilter.h" + +// Test that we don't crash/assert when building a canvas with degenerate coordintes +// (esp. big ones, that might invoke tiling). +DEF_TEST(Canvas_degenerate_dimension, reporter) { + // Need a paint that will sneak us past the quickReject in SkCanvas, so we can test the + // raster code further downstream. + SkPaint paint; + paint.setImageFilter(SkPaintImageFilter::Make(SkPaint(), nullptr)); + REPORTER_ASSERT(reporter, !paint.canComputeFastBounds()); + + const int big = 100 * 1024; // big enough to definitely trigger tiling + const SkISize sizes[] {SkISize{0, big}, {big, 0}, {0, 0}}; + for (SkISize size : sizes) { + SkBitmap bm; + bm.setInfo(SkImageInfo::MakeN32Premul(size.width(), size.height())); + SkCanvas canvas(bm); + canvas.drawRect({0, 0, 100, 90*1024}, paint); + } +} + |