Index: tests/ImageFilterTest.cpp |
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp |
index 2798ea0b18442055a050b9385eacdea5a027ff37..3bc87860a02f982d8f24b378700402192fa196d1 100644 |
--- a/tests/ImageFilterTest.cpp |
+++ b/tests/ImageFilterTest.cpp |
@@ -133,7 +133,7 @@ static SkImageFilter* make_scale(float amount, SkImageFilter* input = NULL) { |
return SkColorFilterImageFilter::Create(filter, input); |
} |
-static SkImageFilter* make_grayscale(SkImageFilter* input = NULL, const SkImageFilter::CropRect* cropRect = NULL) { |
+static SkImageFilter* make_grayscale(SkImageFilter* input, const SkImageFilter::CropRect* cropRect) { |
SkScalar matrix[20]; |
memset(matrix, 0, 20 * sizeof(SkScalar)); |
matrix[0] = matrix[5] = matrix[10] = 0.2126f; |
@@ -144,6 +144,11 @@ static SkImageFilter* make_grayscale(SkImageFilter* input = NULL, const SkImageF |
return SkColorFilterImageFilter::Create(filter, input, cropRect); |
} |
+static SkImageFilter* make_blue(SkImageFilter* input, const SkImageFilter::CropRect* cropRect) { |
robertphillips
2015/03/04 20:14:40
overlength ?
reed1
2015/03/04 20:33:33
Done.
|
+ SkAutoTUnref<SkColorFilter> filter(SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mode)); |
+ return SkColorFilterImageFilter::Create(filter, input, cropRect); |
+} |
+ |
DEF_TEST(ImageFilter, reporter) { |
{ |
// Check that two non-clipping color matrices concatenate into a single filter. |
@@ -153,19 +158,29 @@ DEF_TEST(ImageFilter, reporter) { |
} |
{ |
robertphillips
2015/03/04 20:14:40
// Check that a color matrix followed by another c
Stephen White
2015/03/04 20:26:17
I wonder if we should modify the matrix test to ch
reed1
2015/03/04 20:33:33
Done.
|
- // Check that a clipping color matrix followed by a grayscale does not concatenate into a single filter. |
+ // Check that a clipping color matrix followed by a grayscale does concatenate |
Stephen White
2015/03/04 20:26:16
... and maybe we should check that this one *is* a
reed1
2015/03/04 20:33:33
Done.
|
+ // into a single filter. |
SkAutoTUnref<SkImageFilter> doubleBrightness(make_scale(2.0f)); |
SkAutoTUnref<SkImageFilter> halfBrightness(make_scale(0.5f, doubleBrightness)); |
- REPORTER_ASSERT(reporter, halfBrightness->getInput(0)); |
+ REPORTER_ASSERT(reporter, NULL == halfBrightness->getInput(0)); |
} |
{ |
// Check that a color filter image filter without a crop rect can be |
// expressed as a color filter. |
- SkAutoTUnref<SkImageFilter> gray(make_grayscale()); |
+ SkAutoTUnref<SkImageFilter> gray(make_grayscale(NULL, NULL)); |
REPORTER_ASSERT(reporter, true == gray->asColorFilter(NULL)); |
} |
- |
+ |
+ { |
+ // Check that a colorfilterimage filter without a crop rect but with an input |
+ // that is another colorfilterimage can be expressed as a colorfilter (composed). |
+ // |
+ SkAutoTUnref<SkImageFilter> mode(make_blue(NULL, NULL)); |
+ SkAutoTUnref<SkImageFilter> gray(make_grayscale(mode, NULL)); |
+ REPORTER_ASSERT(reporter, true == gray->asColorFilter(NULL)); |
+ } |
+ |
{ |
// Check that a color filter image filter with a crop rect cannot |
// be expressed as a color filter. |