aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkBmpCodec.h
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-07-14 16:32:31 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-14 21:14:06 +0000
commit588fb040b3ad410cdb10c87f9a7884b6eb825e90 (patch)
tree954314604fe306c899e5d44417cc1019a0a078f5 /src/codec/SkBmpCodec.h
parent0274b30feeacae0bcd12f03ae96cb4721c1393a2 (diff)
Report error on failure to create SkCodec
Update NewFromStream to report an error on failure to create an SkCodec, so that a client can distinguish between - not enough data - invalid data In Chromium, this will allow blink::ImageDecoder to call SetFailed if the stream is invalid early and we never create an SkCodec. Without this, ImageDecoder will keep trying to create an SkCodec when it receives more data. Change-Id: I4f505c56d91c982be36a828fd0f7db17b1596588 Reviewed-on: https://skia-review.googlesource.com/22642 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com> Reviewed-by: Chris Blume <cblume@chromium.org>
Diffstat (limited to 'src/codec/SkBmpCodec.h')
-rw-r--r--src/codec/SkBmpCodec.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/codec/SkBmpCodec.h b/src/codec/SkBmpCodec.h
index bf9727fa1c..d5f5a32eae 100644
--- a/src/codec/SkBmpCodec.h
+++ b/src/codec/SkBmpCodec.h
@@ -28,13 +28,13 @@ public:
* Creates a bmp decoder
* Reads enough of the stream to determine the image format
*/
- static SkCodec* NewFromStream(SkStream*);
+ static SkCodec* NewFromStream(SkStream*, Result*);
/*
* Creates a bmp decoder for a bmp embedded in ico
* Reads enough of the stream to determine the image format
*/
- static SkCodec* NewFromIco(SkStream*);
+ static SkCodec* NewFromIco(SkStream*, Result*);
protected:
@@ -44,12 +44,11 @@ protected:
SkEncodedImageFormat onGetEncodedFormat() const override { return SkEncodedImageFormat::kBMP; }
/*
- * Read enough of the stream to initialize the SkBmpCodec. Returns a bool
- * representing success or failure. If it returned true, and codecOut was
- * not nullptr, it will be set to a new SkBmpCodec.
+ * Read enough of the stream to initialize the SkBmpCodec.
+ * On kSuccess, if codecOut is not nullptr, it will be set to a new SkBmpCodec.
* If an SkCodec is created, it will take ownership of the SkStream.
*/
- static bool ReadHeader(SkStream*, bool inIco, std::unique_ptr<SkCodec>* codecOut);
+ static Result ReadHeader(SkStream*, bool inIco, std::unique_ptr<SkCodec>* codecOut);
bool onRewind() override;
@@ -113,7 +112,7 @@ private:
* Creates a bmp decoder
* Reads enough of the stream to determine the image format
*/
- static SkCodec* NewFromStream(SkStream*, bool inIco);
+ static SkCodec* NewFromStream(SkStream*, Result*, bool inIco);
/*
* Decodes the next dstInfo.height() lines.