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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 : fColorSpace(nullptr) | 191 : fColorSpace(nullptr) |
192 , fWidth(0) | 192 , fWidth(0) |
193 , fHeight(0) | 193 , fHeight(0) |
194 , fColorType(kUnknown_SkColorType) | 194 , fColorType(kUnknown_SkColorType) |
195 , fAlphaType(kUnknown_SkAlphaType) | 195 , fAlphaType(kUnknown_SkAlphaType) |
196 , fProfileType(kLinear_SkColorProfileType) | 196 , fProfileType(kLinear_SkColorProfileType) |
197 {} | 197 {} |
198 | 198 |
199 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a
t, | 199 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a
t, |
200 SkColorProfileType pt = kLinear_SkColorProfileType)
{ | 200 SkColorProfileType pt = kLinear_SkColorProfileType)
{ |
201 return SkImageInfo(width, height, ct, at, pt, nullptr); | 201 sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? |
| 202 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Name
d) : nullptr; |
| 203 return SkImageInfo(width, height, ct, at, pt, cs); |
202 } | 204 } |
203 | 205 |
204 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a
t, | 206 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a
t, |
205 sk_sp<SkColorSpace> cs); | 207 sk_sp<SkColorSpace> cs); |
206 | 208 |
207 /** | 209 /** |
208 * Sets colortype to the native ARGB32 type. | 210 * Sets colortype to the native ARGB32 type. |
209 */ | 211 */ |
210 static SkImageInfo MakeN32(int width, int height, SkAlphaType at, | 212 static SkImageInfo MakeN32(int width, int height, SkAlphaType at, |
211 SkColorProfileType pt = kLinear_SkColorProfileTyp
e) { | 213 SkColorProfileType pt = kLinear_SkColorProfileTyp
e) { |
212 return SkImageInfo(width, height, kN32_SkColorType, at, pt, nullptr); | 214 sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? |
| 215 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Name
d) : nullptr; |
| 216 return SkImageInfo(width, height, kN32_SkColorType, at, pt, cs); |
213 } | 217 } |
214 | 218 |
215 /** | 219 /** |
216 * Sets colortype to the native ARGB32 type, and the alphatype to premul. | 220 * Sets colortype to the native ARGB32 type, and the alphatype to premul. |
217 */ | 221 */ |
218 static SkImageInfo MakeN32Premul(int width, int height, | 222 static SkImageInfo MakeN32Premul(int width, int height, |
219 SkColorProfileType pt = kLinear_SkColorProf
ileType) { | 223 SkColorProfileType pt = kLinear_SkColorProf
ileType) { |
220 return SkImageInfo(width, height, kN32_SkColorType, kPremul_SkAlphaType,
pt, nullptr); | 224 sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? |
| 225 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Name
d) : nullptr; |
| 226 return SkImageInfo(width, height, kN32_SkColorType, kPremul_SkAlphaType,
pt, cs); |
221 } | 227 } |
222 | 228 |
223 /** | 229 /** |
224 * Sets colortype to the native ARGB32 type, and the alphatype to premul. | 230 * Sets colortype to the native ARGB32 type, and the alphatype to premul. |
225 */ | 231 */ |
226 static SkImageInfo MakeN32Premul(const SkISize& size, | 232 static SkImageInfo MakeN32Premul(const SkISize& size, |
227 SkColorProfileType pt = kLinear_SkColorProf
ileType) { | 233 SkColorProfileType pt = kLinear_SkColorProf
ileType) { |
228 return MakeN32Premul(size.width(), size.height(), pt); | 234 return MakeN32Premul(size.width(), size.height(), pt); |
229 } | 235 } |
230 | 236 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 381 |
376 static inline bool SkColorAndProfileAreGammaCorrect(SkColorType ct, SkColorProfi
leType pt) { | 382 static inline bool SkColorAndProfileAreGammaCorrect(SkColorType ct, SkColorProfi
leType pt) { |
377 return kSRGB_SkColorProfileType == pt || kRGBA_F16_SkColorType == ct; | 383 return kSRGB_SkColorProfileType == pt || kRGBA_F16_SkColorType == ct; |
378 } | 384 } |
379 | 385 |
380 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) { | 386 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) { |
381 return SkColorAndProfileAreGammaCorrect(info.colorType(), info.profileType()
); | 387 return SkColorAndProfileAreGammaCorrect(info.colorType(), info.profileType()
); |
382 } | 388 } |
383 | 389 |
384 #endif | 390 #endif |
OLD | NEW |