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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/codec/SkCodecImageGenerator.cpp ('k') | src/codec/SkPngCodec.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodecPriv.h
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index b768b23a8aed63356981fd12dcea9f42d3d4b3d1..17494074b31306eadea1bf7d17c49e7b104277ff 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -310,10 +310,25 @@ static inline PackColorProc choose_pack_color_proc(bool isPremul, SkColorType co
}
}
+static inline bool needs_premul(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo) {
+ return kPremul_SkAlphaType == dstInfo.alphaType() &&
+ kUnpremul_SkAlphaType == srcInfo.alphaType();
+}
+
static inline bool needs_color_xform(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo) {
- return (kRGBA_F16_SkColorType == dstInfo.colorType()) ||
- (dstInfo.colorSpace() && !SkColorSpace::Equals(srcInfo.colorSpace(),
- dstInfo.colorSpace()));
+ // Color xform is necessary in order to correctly perform premultiply in linear space.
+ bool needsPremul = needs_premul(dstInfo, srcInfo);
+
+ // F16 is by definition a linear space, so we always must perform a color xform.
+ bool isF16 = kRGBA_F16_SkColorType == dstInfo.colorType();
+
+ // Need a color xform when dst space does not match the src.
+ bool srcDstNotEqual = !SkColorSpace::Equals(srcInfo.colorSpace(), dstInfo.colorSpace());
+
+ // We never perform a color xform in legacy mode.
+ bool isLegacy = nullptr == dstInfo.colorSpace();
+
+ return !isLegacy && (needsPremul || isF16 || srcDstNotEqual);
}
#endif // SkCodecPriv_DEFINED
« 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