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 { | |
scroggo
2016/05/17 16:54:27
Why is gamma ref counted? I guess it's because of
msarett
2016/05/17 17:27:13
A couple reasons:
(1) As you say, it's nice to not
| |
50 public: | |
51 bool isValues() const { | |
52 return fRed.isValue() && fGreen.isValue() && fBlue.isValue(); | |
53 } | |
54 | |
55 SkGammaCurve fRed; | |
56 SkGammaCurve fGreen; | |
57 SkGammaCurve fBlue; | |
58 | |
59 SkGammas(float red, float green, float blue) | |
60 : fRed(red) | |
61 , fGreen(green) | |
62 , fBlue(blue) | |
63 {} | |
64 | |
65 SkGammas() {} | |
66 | |
67 friend class SkColorSpace; | |
68 }; | |
69 | |
70 struct SkColorLookUpTable { | |
71 static const uint8_t kMaxChannels = 16; | |
72 | |
73 uint8_t fInputChannels; | |
74 uint8_t fOutputChannels; | |
75 uint8_t fGridPoints[kMaxChannels]; | |
76 std::unique_ptr<float[]> fTable; | |
77 | |
78 SkColorLookUpTable() { | |
79 memset(this, 0, sizeof(struct SkColorLookUpTable)); | |
80 } | |
81 }; | |
82 | |
83 #endif | |
OLD | NEW |