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_Base_DEFINED | 8 #ifndef SkColorSpace_Base_DEFINED |
9 #define SkColorSpace_Base_DEFINED | 9 #define SkColorSpace_Base_DEFINED |
10 | 10 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 // Objects of this type are created in a custom fashion using sk_malloc_thro
w | 163 // Objects of this type are created in a custom fashion using sk_malloc_thro
w |
164 // and therefore must be sk_freed. | 164 // and therefore must be sk_freed. |
165 void* operator new(size_t size) = delete; | 165 void* operator new(size_t size) = delete; |
166 void* operator new(size_t, void* p) { return p; } | 166 void* operator new(size_t, void* p) { return p; } |
167 void operator delete(void* p) { sk_free(p); } | 167 void operator delete(void* p) { sk_free(p); } |
168 }; | 168 }; |
169 | 169 |
170 class SkColorSpace_Base : public SkColorSpace { | 170 class SkColorSpace_Base : public SkColorSpace { |
171 public: | 171 public: |
172 SkGammaNamed gammaNamed() const { return fGammaNamed; } | |
173 const SkGammas* gammas() const { return fGammas.get(); } | |
174 | |
175 const SkColorLookUpTable* colorLUT() const { return fColorLUT.get(); } | |
176 | |
177 const SkMatrix44& toXYZD50() const { return fToXYZD50; } | |
178 const SkMatrix44& fromXYZD50() const; | |
179 | |
180 void toDstGammaTables(const uint8_t* tables[3], sk_sp<SkData>* storage, int
numTables) const; | |
181 | 172 |
182 /** | 173 /** |
183 * Create an SkColorSpace with the same gamut as this color space, but with
linear gamma. | 174 * Describes color space gamut as a transformation to XYZ D50. |
| 175 * Returns nullptr if color gamut cannot be described in terms of XYZ D50. |
184 */ | 176 */ |
185 sk_sp<SkColorSpace> makeLinearGamma(); | 177 virtual const SkMatrix44* toXYZD50() const = 0; |
| 178 |
| 179 /** |
| 180 * Describes color space gamut as a transformation from XYZ D50 |
| 181 * Returns nullptr if color gamut cannot be described in terms of XYZ D50. |
| 182 */ |
| 183 virtual const SkMatrix44* fromXYZD50() const = 0; |
| 184 |
| 185 virtual bool onGammaCloseToSRGB() const = 0; |
| 186 |
| 187 virtual bool onGammaIsLinear() const = 0; |
| 188 |
| 189 enum class Type : uint8_t { |
| 190 kXYZ, |
| 191 kA2B |
| 192 }; |
| 193 |
| 194 virtual Type type() const = 0; |
| 195 |
| 196 protected: |
| 197 SkColorSpace_Base(sk_sp<SkData> profileData); |
186 | 198 |
187 private: | 199 private: |
188 | 200 |
189 /** | 201 /** |
190 * FIXME (msarett): | 202 * FIXME (msarett): |
191 * Hiding this function until we can determine if we need it. Known issues
include: | 203 * Hiding this function until we can determine if we need it. Known issues
include: |
192 * Only writes 3x3 matrices | 204 * Only writes 3x3 matrices |
193 * Only writes float gammas | 205 * Only writes float gammas |
194 * Rejected by some parsers because the "profile description" is empty | 206 * Rejected by some parsers because the "profile description" is empty |
195 */ | 207 */ |
196 sk_sp<SkData> writeToICC() const; | 208 sk_sp<SkData> writeToICC() const; |
197 | 209 |
198 static sk_sp<SkColorSpace> NewRGB(SkGammaNamed gammaNamed, const SkMatrix44&
toXYZD50); | 210 static sk_sp<SkColorSpace> NewRGB(SkGammaNamed gammaNamed, const SkMatrix44&
toXYZD50); |
199 | 211 |
200 SkColorSpace_Base(SkGammaNamed gammaNamed, const SkMatrix44& toXYZ); | 212 SkColorSpace_Base(SkGammaNamed gammaNamed, const SkMatrix44& toXYZ); |
201 | 213 |
202 SkColorSpace_Base(sk_sp<SkColorLookUpTable> colorLUT, SkGammaNamed gammaName
d, | 214 sk_sp<SkData> fProfileData; |
203 sk_sp<SkGammas> gammas, const SkMatrix44& toXYZ, sk_sp<SkD
ata> profileData); | |
204 | |
205 sk_sp<SkColorLookUpTable> fColorLUT; | |
206 const SkGammaNamed fGammaNamed; | |
207 sk_sp<SkGammas> fGammas; | |
208 sk_sp<SkData> fProfileData; | |
209 | |
210 const SkMatrix44 fToXYZD50; | |
211 mutable SkMatrix44 fFromXYZD50; | |
212 mutable SkOnce fFromXYZOnce; | |
213 | |
214 mutable sk_sp<SkData> fDstStorage; | |
215 mutable const uint8_t* fToDstGammaTables[3]; | |
216 mutable SkOnce fToDstGammaOnce; | |
217 | 215 |
218 friend class SkColorSpace; | 216 friend class SkColorSpace; |
| 217 friend class SkColorSpace_XYZ; |
219 friend class ColorSpaceXformTest; | 218 friend class ColorSpaceXformTest; |
220 friend class ColorSpaceTest; | 219 friend class ColorSpaceTest; |
221 typedef SkColorSpace INHERITED; | 220 typedef SkColorSpace INHERITED; |
222 }; | 221 }; |
223 | 222 |
224 static inline SkColorSpace_Base* as_CSB(SkColorSpace* colorSpace) { | 223 static inline SkColorSpace_Base* as_CSB(SkColorSpace* colorSpace) { |
225 return static_cast<SkColorSpace_Base*>(colorSpace); | 224 return static_cast<SkColorSpace_Base*>(colorSpace); |
226 } | 225 } |
227 | 226 |
228 static inline const SkColorSpace_Base* as_CSB(const SkColorSpace* colorSpace) { | 227 static inline const SkColorSpace_Base* as_CSB(const SkColorSpace* colorSpace) { |
229 return static_cast<const SkColorSpace_Base*>(colorSpace); | 228 return static_cast<const SkColorSpace_Base*>(colorSpace); |
230 } | 229 } |
231 | 230 |
232 static inline SkColorSpace_Base* as_CSB(const sk_sp<SkColorSpace>& colorSpace) { | 231 static inline SkColorSpace_Base* as_CSB(const sk_sp<SkColorSpace>& colorSpace) { |
233 return static_cast<SkColorSpace_Base*>(colorSpace.get()); | 232 return static_cast<SkColorSpace_Base*>(colorSpace.get()); |
234 } | 233 } |
235 | 234 |
236 #endif | 235 #endif |
OLD | NEW |