aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkColorSpaceXform_A2B.h
blob: 9376491fa186335157e0eda05a05d22465315862 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkColorSpaceXform_A2B_DEFINED
#define SkColorSpaceXform_A2B_DEFINED

#include "SkColorSpace_Base.h"
#include "SkColorSpaceXform_Base.h"
#include "SkRasterPipeline.h"

#include <forward_list>
#include <functional>
#include <vector>

class SkColorSpace_A2B;
class SkColorSpace_XYZ;

struct SkTableTransferFn {
    const float* fData;
    int          fSize;
};

class SkColorSpaceXform_A2B : public SkColorSpaceXform_Base {
public:
    bool onApply(ColorFormat dstFormat, void* dst, ColorFormat srcFormat, const void* src,
                 int count, SkAlphaType alphaType) const override;

private:
    SkColorSpaceXform_A2B(SkColorSpace_A2B* srcSpace, SkColorSpace_XYZ* dstSpace);

    void addTransferFns(const SkColorSpaceTransferFn& fn, int channelCount);

    void addTransferFn(const SkColorSpaceTransferFn& fn, int channelIndex);

    void addTableFn(const SkTableTransferFn& table, int channelIndex);

    void addMatrix(const SkMatrix44& matrix);

    SkRasterPipeline                             fElementsPipeline;
    bool                                         fLinearDstGamma;

    // storage used by the pipeline
    std::forward_list<SkColorSpaceTransferFn>    fTransferFns;
    std::forward_list<SkTableTransferFn>         fTableTransferFns;
    std::forward_list<std::vector<float>>        fMatrices;
    std::vector<sk_sp<const SkColorLookUpTable>> fCLUTs;

    // these are here to maintain ownership of tables used in the pipeline
    std::forward_list<std::vector<float>>        fTableStorage;
    std::vector<sk_sp<const SkGammas>>           fGammaRefs;

    friend class SkColorSpaceXform;
};

#endif