Debian Codegraph @

src/core/SkColorSpaceXformSteps.h

raw
1 /*
2 * Copyright 2018 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 */
7
8 #ifndef SkColorSpaceXformSteps_DEFINED
9 #define SkColorSpaceXformSteps_DEFINED
10
11 #include "modules/skcms/skcms.h"
12
13 #include <cstdint>
14
15 class SkColorSpace;
16 class SkRasterPipeline;
17 enum SkAlphaType : int;
18
19 struct SkColorSpaceXformSteps {
20
21 struct Flags {
22 bool unpremul = false;
23 bool linearize = false;
24 bool src_ootf = false;
25 bool gamut_transform = false;
26 bool dst_ootf = false;
27 bool encode = false;
28 bool premul = false;
29
30 constexpr uint32_t mask() const {
31 return (unpremul ? 1 : 0)
32 | (linearize ? 2 : 0)
33 | (src_ootf ? 32 : 0)
34 | (gamut_transform ? 4 : 0)
35 | (dst_ootf ? 64 : 0)
36 | (encode ? 8 : 0)
37 | (premul ? 16 : 0);
38 }
39 };
40
41 SkColorSpaceXformSteps() {}
42 SkColorSpaceXformSteps(const SkColorSpace* src, SkAlphaType srcAT,
43 const SkColorSpace* dst, SkAlphaType dstAT);
44
45 template <typename S, typename D>
46 SkColorSpaceXformSteps(const S& src, const D& dst)
47 : SkColorSpaceXformSteps(src.colorSpace(), src.alphaType(),
48 dst.colorSpace(), dst.alphaType()) {}
49
50 void apply(float rgba[4]) const;
51 void apply(SkRasterPipeline*) const;
52
53 Flags fFlags;
54
55 skcms_TransferFunction fSrcTF, // Apply for linearize.
56 fDstTFInv; // Apply for encode.
57 float fSrcToDstMatrix[9]; // Apply this 3x3 *column*-major matrix for gamut_transform.
58 float fSrcOotf[4]; // Apply ootf with these r,g,b coefficients and gamma before
59 // gamut_transform.
60 float fDstOotf[4]; // Apply ootf with these r,g,b coefficients and gamma after
61 // gamut_transform.
62 };
63
64 #endif//SkColorSpaceXformSteps_DEFINED