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

Unified Diff: tests/ImageFilterTest.cpp

Issue 481273005: Fix recursive computation of filter bounds for drop shadow, (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use an identity matrix for the test, not an uninit one :( Created 6 years, 4 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
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageFilterTest.cpp
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index f87f99ce98cc4e6dbe9d69daa8b6df1cd3f5c57f..778cc3f4343307ffe0de85d437bcb5a7416052f4 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -469,6 +469,50 @@ DEF_TEST(ImageFilterDrawMatrixBBH, reporter) {
}
}
+static SkImageFilter* makeBlur(SkImageFilter* input = NULL) {
+ return SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1, input);
+}
+
+static SkImageFilter* makeDropShadow(SkImageFilter* input = NULL) {
+ return SkDropShadowImageFilter::Create(
+ SkIntToScalar(100), SkIntToScalar(100),
+ SkIntToScalar(10), SkIntToScalar(10),
+ SK_ColorBLUE, input);
+}
+
+DEF_TEST(ImageFilterBlurThenShadowBounds, reporter) {
+ SkAutoTUnref<SkImageFilter> filter1(makeBlur());
+ SkAutoTUnref<SkImageFilter> filter2(makeDropShadow(filter1.get()));
+
+ SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100);
+ SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236);
+ filter2->filterBounds(bounds, SkMatrix::I(), &bounds);
+
+ REPORTER_ASSERT(reporter, bounds == expectedBounds);
+}
+
+DEF_TEST(ImageFilterShadowThenBlurBounds, reporter) {
+ SkAutoTUnref<SkImageFilter> filter1(makeDropShadow());
+ SkAutoTUnref<SkImageFilter> filter2(makeBlur(filter1.get()));
+
+ SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100);
+ SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236);
+ filter2->filterBounds(bounds, SkMatrix::I(), &bounds);
+
+ REPORTER_ASSERT(reporter, bounds == expectedBounds);
+}
+
+DEF_TEST(ImageFilterDilateThenBlurBounds, reporter) {
+ SkAutoTUnref<SkImageFilter> filter1(SkDilateImageFilter::Create(2, 2));
+ SkAutoTUnref<SkImageFilter> filter2(makeDropShadow(filter1.get()));
+
+ SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100);
+ SkIRect expectedBounds = SkIRect::MakeXYWH(-132, -132, 234, 234);
+ filter2->filterBounds(bounds, SkMatrix::I(), &bounds);
+
+ REPORTER_ASSERT(reporter, bounds == expectedBounds);
+}
+
static void drawBlurredRect(SkCanvas* canvas) {
SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(SkIntToScalar(8), 0));
SkPaint filterPaint;
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698