OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 SkImageInfo_DEFINED | 8 #ifndef SkImageInfo_DEFINED |
9 #define SkImageInfo_DEFINED | 9 #define SkImageInfo_DEFINED |
10 | 10 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 kRec601_SkYUVColorSpace, | 162 kRec601_SkYUVColorSpace, |
163 /** HDTV standard Rec. 709 color space. Uses "studio swing" [16, 235] color | 163 /** HDTV standard Rec. 709 color space. Uses "studio swing" [16, 235] color |
164 range. See http://en.wikipedia.org/wiki/Rec._709 for details. */ | 164 range. See http://en.wikipedia.org/wiki/Rec._709 for details. */ |
165 kRec709_SkYUVColorSpace, | 165 kRec709_SkYUVColorSpace, |
166 | 166 |
167 kLastEnum_SkYUVColorSpace = kRec709_SkYUVColorSpace | 167 kLastEnum_SkYUVColorSpace = kRec709_SkYUVColorSpace |
168 }; | 168 }; |
169 | 169 |
170 /////////////////////////////////////////////////////////////////////////////// | 170 /////////////////////////////////////////////////////////////////////////////// |
171 | 171 |
172 #ifdef SK_SUPPORT_LEGACY_COLORPROFILETYPE | |
173 enum SkColorProfileType { | |
174 kLinear_SkColorProfileType, | |
175 kSRGB_SkColorProfileType, | |
176 | |
177 kLastEnum_SkColorProfileType = kSRGB_SkColorProfileType | |
178 }; | |
179 #endif | |
180 | |
181 enum class SkSourceGammaTreatment { | 172 enum class SkSourceGammaTreatment { |
182 kRespect, | 173 kRespect, |
183 kIgnore, | 174 kIgnore, |
184 }; | 175 }; |
185 | 176 |
186 /** | 177 /** |
187 * Describe an image's dimensions and pixel type. | 178 * Describe an image's dimensions and pixel type. |
188 * Used for both src images and render-targets (surfaces). | 179 * Used for both src images and render-targets (surfaces). |
189 */ | 180 */ |
190 struct SK_API SkImageInfo { | 181 struct SK_API SkImageInfo { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 } | 222 } |
232 | 223 |
233 static SkImageInfo MakeUnknown(int width, int height) { | 224 static SkImageInfo MakeUnknown(int width, int height) { |
234 return Make(width, height, kUnknown_SkColorType, kUnknown_SkAlphaType, n
ullptr); | 225 return Make(width, height, kUnknown_SkColorType, kUnknown_SkAlphaType, n
ullptr); |
235 } | 226 } |
236 | 227 |
237 static SkImageInfo MakeUnknown() { | 228 static SkImageInfo MakeUnknown() { |
238 return MakeUnknown(0, 0); | 229 return MakeUnknown(0, 0); |
239 } | 230 } |
240 | 231 |
241 #ifdef SK_SUPPORT_LEGACY_COLORPROFILETYPE | |
242 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a
t, | |
243 SkColorProfileType pt) { | |
244 sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? | |
245 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr; | |
246 return Make(width, height, ct, at, cs); | |
247 } | |
248 | |
249 static SkImageInfo MakeN32(int width, int height, SkAlphaType at, SkColorPro
fileType pt) { | |
250 sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? | |
251 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Name
d) : nullptr; | |
252 return SkImageInfo(width, height, kN32_SkColorType, at, cs); | |
253 } | |
254 | |
255 /** | |
256 * Sets colortype to the native ARGB32 type, and the alphatype to premul. | |
257 */ | |
258 static SkImageInfo MakeN32Premul(int width, int height, SkColorProfileType p
t) { | |
259 sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? | |
260 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Name
d) : nullptr; | |
261 return Make(width, height, kN32_SkColorType, kPremul_SkAlphaType, cs); | |
262 } | |
263 | |
264 /** | |
265 * Sets colortype to the native ARGB32 type, and the alphatype to premul. | |
266 */ | |
267 static SkImageInfo MakeN32Premul(const SkISize& size, SkColorProfileType pt)
{ | |
268 return MakeN32Premul(size.width(), size.height(), pt); | |
269 } | |
270 | |
271 SkColorProfileType profileType() const; | |
272 bool isLinear() const { return kLinear_SkColorProfileType == this->profileTy
pe(); } | |
273 bool isSRGB() const { return kSRGB_SkColorProfileType == this->profileType()
; } | |
274 #endif | |
275 | |
276 int width() const { return fWidth; } | 232 int width() const { return fWidth; } |
277 int height() const { return fHeight; } | 233 int height() const { return fHeight; } |
278 SkColorType colorType() const { return fColorType; } | 234 SkColorType colorType() const { return fColorType; } |
279 SkAlphaType alphaType() const { return fAlphaType; } | 235 SkAlphaType alphaType() const { return fAlphaType; } |
280 SkColorSpace* colorSpace() const { return fColorSpace.get(); } | 236 SkColorSpace* colorSpace() const { return fColorSpace.get(); } |
281 | 237 |
282 bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; } | 238 bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; } |
283 | 239 |
284 bool isOpaque() const { | 240 bool isOpaque() const { |
285 return SkAlphaTypeIsOpaque(fAlphaType); | 241 return SkAlphaTypeIsOpaque(fAlphaType); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 // Anything with a color-space attached is gamma-correct, as is F16. | 352 // Anything with a color-space attached is gamma-correct, as is F16. |
397 // To get legacy behavior, you need to ask for non-F16, with a nullptr color
space. | 353 // To get legacy behavior, you need to ask for non-F16, with a nullptr color
space. |
398 return (cs != nullptr) || kRGBA_F16_SkColorType == ct; | 354 return (cs != nullptr) || kRGBA_F16_SkColorType == ct; |
399 } | 355 } |
400 | 356 |
401 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) { | 357 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) { |
402 return SkColorAndColorSpaceAreGammaCorrect(info.colorType(), info.colorSpace
()); | 358 return SkColorAndColorSpaceAreGammaCorrect(info.colorType(), info.colorSpace
()); |
403 } | 359 } |
404 | 360 |
405 #endif | 361 #endif |
OLD | NEW |