OLD | NEW |
| (Empty) |
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 SkColorSpacePriv_DEFINED | |
9 #define SkColorSpacePriv_DEFINED | |
10 | |
11 struct SkGammaCurve { | |
12 bool isValue() const { | |
13 bool result = (0.0f != fValue); | |
14 SkASSERT(!result || (0 == fTableSize)); | |
15 return result; | |
16 } | |
17 | |
18 bool isTable() const { | |
19 bool result = (0 != fTableSize); | |
20 SkASSERT(!result || (0.0f == fValue)); | |
21 SkASSERT(!result || fTable); | |
22 return result; | |
23 } | |
24 | |
25 bool isParametric() const { return false; } | |
26 | |
27 // We have three different ways to represent gamma. | |
28 // (1) A single value: | |
29 float fValue; | |
30 | |
31 // (2) A lookup table: | |
32 uint32_t fTableSize; | |
33 std::unique_ptr<float[]> fTable; | |
34 | |
35 // (3) Parameters for a curve: | |
36 // FIXME (msarett): Handle parametric curves. | |
37 | |
38 SkGammaCurve() { | |
39 memset(this, 0, sizeof(struct SkGammaCurve)); | |
40 } | |
41 | |
42 SkGammaCurve(float value) | |
43 : fValue(value) | |
44 , fTableSize(0) | |
45 , fTable(nullptr) | |
46 {} | |
47 }; | |
48 | |
49 struct SkGammas : public SkRefCnt { | |
50 public: | |
51 bool isValues() const { | |
52 return fRed.isValue() && fGreen.isValue() && fBlue.isValue(); | |
53 } | |
54 | |
55 const SkGammaCurve fRed; | |
56 const SkGammaCurve fGreen; | |
57 const SkGammaCurve fBlue; | |
58 | |
59 SkGammas(float red, float green, float blue) | |
60 : fRed(red) | |
61 , fGreen(green) | |
62 , fBlue(blue) | |
63 {} | |
64 | |
65 SkGammas(SkGammaCurve red, SkGammaCurve green, SkGammaCurve blue) | |
66 : fRed(std::move(red)) | |
67 , fGreen(std::move(green)) | |
68 , fBlue(std::move(blue)) | |
69 {} | |
70 | |
71 SkGammas() {} | |
72 | |
73 friend class SkColorSpace; | |
74 }; | |
75 | |
76 struct SkColorLookUpTable { | |
77 static const uint8_t kMaxChannels = 16; | |
78 | |
79 uint8_t fInputChannels; | |
80 uint8_t fOutputChannels; | |
81 uint8_t fGridPoints[kMaxChannels]; | |
82 std::unique_ptr<float[]> fTable; | |
83 | |
84 SkColorLookUpTable() { | |
85 memset(this, 0, sizeof(struct SkColorLookUpTable)); | |
86 } | |
87 }; | |
88 | |
89 #endif | |
OLD | NEW |