| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |