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

Side by Side Diff: src/images/SkDecodingImageGenerator.cpp

Issue 647023006: Qualify the return value of SkImageDecoder::decode (Closed) Base URL: https://skia.googlesource.com/skia.git/+/master
Patch Set: fix a sample Created 6 years, 2 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
« no previous file with comments | « samplecode/SampleUnpremul.cpp ('k') | src/images/SkImageDecoder.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 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkData.h" 8 #include "SkData.h"
9 #include "SkDecodingImageGenerator.h" 9 #include "SkDecodingImageGenerator.h"
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return false; 164 return false;
165 } 165 }
166 decoder->setDitherImage(fDitherImage); 166 decoder->setDitherImage(fDitherImage);
167 decoder->setSampleSize(fSampleSize); 167 decoder->setSampleSize(fSampleSize);
168 decoder->setRequireUnpremultipliedColors(info.alphaType() == kUnpremul_SkAlp haType); 168 decoder->setRequireUnpremultipliedColors(info.alphaType() == kUnpremul_SkAlp haType);
169 169
170 SkBitmap bitmap; 170 SkBitmap bitmap;
171 TargetAllocator allocator(fInfo, pixels, rowBytes); 171 TargetAllocator allocator(fInfo, pixels, rowBytes);
172 decoder->setAllocator(&allocator); 172 decoder->setAllocator(&allocator);
173 bool success = decoder->decode(fStream, &bitmap, info.colorType(), 173 bool success = decoder->decode(fStream, &bitmap, info.colorType(),
174 SkImageDecoder::kDecodePixels_Mode); 174 SkImageDecoder::kDecodePixels_Mode) != SkImag eDecoder::kFailure;
175 decoder->setAllocator(NULL); 175 decoder->setAllocator(NULL);
176 if (!success) { 176 if (!success) {
177 return false; 177 return false;
178 } 178 }
179 if (allocator.isReady()) { // Did not use pixels! 179 if (allocator.isReady()) { // Did not use pixels!
180 SkBitmap bm; 180 SkBitmap bm;
181 SkASSERT(bitmap.canCopyTo(info.colorType())); 181 SkASSERT(bitmap.canCopyTo(info.colorType()));
182 bool copySuccess = bitmap.copyTo(&bm, info.colorType(), &allocator); 182 bool copySuccess = bitmap.copyTo(&bm, info.colorType(), &allocator);
183 if (!copySuccess || allocator.isReady()) { 183 if (!copySuccess || allocator.isReady()) {
184 SkDEBUGFAIL("bitmap.copyTo(requestedConfig) failed."); 184 SkDEBUGFAIL("bitmap.copyTo(requestedConfig) failed.");
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 SkStreamRewindable* stream, 289 SkStreamRewindable* stream,
290 const SkDecodingImageGenerator::Options& opts) { 290 const SkDecodingImageGenerator::Options& opts) {
291 SkASSERT(stream != NULL); 291 SkASSERT(stream != NULL);
292 SkASSERT(stream->unique()); 292 SkASSERT(stream->unique());
293 if ((stream == NULL) || !stream->unique()) { 293 if ((stream == NULL) || !stream->unique()) {
294 SkSafeUnref(stream); 294 SkSafeUnref(stream);
295 return NULL; 295 return NULL;
296 } 296 }
297 return CreateDecodingImageGenerator(NULL, stream, opts); 297 return CreateDecodingImageGenerator(NULL, stream, opts);
298 } 298 }
OLDNEW
« no previous file with comments | « samplecode/SampleUnpremul.cpp ('k') | src/images/SkImageDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698