Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(777)

Side by Side Diff: src/codec/SkCodecPriv.h

Issue 2246143002: Support color xforms for kIndex8 pngs (Closed) Base URL: https://skia.googlesource.com/skia.git@xformpremul
Patch Set: Response to comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/codec/SkCodecImageGenerator.cpp ('k') | src/codec/SkPngCodec.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « src/codec/SkCodecImageGenerator.cpp ('k') | src/codec/SkPngCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698