From 2c516b3ffb8cf23b2317bb0ccb55f9eb42354c00 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Sat, 19 Oct 2024 11:13:07 +0000 Subject: [PATCH] Bug 1925265. Always correctly handle the TO_SRGB_COLORSPACE flag when decoding an image. r=gfx-reviewers,aosmond Differential Revision: https://phabricator.services.mozilla.com/D225962 --- image/Decoder.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/image/Decoder.cpp b/image/Decoder.cpp index 98f52440f32a..44b1547e136d 100644 --- a/image/Decoder.cpp +++ b/image/Decoder.cpp @@ -93,10 +93,20 @@ Decoder::~Decoder() { void Decoder::SetSurfaceFlags(SurfaceFlags aSurfaceFlags) { MOZ_ASSERT(!mInitialized); + MOZ_ASSERT(!(mSurfaceFlags & SurfaceFlags::NO_COLORSPACE_CONVERSION) || + !(mSurfaceFlags & SurfaceFlags::TO_SRGB_COLORSPACE)); mSurfaceFlags = aSurfaceFlags; if (mSurfaceFlags & SurfaceFlags::NO_COLORSPACE_CONVERSION) { mCMSMode = CMSMode::Off; } + if (mSurfaceFlags & SurfaceFlags::TO_SRGB_COLORSPACE) { + // CMSMode::TaggedOnly and CMSMode::All are equivalent when the + // TO_SRGB_COLORSPACE flag is set (for untagged images CMSMode::All assumes + // they are in sRGB space so it does nothing, which is same as what + // CMSMode::TaggedOnly does for untagged images). We just want to avoid + // CMSMode::Off so that the sRGB conversion actually happens. + mCMSMode = CMSMode::All; + } } qcms_profile* Decoder::GetCMSOutputProfile() const {