| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
| 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" | 12 #include "SkColorMatrix.h" |
| 13 | 13 |
| 14 class SK_API SkColorMatrixFilter : public SkColorFilter { | 14 class SK_API SkColorMatrixFilter : public SkColorFilter { |
| 15 public: | 15 public: |
| 16 static SkColorFilter* Create(const SkColorMatrix& cm) { | 16 static SkColorFilter* Create(const SkColorMatrix& cm) { |
| 17 return new SkColorMatrixFilter(cm); | 17 return new SkColorMatrixFilter(cm); |
| 18 } | 18 } |
| 19 static SkColorFilter* Create(const SkScalar array[20]) { | 19 static SkColorFilter* Create(const SkScalar array[20]) { |
| 20 return new SkColorMatrixFilter(array); | 20 return new SkColorMatrixFilter(array); |
| 21 } | 21 } |
| 22 | 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 |
| 23 void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const overrid
e; | 31 void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const overrid
e; |
| 24 uint32_t getFlags() const override; | 32 uint32_t getFlags() const override; |
| 25 bool asColorMatrix(SkScalar matrix[20]) const override; | 33 bool asColorMatrix(SkScalar matrix[20]) const override; |
| 26 SkColorFilter* newComposed(const SkColorFilter*) const override; | 34 SkColorFilter* newComposed(const SkColorFilter*) const override; |
| 27 | 35 |
| 28 #if SK_SUPPORT_GPU | 36 #if SK_SUPPORT_GPU |
| 29 const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override; | 37 const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override; |
| 30 #endif | 38 #endif |
| 31 | 39 |
| 32 SK_TO_STRING_OVERRIDE() | 40 SK_TO_STRING_OVERRIDE() |
| 33 | 41 |
| 34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter) | 42 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter) |
| 35 | 43 |
| 36 protected: | 44 protected: |
| 37 explicit SkColorMatrixFilter(const SkColorMatrix&); | 45 explicit SkColorMatrixFilter(const SkColorMatrix&); |
| 38 explicit SkColorMatrixFilter(const SkScalar array[20]); | 46 explicit SkColorMatrixFilter(const SkScalar array[20]); |
| 39 void flatten(SkWriteBuffer&) const override; | 47 void flatten(SkWriteBuffer&) const override; |
| 40 | 48 |
| 41 private: | 49 private: |
| 42 SkColorMatrix fMatrix; | 50 SkColorMatrix fMatrix; |
| 43 float fTranspose[SkColorMatrix::kCount]; // for Sk4s | 51 float fTranspose[SkColorMatrix::kCount]; // for Sk4s |
| 44 uint32_t fFlags; | 52 uint32_t fFlags; |
| 45 | 53 |
| 46 void initState(const SkScalar array[20]); | 54 void initState(const SkScalar array[20]); |
| 47 | 55 |
| 48 typedef SkColorFilter INHERITED; | 56 typedef SkColorFilter INHERITED; |
| 49 }; | 57 }; |
| 50 | 58 |
| 51 #endif | 59 #endif |
| OLD | NEW |