| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return false; | 166 return false; |
| 167 } | 167 } |
| 168 decoder->setDitherImage(fDitherImage); | 168 decoder->setDitherImage(fDitherImage); |
| 169 decoder->setSampleSize(fSampleSize); | 169 decoder->setSampleSize(fSampleSize); |
| 170 decoder->setRequireUnpremultipliedColors( | 170 decoder->setRequireUnpremultipliedColors( |
| 171 info.fAlphaType == kUnpremul_SkAlphaType); | 171 info.fAlphaType == kUnpremul_SkAlphaType); |
| 172 | 172 |
| 173 SkBitmap bitmap; | 173 SkBitmap bitmap; |
| 174 TargetAllocator allocator(fInfo, pixels, rowBytes); | 174 TargetAllocator allocator(fInfo, pixels, rowBytes); |
| 175 decoder->setAllocator(&allocator); | 175 decoder->setAllocator(&allocator); |
| 176 // TODO: need to be able to pass colortype directly to decoder | 176 bool success = decoder->decode(fStream, &bitmap, info.colorType(), |
| 177 SkBitmap::Config legacyConfig = SkColorTypeToBitmapConfig(info.colorType()); | |
| 178 bool success = decoder->decode(fStream, &bitmap, legacyConfig, | |
| 179 SkImageDecoder::kDecodePixels_Mode); | 177 SkImageDecoder::kDecodePixels_Mode); |
| 180 decoder->setAllocator(NULL); | 178 decoder->setAllocator(NULL); |
| 181 if (!success) { | 179 if (!success) { |
| 182 return false; | 180 return false; |
| 183 } | 181 } |
| 184 if (allocator.isReady()) { // Did not use pixels! | 182 if (allocator.isReady()) { // Did not use pixels! |
| 185 SkBitmap bm; | 183 SkBitmap bm; |
| 186 SkASSERT(bitmap.canCopyTo(info.colorType())); | 184 SkASSERT(bitmap.canCopyTo(info.colorType())); |
| 187 bool copySuccess = bitmap.copyTo(&bm, info.colorType(), &allocator); | 185 bool copySuccess = bitmap.copyTo(&bm, info.colorType(), &allocator); |
| 188 if (!copySuccess || allocator.isReady()) { | 186 if (!copySuccess || allocator.isReady()) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 SkStreamRewindable* stream, | 272 SkStreamRewindable* stream, |
| 275 const SkDecodingImageGenerator::Options& opts) { | 273 const SkDecodingImageGenerator::Options& opts) { |
| 276 SkASSERT(stream != NULL); | 274 SkASSERT(stream != NULL); |
| 277 SkASSERT(stream->unique()); | 275 SkASSERT(stream->unique()); |
| 278 if ((stream == NULL) || !stream->unique()) { | 276 if ((stream == NULL) || !stream->unique()) { |
| 279 SkSafeUnref(stream); | 277 SkSafeUnref(stream); |
| 280 return NULL; | 278 return NULL; |
| 281 } | 279 } |
| 282 return CreateDecodingImageGenerator(NULL, stream, opts); | 280 return CreateDecodingImageGenerator(NULL, stream, opts); |
| 283 } | 281 } |
| OLD | NEW |