From 8444913d2c32ceca8a0f22c9dd7537c615c39af7 Mon Sep 17 00:00:00 2001 From: senorblanco Date: Wed, 25 Nov 2015 10:32:18 -0800 Subject: [PATCH] Don't use SkRect::MakeLargest() for clip bounds in image filter tests. Much of the Skia code dealing with clip bounds does not handle overflow, so if we start doing any math on these rects, the code will break. Use explicit reasonable values instead. BUG=skia: Review URL: https://codereview.chromium.org/1479563002 --- tests/ImageFilterTest.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp index 39d0dc2..4b55274 100644 --- a/tests/ImageFilterTest.cpp +++ b/tests/ImageFilterTest.cpp @@ -319,7 +319,7 @@ static void test_crop_rects(SkImageFilter::Proxy* proxy, skiatest::Reporter* rep SkIPoint offset; SkString str; str.printf("filter %d", static_cast(i)); - SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr, SkImageFilter::kApprox_SizeConstraint); + SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr, SkImageFilter::kApprox_SizeConstraint); REPORTER_ASSERT_MESSAGE(reporter, filter->filterImage(proxy, bitmap, ctx, &result, &offset), str.c_str()); REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, str.c_str()); @@ -364,14 +364,14 @@ static void test_negative_blur_sigma(SkImageFilter::Proxy* proxy, skiatest::Repo SkBitmap positiveResult1, negativeResult1; SkBitmap positiveResult2, negativeResult2; SkIPoint offset; - SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr, SkImageFilter::kApprox_SizeConstraint); - positiveFilter->filterImage(proxy, gradient, ctx, &positiveResult1, &offset); - negativeFilter->filterImage(proxy, gradient, ctx, &negativeResult1, &offset); + SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr, SkImageFilter::kApprox_SizeConstraint); + REPORTER_ASSERT(reporter, positiveFilter->filterImage(proxy, gradient, ctx, &positiveResult1, &offset)); + REPORTER_ASSERT(reporter, negativeFilter->filterImage(proxy, gradient, ctx, &negativeResult1, &offset)); SkMatrix negativeScale; negativeScale.setScale(-SK_Scalar1, SK_Scalar1); - SkImageFilter::Context negativeCTX(negativeScale, SkIRect::MakeLargest(), nullptr, SkImageFilter::kApprox_SizeConstraint); - positiveFilter->filterImage(proxy, gradient, negativeCTX, &negativeResult2, &offset); - negativeFilter->filterImage(proxy, gradient, negativeCTX, &positiveResult2, &offset); + SkImageFilter::Context negativeCTX(negativeScale, SkIRect::MakeWH(32, 32), nullptr, SkImageFilter::kApprox_SizeConstraint); + REPORTER_ASSERT(reporter, positiveFilter->filterImage(proxy, gradient, negativeCTX, &negativeResult2, &offset)); + REPORTER_ASSERT(reporter, negativeFilter->filterImage(proxy, gradient, negativeCTX, &positiveResult2, &offset)); SkAutoLockPixels lockP1(positiveResult1); SkAutoLockPixels lockP2(positiveResult2); SkAutoLockPixels lockN1(negativeResult1); @@ -1156,7 +1156,7 @@ DEF_TEST(ComposedImageFilterOffset, reporter) { SkAutoTUnref composedFilter(SkComposeImageFilter::Create(blurFilter, offsetFilter.get())); SkBitmap result; SkIPoint offset; - SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr, SkImageFilter::kApprox_SizeConstraint); + SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr, SkImageFilter::kApprox_SizeConstraint); REPORTER_ASSERT(reporter, composedFilter->filterImage(&proxy, bitmap, ctx, &result, &offset)); REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0); } @@ -1174,7 +1174,7 @@ DEF_TEST(PartialCropRect, reporter) { SkAutoTUnref filter(make_grayscale(nullptr, &cropRect)); SkBitmap result; SkIPoint offset; - SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr, SkImageFilter::kApprox_SizeConstraint); + SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr, SkImageFilter::kApprox_SizeConstraint); REPORTER_ASSERT(reporter, filter->filterImage(&proxy, bitmap, ctx, &result, &offset)); REPORTER_ASSERT(reporter, offset.fX == 0); REPORTER_ASSERT(reporter, offset.fY == 0); -- 2.7.4