| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 SkTableColorFilter_DEFINED | 8 #ifndef SkTableColorFilter_DEFINED |
| 9 #define SkTableColorFilter_DEFINED | 9 #define SkTableColorFilter_DEFINED |
| 10 | 10 |
| 11 #include "SkColorFilter.h" | 11 #include "SkColorFilter.h" |
| 12 | 12 |
| 13 class SK_API SkTableColorFilter { | 13 class SK_API SkTableColorFilter { |
| 14 public: | 14 public: |
| 15 /** | 15 /** |
| 16 * Create a table colorfilter, copying the table into the filter, and | 16 * Create a table colorfilter, copying the table into the filter, and |
| 17 * applying it to all 4 components. | 17 * applying it to all 4 components. |
| 18 * a' = table[a]; | 18 * a' = table[a]; |
| 19 * r' = table[r]; | 19 * r' = table[r]; |
| 20 * g' = table[g]; | 20 * g' = table[g]; |
| 21 * b' = table[b]; | 21 * b' = table[b]; |
| 22 * Compoents are operated on in unpremultiplied space. If the incomming | 22 * Compoents are operated on in unpremultiplied space. If the incomming |
| 23 * colors are premultiplied, they are temporarily unpremultiplied, then | 23 * colors are premultiplied, they are temporarily unpremultiplied, then |
| 24 * the table is applied, and then the result is remultiplied. | 24 * the table is applied, and then the result is remultiplied. |
| 25 */ | 25 */ |
| 26 static SkColorFilter* Create(const uint8_t table[256]); | 26 static sk_sp<SkColorFilter> Make(const uint8_t table[256]); |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Create a table colorfilter, with a different table for each | 29 * Create a table colorfilter, with a different table for each |
| 30 * component [A, R, G, B]. If a given table is NULL, then it is | 30 * component [A, R, G, B]. If a given table is NULL, then it is |
| 31 * treated as identity, with the component left unchanged. If a table | 31 * treated as identity, with the component left unchanged. If a table |
| 32 * is not null, then its contents are copied into the filter. | 32 * is not null, then its contents are copied into the filter. |
| 33 */ | 33 */ |
| 34 static sk_sp<SkColorFilter> MakeARGB(const uint8_t tableA[256], |
| 35 const uint8_t tableR[256], |
| 36 const uint8_t tableG[256], |
| 37 const uint8_t tableB[256]); |
| 38 |
| 39 #ifdef SK_SUPPORT_LEGACY_COLORFILTER_PTR |
| 40 static SkColorFilter* Create(const uint8_t table[256]) { |
| 41 return Make(table).release(); |
| 42 } |
| 34 static SkColorFilter* CreateARGB(const uint8_t tableA[256], | 43 static SkColorFilter* CreateARGB(const uint8_t tableA[256], |
| 35 const uint8_t tableR[256], | 44 const uint8_t tableR[256], |
| 36 const uint8_t tableG[256], | 45 const uint8_t tableG[256], |
| 37 const uint8_t tableB[256]); | 46 const uint8_t tableB[256]) { |
| 38 | 47 return MakeARGB(tableA, tableR, tableG, tableB).release(); |
| 48 } |
| 49 #endif |
| 50 |
| 39 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 51 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
| 40 }; | 52 }; |
| 41 | 53 |
| 42 #endif | 54 #endif |
| OLD | NEW |