rewrite iterator to make msvc happy

Revert "Revert "add test for degenerate canvas dimension""

This reverts commit 1749af20a1.

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>
This commit is contained in:
Mike Reed 2018-04-13 15:34:16 -04:00
parent 584b501816
commit 490aa59ce2

View File

@ -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);
}
}