From dc7128f82beffe68fa6e00d6d3e767875be230f5 Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Mon, 6 Jan 2020 19:03:41 +0000 Subject: [PATCH] Bug 1516761 - Only use OS_RGBA for the first frame of animated GIFs. r=tnikkel Differential Revision: https://phabricator.services.mozilla.com/D58821 --HG-- extra : moz-landing-system : lando --- image/decoders/nsGIFDecoder2.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/image/decoders/nsGIFDecoder2.cpp b/image/decoders/nsGIFDecoder2.cpp index c87dda04a9e4..10ead066a4ac 100644 --- a/image/decoders/nsGIFDecoder2.cpp +++ b/image/decoders/nsGIFDecoder2.cpp @@ -190,7 +190,12 @@ nsresult nsGIFDecoder2::BeginImageFrame(const IntRect& aFrameRect, // The first frame may be displayed progressively. pipeFlags |= SurfacePipeFlags::PROGRESSIVE_DISPLAY; - format = hasTransparency ? SurfaceFormat::OS_RGBA : SurfaceFormat::OS_RGBX; + // Only allow opaque surfaces if we are decoding a single image without + // transparency. For an animation, there isn't much benefit to RGBX given + // the current frame is constantly changing, and there are many risks + // since BlendAnimationFilter is able to clear rows of data. + format = hasTransparency || animParams ? SurfaceFormat::OS_RGBA + : SurfaceFormat::OS_RGBX; } else { format = SurfaceFormat::OS_RGBA; }