aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/CanvasTest.cpp
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-04-13 15:34:16 -0400
committerGravatar Mike Reed <reed@google.com>2018-04-13 20:41:25 +0000
commit490aa59ce2e90a85c09bd8a8ac477272385f25b0 (patch)
tree32472b5033fe1c64d589c60641cf81f79185e38b /tests/CanvasTest.cpp
parent584b501816657e38b8c1406103a54c3c7fc1c5e4 (diff)
rewrite iterator to make msvc happy
Revert "Revert "add test for degenerate canvas dimension"" This reverts commit 1749af20a11d0f364dbb7cad8dc89101f956c923. Bug: skia: Change-Id: I382cbef397dfba600a6779b159764239399b177f Reviewed-on: https://skia-review.googlesource.com/121344 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'tests/CanvasTest.cpp')
-rw-r--r--tests/CanvasTest.cpp22
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);
+ }
+}
+