• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 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 SkColorSpaceXform_A2B_DEFINED
9 #define SkColorSpaceXform_A2B_DEFINED
10 
11 #include "SkArenaAlloc.h"
12 #include "SkColorSpaceXform_Base.h"
13 #include "SkColorSpace_Base.h"
14 #include "SkRasterPipeline.h"
15 
16 class SkColorSpace_A2B;
17 class SkColorSpace_XYZ;
18 
19 struct SkTableTransferFn {
20     const float* fData;
21     int          fSize;
22 };
23 
24 class SkColorSpaceXform_A2B : public SkColorSpaceXform_Base {
25 public:
26     bool onApply(ColorFormat dstFormat, void* dst, ColorFormat srcFormat, const void* src,
27                  int count, SkAlphaType alphaType) const override;
28 
29 private:
30     SkColorSpaceXform_A2B(SkColorSpace_A2B* srcSpace, SkColorSpace_XYZ* dstSpace);
31 
32     void addTransferFns(const SkColorSpaceTransferFn& fn, int channelCount);
33 
34     void addTransferFn(const SkColorSpaceTransferFn& fn, int channelIndex);
35 
36     bool buildTableFn(SkTableTransferFn* table);
37     void addTableFn(const SkTableTransferFn& table, int channelIndex);
38 
39     void addMatrix(const SkMatrix44& matrix);
40 
41     SkRasterPipeline fElementsPipeline;
42     bool             fLinearDstGamma;
43     SkArenaAlloc     fAlloc{128};  // TODO: tune?
44 
45     template <typename T>
copy(const T & val)46     T* copy(const T& val) { return fAlloc.make<T>(val); }
47 
48     friend class SkColorSpaceXform_Base;
49 };
50 
51 #endif
52