From 80ef739d5b76b4ffe15b53e5b5ba0c3f9d72390f Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Tue, 23 Apr 2019 13:47:23 -0400 Subject: [PATCH] Convert animated unpremul images to premul during decode (flutter/engine#8698) Skia allows drawing unpremul images, but filtering them can look bad. Internally Skia performs this transformation when creating SkImages from encoded data (so this already happens for MakeCrossContextFromEncoded), and for consistency/quality it should be done here, too. Fixes #28785 --- engine/src/flutter/lib/ui/painting/codec.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/lib/ui/painting/codec.cc b/engine/src/flutter/lib/ui/painting/codec.cc index bf327739a6..ec724957c5 100644 --- a/engine/src/flutter/lib/ui/painting/codec.cc +++ b/engine/src/flutter/lib/ui/painting/codec.cc @@ -401,7 +401,10 @@ sk_sp MultiFrameCodec::GetNextFrameImage( : SkBitmap(); const bool frameAlreadyCached = bitmap.getPixels(); if (!frameAlreadyCached) { - const SkImageInfo info = codec_->getInfo().makeColorType(kN32_SkColorType); + SkImageInfo info = codec_->getInfo().makeColorType(kN32_SkColorType); + if (info.alphaType() == kUnpremul_SkAlphaType) { + info = info.makeAlphaType(kPremul_SkAlphaType); + } bitmap.allocPixels(info); SkCodec::Options options;