OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The Android Open Source Project | 2 * Copyright 2015 The Android Open Source Project |
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 SkCodecPriv_DEFINED | 8 #ifndef SkCodecPriv_DEFINED |
9 #define SkCodecPriv_DEFINED | 9 #define SkCodecPriv_DEFINED |
10 | 10 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 303 } |
304 } else { | 304 } else { |
305 if (isRGBA) { | 305 if (isRGBA) { |
306 return &SkPackARGB_as_RGBA; | 306 return &SkPackARGB_as_RGBA; |
307 } else { | 307 } else { |
308 return &SkPackARGB_as_BGRA; | 308 return &SkPackARGB_as_BGRA; |
309 } | 309 } |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
| 313 static inline bool needs_premul(const SkImageInfo& dstInfo, const SkImageInfo& s
rcInfo) { |
| 314 return kPremul_SkAlphaType == dstInfo.alphaType() && |
| 315 kUnpremul_SkAlphaType == srcInfo.alphaType(); |
| 316 } |
| 317 |
313 static inline bool needs_color_xform(const SkImageInfo& dstInfo, const SkImageIn
fo& srcInfo) { | 318 static inline bool needs_color_xform(const SkImageInfo& dstInfo, const SkImageIn
fo& srcInfo) { |
314 return (kRGBA_F16_SkColorType == dstInfo.colorType()) || | 319 // Color xform is necessary in order to correctly perform premultiply in lin
ear space. |
315 (dstInfo.colorSpace() && !SkColorSpace::Equals(srcInfo.colorSpace(), | 320 bool needsPremul = needs_premul(dstInfo, srcInfo); |
316 dstInfo.colorSpace()))
; | 321 |
| 322 // F16 is by definition a linear space, so we always must perform a color xf
orm. |
| 323 bool isF16 = kRGBA_F16_SkColorType == dstInfo.colorType(); |
| 324 |
| 325 // Need a color xform when dst space does not match the src. |
| 326 bool srcDstNotEqual = !SkColorSpace::Equals(srcInfo.colorSpace(), dstInfo.co
lorSpace()); |
| 327 |
| 328 // We never perform a color xform in legacy mode. |
| 329 bool isLegacy = nullptr == dstInfo.colorSpace(); |
| 330 |
| 331 return !isLegacy && (needsPremul || isF16 || srcDstNotEqual); |
317 } | 332 } |
318 | 333 |
319 #endif // SkCodecPriv_DEFINED | 334 #endif // SkCodecPriv_DEFINED |
OLD | NEW |