aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/effects/SkTableColorFilter.h
blob: 3989b5ac2d994016abb6d96c7a3eaf25137e542a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#ifndef SkTableColorFilter_DEFINED
#define SkTableColorFilter_DEFINED

#include "SkColorFilter.h"

class SK_API SkTableColorFilter {
public:
    /**
     *  Create a table colorfilter, copying the table into the filter, and
     *  applying it to all 4 components.
     *      a' = table[a];
     *      r' = table[r];
     *      g' = table[g];
     *      b' = table[b];
     *  Compoents are operated on in unpremultiplied space. If the incomming
     *  colors are premultiplied, they are temporarily unpremultiplied, then
     *  the table is applied, and then the result is remultiplied.
     */
    static sk_sp<SkColorFilter> Make(const uint8_t table[256]);

    /**
     *  Create a table colorfilter, with a different table for each
     *  component [A, R, G, B]. If a given table is NULL, then it is
     *  treated as identity, with the component left unchanged. If a table
     *  is not null, then its contents are copied into the filter.
     */
    static sk_sp<SkColorFilter> MakeARGB(const uint8_t tableA[256],
                                         const uint8_t tableR[256],
                                         const uint8_t tableG[256],
                                         const uint8_t tableB[256]);

    static void InitializeFlattenables();
};

#endif