OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkColorSpacePriv_DEFINED | 8 #ifndef SkColorSpacePriv_DEFINED |
9 #define SkColorSpacePriv_DEFINED | 9 #define SkColorSpacePriv_DEFINED |
10 | 10 |
11 struct SkGammaCurve { | 11 struct SkGammaCurve { |
12 bool isValue() const { | 12 bool isValue() const { |
13 bool result = (0.0f != fValue); | 13 bool result = (0.0f != fValue); |
14 SkASSERT(!result || (0 == fTableSize)); | 14 SkASSERT(!result || (0 == fTableSize)); |
15 SkASSERT(!result || (0.0f == fG)); | |
15 return result; | 16 return result; |
16 } | 17 } |
17 | 18 |
18 bool isTable() const { | 19 bool isTable() const { |
19 bool result = (0 != fTableSize); | 20 bool result = (0 != fTableSize); |
20 SkASSERT(!result || (0.0f == fValue)); | 21 SkASSERT(!result || (0.0f == fValue)); |
22 SkASSERT(!result || (0.0f == fG)); | |
21 SkASSERT(!result || fTable); | 23 SkASSERT(!result || fTable); |
22 return result; | 24 return result; |
23 } | 25 } |
24 | 26 |
25 bool isParametric() const { return false; } | 27 bool isParametric() const { |
28 bool result = (0.0f != fG); | |
29 SkASSERT(!result || (0.0f == fValue)); | |
30 SkASSERT(!result || (0 == fTableSize)); | |
31 return result; | |
32 } | |
26 | 33 |
27 // We have three different ways to represent gamma. | 34 // We have three different ways to represent gamma. |
28 // (1) A single value: | 35 // (1) A single value: |
29 float fValue; | 36 float fValue; |
30 | 37 |
31 // (2) A lookup table: | 38 // (2) A lookup table: |
32 uint32_t fTableSize; | 39 uint32_t fTableSize; |
33 std::unique_ptr<float[]> fTable; | 40 std::unique_ptr<float[]> fTable; |
34 | 41 |
35 // (3) Parameters for a curve: | 42 // (3) Parameters for a curve: |
36 // FIXME (msarett): Handle parametric curves. | 43 // Y = (aX + b)^g + c for X >= d |
44 // Y = eX + f otherwise | |
45 float fG; | |
scroggo
2016/05/18 12:49:15
Why does G come first?
msarett
2016/05/18 13:14:01
In my mind it makes sense because g is the "most i
| |
46 float fA; | |
47 float fB; | |
48 float fC; | |
49 float fD; | |
50 float fE; | |
51 float fF; | |
37 | 52 |
38 SkGammaCurve() { | 53 SkGammaCurve() { |
39 memset(this, 0, sizeof(struct SkGammaCurve)); | 54 memset(this, 0, sizeof(struct SkGammaCurve)); |
40 } | 55 } |
41 | 56 |
42 SkGammaCurve(float value) | 57 SkGammaCurve(float value) |
43 : fValue(value) | 58 : fValue(value) |
44 , fTableSize(0) | 59 , fTableSize(0) |
45 , fTable(nullptr) | 60 , fTable(nullptr) |
61 , fG(0.0f) | |
62 , fA(0.0f) | |
63 , fB(0.0f) | |
64 , fC(0.0f) | |
65 , fD(0.0f) | |
66 , fE(0.0f) | |
67 , fF(0.0f) | |
46 {} | 68 {} |
47 }; | 69 }; |
48 | 70 |
49 struct SkGammas : public SkRefCnt { | 71 struct SkGammas : public SkRefCnt { |
50 public: | 72 public: |
51 bool isValues() const { | 73 bool isValues() const { |
52 return fRed.isValue() && fGreen.isValue() && fBlue.isValue(); | 74 return fRed.isValue() && fGreen.isValue() && fBlue.isValue(); |
53 } | 75 } |
54 | 76 |
55 const SkGammaCurve fRed; | 77 const SkGammaCurve fRed; |
(...skipping 24 matching lines...) Expand all Loading... | |
80 uint8_t fOutputChannels; | 102 uint8_t fOutputChannels; |
81 uint8_t fGridPoints[kMaxChannels]; | 103 uint8_t fGridPoints[kMaxChannels]; |
82 std::unique_ptr<float[]> fTable; | 104 std::unique_ptr<float[]> fTable; |
83 | 105 |
84 SkColorLookUpTable() { | 106 SkColorLookUpTable() { |
85 memset(this, 0, sizeof(struct SkColorLookUpTable)); | 107 memset(this, 0, sizeof(struct SkColorLookUpTable)); |
86 } | 108 } |
87 }; | 109 }; |
88 | 110 |
89 #endif | 111 #endif |
OLD | NEW |