aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ColorFilterTest.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-10 20:13:51 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-10 20:13:51 +0000
commitd494b09f554d470fc6411d0924879bbfb0cb0e95 (patch)
tree94265bef62c686309148e8cf10eaab31fa4a0faa /tests/ColorFilterTest.cpp
parenta7538baeae619a513437f89b60cf738ee2de463d (diff)
Align SkLumaColorFilter with the spec.
The spec requires the resulting RGB channels for LuminanceToAlpha to be 0 (and not just scaled by the luminance value</facepalm>): | R' | | 0 0 0 0 0 | | R | | G' | | 0 0 0 0 0 | | G | | B' | = | 0 0 0 0 0 | * | B | | A' | | 0.2125 0.7154 0.0721 0 0 | | A | | 1 | | 0 0 0 0 1 | | 1 | (http://www.w3.org/TR/2011/REC-SVG11-20110816/filters.html#feColorMatrixElement) This doesn't affect luminance masking (which depends only on the resulting alpha channel), but other color filter users may care about all color components. R=bsalomon@google.com, reed@google.com, robertphillips@google.com Author: fmalita@chromium.org Review URL: https://codereview.chromium.org/26467003 git-svn-id: http://skia.googlecode.com/svn/trunk@11713 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/ColorFilterTest.cpp')
-rw-r--r--tests/ColorFilterTest.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/ColorFilterTest.cpp b/tests/ColorFilterTest.cpp
index b333ad68f0..8c96d752fb 100644
--- a/tests/ColorFilterTest.cpp
+++ b/tests/ColorFilterTest.cpp
@@ -101,11 +101,14 @@ static void test_lumaColorFilter(skiatest::Reporter* reporter) {
SkPMColor in, out;
SkAutoTUnref<SkColorFilter> lf(SkLumaColorFilter::Create());
- // Applying luma to white is a nop (luminance(white) == 1.0)
+ // Applying luma to white produces black with the same transparency.
for (unsigned i = 0; i < 256; ++i) {
in = SkPackARGB32(i, i, i, i);
lf->filterSpan(&in, 1, &out);
- REPORTER_ASSERT(reporter, out == in);
+ REPORTER_ASSERT(reporter, SkGetPackedA32(out) == i);
+ REPORTER_ASSERT(reporter, SkGetPackedR32(out) == 0);
+ REPORTER_ASSERT(reporter, SkGetPackedG32(out) == 0);
+ REPORTER_ASSERT(reporter, SkGetPackedB32(out) == 0);
}
// Applying luma to black yields transparent black (luminance(black) == 0)
@@ -115,15 +118,15 @@ static void test_lumaColorFilter(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, out == SK_ColorTRANSPARENT);
}
- // For general colors, a luma filter has an attenuating effect.
+ // For general colors, a luma filter generates black with an attenuated alpha channel.
for (unsigned i = 1; i < 256; ++i) {
in = SkPackARGB32(i, i, i / 2, i / 3);
lf->filterSpan(&in, 1, &out);
REPORTER_ASSERT(reporter, out != in);
REPORTER_ASSERT(reporter, SkGetPackedA32(out) <= i);
- REPORTER_ASSERT(reporter, SkGetPackedR32(out) <= i);
- REPORTER_ASSERT(reporter, SkGetPackedG32(out) <= i / 2);
- REPORTER_ASSERT(reporter, SkGetPackedB32(out) <= i / 3);
+ REPORTER_ASSERT(reporter, SkGetPackedR32(out) == 0);
+ REPORTER_ASSERT(reporter, SkGetPackedG32(out) == 0);
+ REPORTER_ASSERT(reporter, SkGetPackedB32(out) == 0);
}
}