aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ColorFilterTest.cpp
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-06-29 11:37:15 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-29 16:09:37 +0000
commit9c1d7802284bf5a0e6fcf1a43e9218e21ce1a9e0 (patch)
treef8586d95657fb9a77717ba9c65fb647112fb30e8 /tests/ColorFilterTest.cpp
parent185a3798db64c64d47ef89a5fd3d4c5c70f1e621 (diff)
remove filterSpan from SkColorFilter
Bug: skia: Change-Id: Ie8a31ea8131c08d251a825622484342e3e174474 Reviewed-on: https://skia-review.googlesource.com/21207 Commit-Queue: Mike Reed <reed@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'tests/ColorFilterTest.cpp')
-rw-r--r--tests/ColorFilterTest.cpp121
1 files changed, 0 insertions, 121 deletions
diff --git a/tests/ColorFilterTest.cpp b/tests/ColorFilterTest.cpp
index b6456a6414..c502a70a4f 100644
--- a/tests/ColorFilterTest.cpp
+++ b/tests/ColorFilterTest.cpp
@@ -110,124 +110,3 @@ DEF_TEST(ColorFilter, reporter) {
test_composecolorfilter_limit(reporter);
}
-
-///////////////////////////////////////////////////////////////////////////////
-
-DEF_TEST(LumaColorFilter, reporter) {
- SkPMColor in, out;
- auto lf(SkLumaColorFilter::Make());
-
- // 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, 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)
- for (unsigned i = 0; i < 256; ++i) {
- in = SkPackARGB32(i, 0, 0, 0);
- lf->filterSpan(&in, 1, &out);
- REPORTER_ASSERT(reporter, out == SK_ColorTRANSPARENT);
- }
-
- // 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) == 0);
- REPORTER_ASSERT(reporter, SkGetPackedG32(out) == 0);
- REPORTER_ASSERT(reporter, SkGetPackedB32(out) == 0);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-#include "SkColorMatrixFilter.h"
-
-static void get_brightness_matrix(float amount, float matrix[20]) {
- // Spec implementation
- // (http://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#brightnessEquivalent)
- // <feFunc[R|G|B] type="linear" slope="[amount]">
- memset(matrix, 0, 20 * sizeof(SkScalar));
- matrix[0] = matrix[6] = matrix[12] = amount;
- matrix[18] = 1.f;
-}
-
-static void get_grayscale_matrix(float amount, float matrix[20]) {
- // Note, these values are computed to ensure MatrixNeedsClamping is false
- // for amount in [0..1]
- matrix[0] = 0.2126f + 0.7874f * amount;
- matrix[1] = 0.7152f - 0.7152f * amount;
- matrix[2] = 1.f - (matrix[0] + matrix[1]);
- matrix[3] = matrix[4] = 0.f;
-
- matrix[5] = 0.2126f - 0.2126f * amount;
- matrix[6] = 0.7152f + 0.2848f * amount;
- matrix[7] = 1.f - (matrix[5] + matrix[6]);
- matrix[8] = matrix[9] = 0.f;
-
- matrix[10] = 0.2126f - 0.2126f * amount;
- matrix[11] = 0.7152f - 0.7152f * amount;
- matrix[12] = 1.f - (matrix[10] + matrix[11]);
- matrix[13] = matrix[14] = 0.f;
-
- matrix[15] = matrix[16] = matrix[17] = matrix[19] = 0.f;
- matrix[18] = 1.f;
-}
-
-static sk_sp<SkColorFilter> make_cf0() {
- SkScalar matrix[20];
- get_brightness_matrix(0.5f, matrix);
- return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
-}
-static sk_sp<SkColorFilter> make_cf1() {
- SkScalar matrix[20];
- get_grayscale_matrix(1, matrix);
- return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
-}
-static sk_sp<SkColorFilter> make_cf2() {
- SkColorMatrix m0, m1;
- get_brightness_matrix(0.5f, m0.fMat);
- get_grayscale_matrix(1, m1.fMat);
- m0.preConcat(m1);
- return SkColorFilter::MakeMatrixFilterRowMajor255(m0.fMat);
-}
-static sk_sp<SkColorFilter> make_cf3() {
- SkColorMatrix m0, m1;
- get_brightness_matrix(0.5f, m0.fMat);
- get_grayscale_matrix(1, m1.fMat);
- m0.postConcat(m1);
- return SkColorFilter::MakeMatrixFilterRowMajor255(m0.fMat);
-}
-typedef sk_sp<SkColorFilter> (*CFProc)();
-
-// Test that a colormatrix that "should" preserve opaquness actually does.
-DEF_TEST(ColorMatrixFilter, reporter) {
- const CFProc procs[] = {
- make_cf0, make_cf1, make_cf2, make_cf3,
- };
-
- for (size_t i = 0; i < SK_ARRAY_COUNT(procs); ++i) {
- auto cf(procs[i]());
-
- // generate all possible r,g,b triples
- for (int r = 0; r < 256; ++r) {
- for (int g = 0; g < 256; ++g) {
- SkPMColor storage[256];
- for (int b = 0; b < 256; ++b) {
- storage[b] = SkPackARGB32(0xFF, r, g, b);
- }
- cf->filterSpan(storage, 256, storage);
- for (int b = 0; b < 256; ++b) {
- REPORTER_ASSERT(reporter, 0xFF == SkGetPackedA32(storage[b]));
- }
- }
- }
- }
-}