From: scroggo Date: Fri, 19 Feb 2016 20:08:41 +0000 (-0800) Subject: Insert an empty image when we cannot decode X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~129^2~1932 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=950fb1ca24cca9803eb29dc6aa5472b0f506a67f;p=platform%2Fupstream%2FlibSkiaSharp.git Insert an empty image when we cannot decode In SKP deserialization, if there is a 0 byte encoded image, we insert an empty image into the output SkPicture so that we can continue deserializing. Do the same when our decoder cannot decode it. This may be the result of a bug in our decoder, or in the stream serialization. But it should not mean the entire stream is invalid. BUG=skia:4691 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1715853002 Review URL: https://codereview.chromium.org/1715853002 --- diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp index ca89022..6823a6c 100644 --- a/src/core/SkReadBuffer.cpp +++ b/src/core/SkReadBuffer.cpp @@ -313,7 +313,13 @@ SkImage* SkReadBuffer::readImage() { } const SkIRect subset = SkIRect::MakeXYWH(originX, originY, width, height); - return SkImage::NewFromEncoded(encoded, &subset); + SkImage* image = SkImage::NewFromEncoded(encoded, &subset); + if (image) { + return image; + } + + return SkImage::NewFromGenerator( + new EmptyImageGenerator(SkImageInfo::MakeN32Premul(width, height))); } SkTypeface* SkReadBuffer::readTypeface() {