Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: tests/ImageFilterTest.cpp

Issue 2114313002: Handle negative scale in SkDropShadowImageFilter::onFilterNodeBounds. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: I can has unit test. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/ImageFilterTest.cpp
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index dd0824551b157342e0791c9cd537bedc1812de45..f46519d94eaa23759247b870724200a5eaceac16 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -856,6 +856,64 @@ DEF_TEST(ImageFilterDilateThenBlurBounds, reporter) {
REPORTER_ASSERT(reporter, bounds == expectedBounds);
}
+DEF_TEST(ImageFilterScaledBlurRadius, reporter) {
+ // Each blur should spread 3*sigma, so 3 for the blur and 30 for the shadow
+ // (before the CTM). Bounds should be computed correctly in the presence of
+ // a (possibly negative) scale.
+ sk_sp<SkImageFilter> blur(make_blur(nullptr));
+ sk_sp<SkImageFilter> dropShadow(make_drop_shadow(nullptr));
+ {
+ // Uniform scale by 2.
+ SkMatrix scaleMatrix;
+ scaleMatrix.setScale(2, 2);
+ SkIRect bounds = SkIRect::MakeLTRB(0, 0, 200, 200);
+
+ SkIRect expectedBlurBounds = SkIRect::MakeLTRB(-6, -6, 206, 206);
+ SkIRect blurBounds = blur->filterBounds(
+ bounds, scaleMatrix, SkImageFilter::kForward_MapDirection);
+ REPORTER_ASSERT(reporter, blurBounds == expectedBlurBounds);
+ SkIRect reverseBlurBounds = blur->filterBounds(
+ bounds, scaleMatrix, SkImageFilter::kReverse_MapDirection);
+ REPORTER_ASSERT(reporter, reverseBlurBounds == expectedBlurBounds);
+
+ SkIRect expectedShadowBounds = SkIRect::MakeLTRB(0, 0, 460, 460);
+ SkIRect shadowBounds = dropShadow->filterBounds(
+ bounds, scaleMatrix, SkImageFilter::kForward_MapDirection);
+ REPORTER_ASSERT(reporter, shadowBounds == expectedShadowBounds);
+ SkIRect expectedReverseShadowBounds =
+ SkIRect::MakeLTRB(-260, -260, 200, 200);
+ SkIRect reverseShadowBounds = dropShadow->filterBounds(
+ bounds, scaleMatrix, SkImageFilter::kReverse_MapDirection);
+ REPORTER_ASSERT(reporter,
+ reverseShadowBounds == expectedReverseShadowBounds);
+ }
+ {
+ // Vertical flip.
+ SkMatrix scaleMatrix;
+ scaleMatrix.setScale(1, -1);
+ SkIRect bounds = SkIRect::MakeLTRB(0, -100, 100, 0);
+
+ SkIRect expectedBlurBounds = SkIRect::MakeLTRB(-3, -103, 103, 3);
+ SkIRect blurBounds = blur->filterBounds(
+ bounds, scaleMatrix, SkImageFilter::kForward_MapDirection);
+ REPORTER_ASSERT(reporter, blurBounds == expectedBlurBounds);
+ SkIRect reverseBlurBounds = blur->filterBounds(
+ bounds, scaleMatrix, SkImageFilter::kReverse_MapDirection);
+ REPORTER_ASSERT(reporter, reverseBlurBounds == expectedBlurBounds);
+
+ SkIRect expectedShadowBounds = SkIRect::MakeLTRB(0, -230, 230, 0);
+ SkIRect shadowBounds = dropShadow->filterBounds(
+ bounds, scaleMatrix, SkImageFilter::kForward_MapDirection);
+ REPORTER_ASSERT(reporter, shadowBounds == expectedShadowBounds);
+ SkIRect expectedReverseShadowBounds =
+ SkIRect::MakeLTRB(-130, -100, 100, 130);
+ SkIRect reverseShadowBounds = dropShadow->filterBounds(
+ bounds, scaleMatrix, SkImageFilter::kReverse_MapDirection);
+ REPORTER_ASSERT(reporter,
+ reverseShadowBounds == expectedReverseShadowBounds);
+ }
+}
+
DEF_TEST(ImageFilterComposedBlurFastBounds, reporter) {
sk_sp<SkImageFilter> filter1(make_blur(nullptr));
sk_sp<SkImageFilter> filter2(make_blur(nullptr));
« src/effects/SkDropShadowImageFilter.cpp ('K') | « src/effects/SkDropShadowImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698