blob: 8dd519af4a77fe5ea142e9d8a15c4bfbc4c4a2e5 [file] [log] [blame]
commit-bot@chromium.org6c1ee2d2013-10-07 18:00:17 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkLumaColorFilter_DEFINED
9#define SkLumaColorFilter_DEFINED
10
11#include "SkColorFilter.h"
12
13/**
14 * Luminance-to-alpha color filter, as defined in
15 * http://www.w3.org/TR/SVG/masking.html#Masking
16 * http://www.w3.org/TR/css-masking/#MaskValues
17 *
commit-bot@chromium.orgd494b092013-10-10 20:13:51 +000018 * The resulting color is black with transparency equal to the
19 * luminance value modulated by alpha:
commit-bot@chromium.org6c1ee2d2013-10-07 18:00:17 +000020 *
commit-bot@chromium.orgd494b092013-10-10 20:13:51 +000021 * C' = [ Lum * a, 0, 0, 0 ]
commit-bot@chromium.org6c1ee2d2013-10-07 18:00:17 +000022 *
23 */
24class SK_API SkLumaColorFilter : public SkColorFilter {
25public:
26 static SkColorFilter* Create();
27
mtklein36352bf2015-03-25 18:17:31 -070028 void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override;
commit-bot@chromium.org6c1ee2d2013-10-07 18:00:17 +000029
30#if SK_SUPPORT_GPU
bsalomon4a339522015-10-06 08:40:50 -070031 const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
commit-bot@chromium.org6c1ee2d2013-10-07 18:00:17 +000032#endif
33
commit-bot@chromium.org0f10f7b2014-03-13 18:02:17 +000034 SK_TO_STRING_OVERRIDE()
commit-bot@chromium.org6c1ee2d2013-10-07 18:00:17 +000035 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter)
36
37protected:
mtklein36352bf2015-03-25 18:17:31 -070038 void flatten(SkWriteBuffer&) const override;
commit-bot@chromium.org6c1ee2d2013-10-07 18:00:17 +000039
40private:
41 SkLumaColorFilter();
42
43 typedef SkColorFilter INHERITED;
44};
45
46#endif