| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 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 SkTableMaskFilter_DEFINED | 8 #ifndef SkTableMaskFilter_DEFINED |
| 9 #define SkTableMaskFilter_DEFINED | 9 #define SkTableMaskFilter_DEFINED |
| 10 | 10 |
| 11 #include "SkMaskFilter.h" | 11 #include "SkMaskFilter.h" |
| 12 #include "SkScalar.h" | 12 #include "SkScalar.h" |
| 13 | 13 |
| 14 /** \class SkTableMaskFilter | 14 /** \class SkTableMaskFilter |
| 15 | 15 |
| 16 Applies a table lookup on each of the alpha values in the mask. | 16 Applies a table lookup on each of the alpha values in the mask. |
| 17 Helper methods create some common tables (e.g. gamma, clipping) | 17 Helper methods create some common tables (e.g. gamma, clipping) |
| 18 */ | 18 */ |
| 19 class SK_API SkTableMaskFilter : public SkMaskFilter { | 19 class SK_API SkTableMaskFilter : public SkMaskFilter { |
| 20 public: | 20 public: |
| 21 virtual ~SkTableMaskFilter(); |
| 22 |
| 21 /** Utility that sets the gamma table | 23 /** Utility that sets the gamma table |
| 22 */ | 24 */ |
| 23 static void MakeGammaTable(uint8_t table[256], SkScalar gamma); | 25 static void MakeGammaTable(uint8_t table[256], SkScalar gamma); |
| 24 | 26 |
| 25 /** Utility that creates a clipping table: clamps values below min to 0 | 27 /** Utility that creates a clipping table: clamps values below min to 0 |
| 26 and above max to 255, and rescales the remaining into 0..255 | 28 and above max to 255, and rescales the remaining into 0..255 |
| 27 */ | 29 */ |
| 28 static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max); | 30 static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max); |
| 29 | 31 |
| 30 static SkMaskFilter* Create(const uint8_t table[256]) { | 32 static SkTableMaskFilter* Create(const uint8_t table[256]) { |
| 31 return new SkTableMaskFilter(table); | 33 return new SkTableMaskFilter(table); |
| 32 } | 34 } |
| 33 | 35 |
| 34 static SkMaskFilter* CreateGamma(SkScalar gamma) { | 36 static SkTableMaskFilter* CreateGamma(SkScalar gamma) { |
| 35 uint8_t table[256]; | 37 uint8_t table[256]; |
| 36 MakeGammaTable(table, gamma); | 38 MakeGammaTable(table, gamma); |
| 37 return new SkTableMaskFilter(table); | 39 return new SkTableMaskFilter(table); |
| 38 } | 40 } |
| 39 | 41 |
| 40 static SkMaskFilter* CreateClip(uint8_t min, uint8_t max) { | 42 static SkTableMaskFilter* CreateClip(uint8_t min, uint8_t max) { |
| 41 uint8_t table[256]; | 43 uint8_t table[256]; |
| 42 MakeClipTable(table, min, max); | 44 MakeClipTable(table, min, max); |
| 43 return new SkTableMaskFilter(table); | 45 return new SkTableMaskFilter(table); |
| 44 } | 46 } |
| 45 | 47 |
| 46 SkMask::Format getFormat() const override; | 48 SkMask::Format getFormat() const override; |
| 47 bool filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*) const ov
erride; | 49 virtual bool filterMask(SkMask*, const SkMask&, const SkMatrix&, |
| 50 SkIPoint*) const override; |
| 48 | 51 |
| 49 SK_TO_STRING_OVERRIDE() | 52 SK_TO_STRING_OVERRIDE() |
| 50 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilter) | 53 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilter) |
| 51 | 54 |
| 52 protected: | 55 protected: |
| 53 virtual ~SkTableMaskFilter(); | 56 SkTableMaskFilter(); |
| 54 | 57 explicit SkTableMaskFilter(const uint8_t table[256]); |
| 55 void flatten(SkWriteBuffer&) const override; | 58 void flatten(SkWriteBuffer&) const override; |
| 56 | 59 |
| 57 private: | 60 private: |
| 58 SkTableMaskFilter(); | |
| 59 explicit SkTableMaskFilter(const uint8_t table[256]); | |
| 60 | |
| 61 uint8_t fTable[256]; | 61 uint8_t fTable[256]; |
| 62 | 62 |
| 63 typedef SkMaskFilter INHERITED; | 63 typedef SkMaskFilter INHERITED; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 #endif | 66 #endif |
| OLD | NEW |