зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1255106 - Part 4. Ensure we don't apply CMS transforms in cases we missed. r=tnikkel
GIF images should not apply CMS transforms if disabled by caller via SurfaceFlags::NO_COLORSPACE_CONVERSION. WebP images should reject any non-RGB ICC profiles, not just grayscale profiles. Differential Revision: https://phabricator.services.mozilla.com/D26372
This commit is contained in:
Родитель
741028ad6b
Коммит
1f049d2787
|
@ -392,9 +392,10 @@ Tuple<int32_t, Maybe<WriteState>> nsGIFDecoder2::YieldPixels(
|
|||
|
||||
/// Expand the colormap from RGB to Packed ARGB as needed by Cairo.
|
||||
/// And apply any LCMS transformation.
|
||||
static void ConvertColormap(uint32_t* aColormap, uint32_t aColors) {
|
||||
void nsGIFDecoder2::ConvertColormap(uint32_t* aColormap, uint32_t aColors) {
|
||||
// Apply CMS transformation if enabled and available
|
||||
if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
|
||||
if (!(GetSurfaceFlags() & SurfaceFlags::NO_COLORSPACE_CONVERSION) &&
|
||||
gfxPlatform::GetCMSMode() == eCMSMode_All) {
|
||||
qcms_transform* transform = gfxPlatform::GetCMSRGBTransform();
|
||||
if (transform) {
|
||||
qcms_transform_data(transform, aColormap, aColormap, aColors);
|
||||
|
|
|
@ -58,6 +58,9 @@ class nsGIFDecoder2 : public Decoder {
|
|||
/// Called when we finish decoding the entire image.
|
||||
void FlushImageData();
|
||||
|
||||
/// Convert color map to BGRA, applying any necessary CMS tranforms.
|
||||
void ConvertColormap(uint32_t* aColormap, uint32_t aColors);
|
||||
|
||||
/// Transforms a palette index into a pixel.
|
||||
template <typename PixelSize>
|
||||
PixelSize ColormapIndexToPixel(uint8_t aIndex);
|
||||
|
|
|
@ -271,15 +271,15 @@ void nsWebPDecoder::ApplyColorProfile(const char* aProfile, size_t aLength) {
|
|||
}
|
||||
|
||||
auto mode = gfxPlatform::GetCMSMode();
|
||||
if (mode == eCMSMode_Off || (mode == eCMSMode_TaggedOnly && !aProfile)) {
|
||||
if (mode == eCMSMode_Off || (mode == eCMSMode_TaggedOnly && !aProfile) ||
|
||||
!gfxPlatform::GetCMSOutputProfile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aProfile || !gfxPlatform::GetCMSOutputProfile()) {
|
||||
if (!aProfile) {
|
||||
MOZ_LOG(sWebPLog, LogLevel::Debug,
|
||||
("[this=%p] nsWebPDecoder::ApplyColorProfile -- not tagged or no "
|
||||
"output "
|
||||
"profile , use sRGB transform\n",
|
||||
("[this=%p] nsWebPDecoder::ApplyColorProfile -- not tagged, use "
|
||||
"sRGB transform\n",
|
||||
this));
|
||||
mTransform = gfxPlatform::GetCMSBGRATransform();
|
||||
return;
|
||||
|
@ -295,10 +295,10 @@ void nsWebPDecoder::ApplyColorProfile(const char* aProfile, size_t aLength) {
|
|||
}
|
||||
|
||||
uint32_t profileSpace = qcms_profile_get_color_space(mInProfile);
|
||||
if (profileSpace == icSigGrayData) {
|
||||
if (profileSpace != icSigRgbData) {
|
||||
// WebP doesn't produce grayscale data, this must be corrupt.
|
||||
MOZ_LOG(sWebPLog, LogLevel::Error,
|
||||
("[this=%p] nsWebPDecoder::ApplyColorProfile -- ignoring grayscale "
|
||||
("[this=%p] nsWebPDecoder::ApplyColorProfile -- ignoring non-rgb "
|
||||
"color profile\n",
|
||||
this));
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче