aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2016-02-19 12:08:41 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-19 12:08:41 -0800
commit950fb1ca24cca9803eb29dc6aa5472b0f506a67f (patch)
treeddb63ced455fdef6698e7ac78223d209f8a27e15 /src
parent27e88d0dab8d9fe66b572004972b01adc62a8063 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/core/SkReadBuffer.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index ca89022d12..6823a6cd8e 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() {