• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "include/core/SkColorSpace.h"
12 #include "include/core/SkImageInfo.h"
13 #include "include/private/SkImageInfoPriv.h"
14 #include "src/core/SkVM_fwd.h"
15 
16 class SkRasterPipeline;
17 
18 struct SkColorSpaceXformSteps {
19 
20     struct Flags {
21         bool unpremul         = false;
22         bool linearize        = false;
23         bool gamut_transform  = false;
24         bool encode           = false;
25         bool premul           = false;
26 
maskSkColorSpaceXformSteps::Flags27         uint32_t mask() const {
28             return (unpremul        ?  1 : 0)
29                  | (linearize       ?  2 : 0)
30                  | (gamut_transform ?  4 : 0)
31                  | (encode          ?  8 : 0)
32                  | (premul          ? 16 : 0);
33         }
34     };
35 
36     SkColorSpaceXformSteps(const SkColorSpace* src, SkAlphaType srcAT,
37                            const SkColorSpace* dst, SkAlphaType dstAT);
38 
39     template <typename S, typename D>
SkColorSpaceXformStepsSkColorSpaceXformSteps40     SkColorSpaceXformSteps(const S& src, const D& dst)
41         : SkColorSpaceXformSteps(src.colorSpace(), src.alphaType(),
42                                  dst.colorSpace(), dst.alphaType()) {}
43 
44     void apply(float rgba[4]) const;
45     void apply(SkRasterPipeline*) const;
46     skvm::Color program(skvm::Builder*, skvm::Uniforms*, skvm::Color) const;
47 
48     Flags flags;
49 
50     skcms_TransferFunction srcTF,     // Apply for linearize.
51                            dstTFInv;  // Apply for encode.
52     float src_to_dst_matrix[9];       // Apply this 3x3 column-major matrix for gamut_transform.
53 };
54 
55 #endif//SkColorSpaceXformSteps_DEFINED
56