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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp

Issue 2787053004: Respect colorSpace in DecodingImageGenerator::onGetPixels() (Closed)
Patch Set: Response to comments Created 3 years, 8 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
Index: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
index 440e16a3e3af68ffdd1031bc7fd9eb7803dc3732..414eb0283c672a3f415b600816417a10871456ec 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
@@ -549,8 +549,26 @@ sk_sp<SkColorSpace> ImageDecoder::colorSpaceForSkImages() const {
if (!m_colorBehavior.isTag())
return nullptr;
- if (m_embeddedColorSpace)
- return m_embeddedColorSpace;
+ if (m_embeddedColorSpace) {
+ SkColorSpaceTransferFn fn;
+ if (m_embeddedColorSpace->isNumericalTransferFn(&fn)) {
+ // The embedded color space is supported by Skia.
+ return m_embeddedColorSpace;
+ }
+
+ // In the rare case that the embedded color space is unsupported, xform at
+ // decode time.
+ SkMatrix44 toXYZD50(SkMatrix44::kUninitialized_Constructor);
+ if (m_embeddedColorSpace->toXYZD50(&toXYZD50)) {
+ // Preserve the gamut, but convert to a standard transfer function.
+ return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
+ toXYZD50);
+ }
+
+ // For color spaces without an identifiable gamut, just fall through to
+ // sRGB.
+ }
+
return SkColorSpace::MakeSRGB();
}

Powered by Google App Engine
This is Rietveld 408576698