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

Unified Diff: include/codec/SkCodec.h

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
« no previous file with comments | « no previous file | src/codec/SkBmpCodec.h » ('j') | src/codec/SkBmpCodec.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/codec/SkCodec.h
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index ce581632e158e3ec55e266b5d7a221c889987b89..a0bd18a8e59cb3fda66531c10b2aca71e35addbd 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -233,26 +233,27 @@ protected:
virtual bool onReallyHasAlpha() const { return false; }
- enum RewindState {
- kRewound_RewindState,
- kNoRewindNecessary_RewindState,
- kCouldNotRewind_RewindState
- };
/**
* If the stream was previously read, attempt to rewind.
- * @returns:
- * kRewound if the stream needed to be rewound, and the
- * rewind succeeded.
- * kNoRewindNecessary if the stream did not need to be
- * rewound.
- * kCouldNotRewind if the stream needed to be rewound, and
- * rewind failed.
+ *
+ * If the stream needed to be rewound, call onRewind.
+ * @returns true if the codec is at the right position and can be used.
+ * false if there was a failure to rewind.
*
* Subclasses MUST call this function before reading the stream (e.g. in
* onGetPixels). If it returns false, onGetPixels should return
* kCouldNotRewind.
*/
- RewindState SK_WARN_UNUSED_RESULT rewindIfNeeded();
+ bool SK_WARN_UNUSED_RESULT rewindIfNeeded();
+
+ /**
+ * Called by rewindIfNeeded, if the stream needed to be rewound.
+ *
+ * Subclasses should do any set up needed after a rewind.
+ */
+ virtual bool onRewind() {
+ return true;
+ }
/**
* Get method for the input stream
« no previous file with comments | « no previous file | src/codec/SkBmpCodec.h » ('j') | src/codec/SkBmpCodec.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698