aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-04-13 14:44:25 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-13 19:17:32 +0000
commit715b919e37aa662131ca70b0056bc8192d4bcee9 (patch)
treec28c529f50a6967465e4da26fd47e71882546c10 /tests
parent28a142f213cf4d7dd4e6005a96cca6cb67a9887d (diff)
add test for degenerate canvas dimension
Bug: skia: Change-Id: Ib0532e706fbcdb126619301591ddc64910babdef Reviewed-on: https://skia-review.googlesource.com/121341 Reviewed-by: Yuqian Li <liyuqian@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/CanvasTest.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 06e06f0934..380bdab392 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -876,3 +876,24 @@ 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
+ for (SkISize size : {SkISize{0, big}, {big, 0}, {0, 0}}) {
+ SkBitmap bm;
+ bm.setInfo(SkImageInfo::MakeN32Premul(size.width(), size.height()));
+ SkCanvas canvas(bm);
+ canvas.drawRect({0, 0, 100, 90*1024}, paint);
+ }
+}
+