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

Unified Diff: src/codec/SkJpegCodec.cpp

Issue 1288483002: Consolidate SkCodec functions for handling rewind (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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
Index: src/codec/SkJpegCodec.cpp
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index e160f0c4e29a124aa09b03fcb6fd8dea37f57b0e..a0b3f520a80cc72b13511233281851020067f37b 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -189,28 +189,14 @@ SkISize SkJpegCodec::onGetScaledDimensions(float desiredScale) const {
return SkISize::Make(dinfo.output_width, dinfo.output_height);
}
-/*
- * Handles rewinding the input stream if it is necessary
- */
-bool SkJpegCodec::handleRewind() {
- switch(this->rewindIfNeeded()) {
- case kCouldNotRewind_RewindState:
- return fDecoderMgr->returnFalse("could not rewind");
- case kRewound_RewindState: {
- JpegDecoderMgr* decoderMgr = NULL;
- if (!ReadHeader(this->stream(), NULL, &decoderMgr)) {
- return fDecoderMgr->returnFalse("could not rewind");
- }
- SkASSERT(NULL != decoderMgr);
- fDecoderMgr.reset(decoderMgr);
- return true;
- }
- case kNoRewindNecessary_RewindState:
- return true;
- default:
- SkASSERT(false);
- return false;
+bool SkJpegCodec::onRewind() {
+ JpegDecoderMgr* decoderMgr = NULL;
+ if (!ReadHeader(this->stream(), NULL, &decoderMgr)) {
+ return fDecoderMgr->returnFalse("could not rewind");
}
+ SkASSERT(NULL != decoderMgr);
+ fDecoderMgr.reset(decoderMgr);
+ return true;
}
/*
@@ -304,7 +290,7 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
void* dst, size_t dstRowBytes,
const Options& options, SkPMColor*, int*) {
// Rewind the stream if needed
- if (!this->handleRewind()) {
+ if (!this->rewindIfNeeded()) {
return fDecoderMgr->returnFailure("could not rewind stream", kCouldNotRewind);
}
@@ -399,7 +385,7 @@ public:
SkPMColor ctable[], int* ctableCount) override {
// Rewind the stream if needed
- if (!fCodec->handleRewind()) {
+ if (!fCodec->rewindIfNeeded()) {
return SkCodec::kCouldNotRewind;
}
« src/codec/SkBmpCodec.h ('K') | « src/codec/SkJpegCodec.h ('k') | src/codec/SkWebpCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698