OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkColorMatrixFilter_DEFINED | 8 #ifndef SkColorMatrixFilter_DEFINED |
9 #define SkColorMatrixFilter_DEFINED | 9 #define SkColorMatrixFilter_DEFINED |
10 | 10 |
11 #include "SkColorFilter.h" | 11 #include "SkColorFilter.h" |
12 #include "SkColorMatrix.h" | |
13 | 12 |
14 class SK_API SkColorMatrixFilter : public SkColorFilter { | 13 class SK_API SkColorMatrixFilterRowMajor255 : public SkColorFilter { |
15 public: | 14 public: |
16 static SkColorFilter* Create(const SkColorMatrix& cm) { | 15 explicit SkColorMatrixFilterRowMajor255(const SkScalar array[20]); |
17 return new SkColorMatrixFilter(cm); | |
18 } | |
19 static SkColorFilter* Create(const SkScalar array[20]) { | |
20 return new SkColorMatrixFilter(array); | |
21 } | |
22 | |
23 /** | |
24 * Create a colorfilter that multiplies the RGB channels by one color, and | |
25 * then adds a second color, pinning the result for each component to | |
26 * [0..255]. The alpha components of the mul and add arguments | |
27 * are ignored. | |
28 */ | |
29 static SkColorFilter* CreateLightingFilter(SkColor mul, SkColor add); | |
30 | 16 |
31 void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const overrid
e; | 17 void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const overrid
e; |
32 void filterSpan4f(const SkPM4f src[], int count, SkPM4f[]) const override; | 18 void filterSpan4f(const SkPM4f src[], int count, SkPM4f[]) const override; |
33 uint32_t getFlags() const override; | 19 uint32_t getFlags() const override; |
34 bool asColorMatrix(SkScalar matrix[20]) const override; | 20 bool asColorMatrix(SkScalar matrix[20]) const override; |
35 SkColorFilter* newComposed(const SkColorFilter*) const override; | 21 SkColorFilter* newComposed(const SkColorFilter*) const override; |
36 | 22 |
37 #if SK_SUPPORT_GPU | 23 #if SK_SUPPORT_GPU |
38 const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override; | 24 const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override; |
39 #endif | 25 #endif |
40 | 26 |
41 SK_TO_STRING_OVERRIDE() | 27 SK_TO_STRING_OVERRIDE() |
42 | 28 |
43 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter) | 29 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter) |
44 | 30 |
45 protected: | 31 protected: |
46 explicit SkColorMatrixFilter(const SkColorMatrix&); | |
47 explicit SkColorMatrixFilter(const SkScalar array[20]); | |
48 void flatten(SkWriteBuffer&) const override; | 32 void flatten(SkWriteBuffer&) const override; |
49 | 33 |
50 private: | 34 private: |
51 SkColorMatrix fMatrix; | 35 SkScalar fMatrix[20]; |
52 float fTranspose[SkColorMatrix::kCount]; // for Sk4s | 36 float fTranspose[20]; // for Sk4s |
53 uint32_t fFlags; | 37 uint32_t fFlags; |
54 | 38 |
55 void initState(const SkScalar array[20]); | 39 void initState(const SkScalar array[20]); |
56 | 40 |
57 typedef SkColorFilter INHERITED; | 41 typedef SkColorFilter INHERITED; |
58 }; | 42 }; |
59 | 43 |
60 #endif | 44 #endif |
OLD | NEW |