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

Unified Diff: src/images/SkImageRef.cpp

Issue 22861028: Handle SkStream::rewind properly. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Another comment rewrite. Created 7 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 | « src/images/SkImageDecoder_libwebp.cpp ('k') | src/images/SkJpegUtility.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageRef.cpp
diff --git a/src/images/SkImageRef.cpp b/src/images/SkImageRef.cpp
index 299166c31ccc4a50c3a6402535c45abcab5ef44f..bd4a7393d9fc9a3a029ca6ee5d053ef2938571cf 100644
--- a/src/images/SkImageRef.cpp
+++ b/src/images/SkImageRef.cpp
@@ -107,7 +107,10 @@ bool SkImageRef::prepareBitmap(SkImageDecoder::Mode mode) {
SkASSERT(fBitmap.getPixels() == NULL);
- fStream->rewind();
+ if (!fStream->rewind()) {
+ SkDEBUGF(("Failed to rewind SkImageRef stream!"));
+ return false;
+ }
SkImageDecoder* codec;
if (fFactory) {
@@ -184,6 +187,15 @@ void SkImageRef::flatten(SkFlattenableWriteBuffer& buffer) const {
buffer.writeUInt(fConfig);
buffer.writeInt(fSampleSize);
buffer.writeBool(fDoDither);
- fStream->rewind();
- buffer.writeStream(fStream, fStream->getLength());
+ // FIXME: Consider moving this logic should go into writeStream itself.
+ // writeStream currently has no other callers, so this may be fine for
+ // now.
+ if (!fStream->rewind()) {
+ SkDEBUGF(("Failed to rewind SkImageRef stream!"));
+ buffer.write32(0);
+ } else {
+ // FIXME: Handle getLength properly here. Perhaps this class should
+ // take an SkStreamAsset.
+ buffer.writeStream(fStream, fStream->getLength());
+ }
}
« no previous file with comments | « src/images/SkImageDecoder_libwebp.cpp ('k') | src/images/SkJpegUtility.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698