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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_libwebp.cpp ('k') | src/images/SkJpegUtility.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkImageRef.h" 8 #include "SkImageRef.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkFlattenableBuffers.h" 10 #include "SkFlattenableBuffers.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 if (NULL != fBitmap.getPixels() || 102 if (NULL != fBitmap.getPixels() ||
103 (SkBitmap::kNo_Config != fBitmap.config() && 103 (SkBitmap::kNo_Config != fBitmap.config() &&
104 SkImageDecoder::kDecodeBounds_Mode == mode)) { 104 SkImageDecoder::kDecodeBounds_Mode == mode)) {
105 return true; 105 return true;
106 } 106 }
107 107
108 SkASSERT(fBitmap.getPixels() == NULL); 108 SkASSERT(fBitmap.getPixels() == NULL);
109 109
110 fStream->rewind(); 110 if (!fStream->rewind()) {
111 SkDEBUGF(("Failed to rewind SkImageRef stream!"));
112 return false;
113 }
111 114
112 SkImageDecoder* codec; 115 SkImageDecoder* codec;
113 if (fFactory) { 116 if (fFactory) {
114 codec = fFactory->newDecoder(fStream); 117 codec = fFactory->newDecoder(fStream);
115 } else { 118 } else {
116 codec = SkImageDecoder::Factory(fStream); 119 codec = SkImageDecoder::Factory(fStream);
117 } 120 }
118 121
119 if (codec) { 122 if (codec) {
120 SkAutoTDelete<SkImageDecoder> ad(codec); 123 SkAutoTDelete<SkImageDecoder> ad(codec);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 fPrev = fNext = NULL; 180 fPrev = fNext = NULL;
178 fFactory = NULL; 181 fFactory = NULL;
179 } 182 }
180 183
181 void SkImageRef::flatten(SkFlattenableWriteBuffer& buffer) const { 184 void SkImageRef::flatten(SkFlattenableWriteBuffer& buffer) const {
182 this->INHERITED::flatten(buffer); 185 this->INHERITED::flatten(buffer);
183 186
184 buffer.writeUInt(fConfig); 187 buffer.writeUInt(fConfig);
185 buffer.writeInt(fSampleSize); 188 buffer.writeInt(fSampleSize);
186 buffer.writeBool(fDoDither); 189 buffer.writeBool(fDoDither);
187 fStream->rewind(); 190 // FIXME: Consider moving this logic should go into writeStream itself.
188 buffer.writeStream(fStream, fStream->getLength()); 191 // writeStream currently has no other callers, so this may be fine for
192 // now.
193 if (!fStream->rewind()) {
194 SkDEBUGF(("Failed to rewind SkImageRef stream!"));
195 buffer.write32(0);
196 } else {
197 // FIXME: Handle getLength properly here. Perhaps this class should
198 // take an SkStreamAsset.
199 buffer.writeStream(fStream, fStream->getLength());
200 }
189 } 201 }
OLDNEW
« 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