Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: src/codec/SkCodec.cpp

Issue 1381483002: Call rewindIfNeeded in SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@codecSDmerge
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/codec/SkBmpStandardCodec.cpp ('k') | src/codec/SkCodec_libgif.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodec.cpp
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 97bcf3e1d84403f776900be5e9965500fa481291..cabcadcccda5c872b69834daa18bbe1701be82fd 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -87,6 +87,12 @@ SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream)
SkCodec::~SkCodec() {}
bool SkCodec::rewindIfNeeded() {
+ if (!fStream) {
+ // Some codecs do not have a stream, but they hold others that do. They
+ // must handle rewinding themselves.
+ return true;
+ }
+
// Store the value of fNeedsRewind so we can update it. Next read will
// require a rewind.
const bool needsRewind = fNeedsRewind;
@@ -138,6 +144,10 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
}
}
+ if (!this->rewindIfNeeded()) {
+ return kCouldNotRewind;
+ }
+
// Default options.
Options optsStorage;
if (nullptr == options) {
@@ -172,6 +182,10 @@ SkCodec::Result SkCodec::startScanlineDecode(const SkImageInfo& dstInfo,
ctable = nullptr;
}
+ if (!this->rewindIfNeeded()) {
+ return kCouldNotRewind;
+ }
+
// Set options.
Options optsStorage;
if (nullptr == options) {
« no previous file with comments | « src/codec/SkBmpStandardCodec.cpp ('k') | src/codec/SkCodec_libgif.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698