jvanverth | cfc1886 | 2015-04-28 08:48:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | */ |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 7 | |
| 8 | #ifndef SkTableColorFilter_DEFINED |
| 9 | #define SkTableColorFilter_DEFINED |
| 10 | |
| 11 | #include "SkColorFilter.h" |
| 12 | |
vandebo@chromium.org | f724c4d | 2012-02-08 17:01:54 +0000 | [diff] [blame] | 13 | class SK_API SkTableColorFilter { |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 14 | public: |
| 15 | /** |
| 16 | * Create a table colorfilter, copying the table into the filter, and |
| 17 | * applying it to all 4 components. |
| 18 | * a' = table[a]; |
| 19 | * r' = table[r]; |
| 20 | * g' = table[g]; |
| 21 | * b' = table[b]; |
| 22 | * Compoents are operated on in unpremultiplied space. If the incomming |
| 23 | * colors are premultiplied, they are temporarily unpremultiplied, then |
| 24 | * the table is applied, and then the result is remultiplied. |
| 25 | */ |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 26 | static sk_sp<SkColorFilter> Make(const uint8_t table[256]); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 27 | |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 28 | /** |
| 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 |
| 31 | * treated as identity, with the component left unchanged. If a table |
| 32 | * is not null, then its contents are copied into the filter. |
| 33 | */ |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 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 | |
Cary Clark | 4dc5a45 | 2018-05-21 11:56:57 -0400 | [diff] [blame] | 39 | static void InitializeFlattenables(); |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | #endif |