commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 1 | /* |
| 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.org | d494b09 | 2013-10-10 20:13:51 +0000 | [diff] [blame] | 18 | * The resulting color is black with transparency equal to the |
| 19 | * luminance value modulated by alpha: |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 20 | * |
commit-bot@chromium.org | d494b09 | 2013-10-10 20:13:51 +0000 | [diff] [blame] | 21 | * C' = [ Lum * a, 0, 0, 0 ] |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 22 | * |
| 23 | */ |
| 24 | class SK_API SkLumaColorFilter : public SkColorFilter { |
| 25 | public: |
| 26 | static SkColorFilter* Create(); |
| 27 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 28 | void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override; |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 29 | |
| 30 | #if SK_SUPPORT_GPU |
bsalomon | 4a33952 | 2015-10-06 08:40:50 -0700 | [diff] [blame] | 31 | const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override; |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 32 | #endif |
| 33 | |
commit-bot@chromium.org | 0f10f7b | 2014-03-13 18:02:17 +0000 | [diff] [blame] | 34 | SK_TO_STRING_OVERRIDE() |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 35 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter) |
| 36 | |
| 37 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 38 | void flatten(SkWriteBuffer&) const override; |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 39 | |
| 40 | private: |
| 41 | SkLumaColorFilter(); |
| 42 | |
| 43 | typedef SkColorFilter INHERITED; |
| 44 | }; |
| 45 | |
| 46 | #endif |