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 SkColorSpace_DEFINED | 8 #ifndef SkColorSpace_DEFINED |
9 #define SkColorSpace_DEFINED | 9 #define SkColorSpace_DEFINED |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 float fBX, fBY; | 22 float fBX, fBY; |
23 float fWX, fWY; | 23 float fWX, fWY; |
24 | 24 |
25 /** | 25 /** |
26 * Convert primaries and a white point to a toXYZD50 matrix, the preferred
color gamut | 26 * Convert primaries and a white point to a toXYZD50 matrix, the preferred
color gamut |
27 * representation of SkColorSpace. | 27 * representation of SkColorSpace. |
28 */ | 28 */ |
29 bool toXYZD50(SkMatrix44* toXYZD50) const; | 29 bool toXYZD50(SkMatrix44* toXYZD50) const; |
30 }; | 30 }; |
31 | 31 |
| 32 /** |
| 33 * Contains the coefficients for a common transfer function equation, specified
as |
| 34 * a transformation from a curved space to linear. |
| 35 * |
| 36 * LinearVal = E*InputVal + F , for 0.0f <= InputVal < D |
| 37 * LinearVal = (A*InputVal + B)^G + C, for D <= InputVal <= 1.0f |
| 38 * |
| 39 * Function is undefined if InputVal is not in [ 0.0f, 1.0f ]. |
| 40 * Resulting LinearVals must be in [ 0.0f, 1.0f ]. |
| 41 * Function must be positive and increasing. |
| 42 */ |
| 43 struct SK_API SkColorSpaceTransferFn { |
| 44 float fG; |
| 45 float fA; |
| 46 float fB; |
| 47 float fC; |
| 48 float fD; |
| 49 float fE; |
| 50 float fF; |
| 51 }; |
| 52 |
32 class SK_API SkColorSpace : public SkRefCnt { | 53 class SK_API SkColorSpace : public SkRefCnt { |
33 public: | 54 public: |
34 | 55 |
35 /** | 56 /** |
36 * Common, named profiles that we can recognize. | 57 * Common, named profiles that we can recognize. |
37 */ | 58 */ |
38 enum Named : uint8_t { | 59 enum Named : uint8_t { |
39 /** | 60 /** |
40 * By far the most common color space. | 61 * By far the most common color space. |
41 * This is the default space for images, unmarked content, and monitors
. | 62 * This is the default space for images, unmarked content, and monitors
. |
(...skipping 19 matching lines...) Expand all Loading... |
61 /** | 82 /** |
62 * Transfer function is the canonical sRGB curve, which has a short lin
ear segment | 83 * Transfer function is the canonical sRGB curve, which has a short lin
ear segment |
63 * followed by a 2.4f exponential. | 84 * followed by a 2.4f exponential. |
64 */ | 85 */ |
65 kSRGB_RenderTargetGamma, | 86 kSRGB_RenderTargetGamma, |
66 }; | 87 }; |
67 | 88 |
68 /** | 89 /** |
69 * Create an SkColorSpace from a transfer function and a color gamut. | 90 * Create an SkColorSpace from a transfer function and a color gamut. |
70 * | 91 * |
71 * Transfer function is specified as linear or sRGB. | 92 * Transfer function can be specified as a render target or as the coeffici
ents to an equation. |
72 * Gamut is specified using the matrix transformation to XYZ D50. | 93 * Gamut is specified using the matrix transformation to XYZ D50. |
73 */ | 94 */ |
74 static sk_sp<SkColorSpace> NewRGB(RenderTargetGamma gamma, const SkMatrix44&
toXYZD50); | 95 static sk_sp<SkColorSpace> NewRGB(RenderTargetGamma gamma, const SkMatrix44&
toXYZD50); |
| 96 static sk_sp<SkColorSpace> NewRGB(const SkColorSpaceTransferFn& coeffs, |
| 97 const SkMatrix44& toXYZD50); |
75 | 98 |
76 /** | 99 /** |
77 * Create a common, named SkColorSpace. | 100 * Create a common, named SkColorSpace. |
78 */ | 101 */ |
79 static sk_sp<SkColorSpace> NewNamed(Named); | 102 static sk_sp<SkColorSpace> NewNamed(Named); |
80 | 103 |
81 /** | 104 /** |
82 * Create an SkColorSpace from an ICC profile. | 105 * Create an SkColorSpace from an ICC profile. |
83 */ | 106 */ |
84 static sk_sp<SkColorSpace> NewICC(const void*, size_t); | 107 static sk_sp<SkColorSpace> NewICC(const void*, size_t); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 * If both are null, we return true. If one is null and the other is not,
we return false. | 139 * If both are null, we return true. If one is null and the other is not,
we return false. |
117 * If both are non-null, we do a deeper compare. | 140 * If both are non-null, we do a deeper compare. |
118 */ | 141 */ |
119 static bool Equals(const SkColorSpace* src, const SkColorSpace* dst); | 142 static bool Equals(const SkColorSpace* src, const SkColorSpace* dst); |
120 | 143 |
121 protected: | 144 protected: |
122 SkColorSpace() {} | 145 SkColorSpace() {} |
123 }; | 146 }; |
124 | 147 |
125 #endif | 148 #endif |
OLD | NEW |