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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 if (!bitmap.canCopyTo(opts.fRequestedColorType)) { | 239 if (!bitmap.canCopyTo(opts.fRequestedColorType)) { |
240 SkASSERT(bitmap.colorType() != opts.fRequestedColorType); | 240 SkASSERT(bitmap.colorType() != opts.fRequestedColorType); |
241 return NULL; // Can not translate to needed config. | 241 return NULL; // Can not translate to needed config. |
242 } | 242 } |
243 info.fColorType = opts.fRequestedColorType; | 243 info.fColorType = opts.fRequestedColorType; |
244 } | 244 } |
245 | 245 |
246 if (opts.fRequireUnpremul && info.fAlphaType != kOpaque_SkAlphaType) { | 246 if (opts.fRequireUnpremul && info.fAlphaType != kOpaque_SkAlphaType) { |
247 info.fAlphaType = kUnpremul_SkAlphaType; | 247 info.fAlphaType = kUnpremul_SkAlphaType; |
248 } | 248 } |
| 249 |
| 250 if (!SkColorTypeValidateAlphaType(info.fColorType, info.fAlphaType, &info.fA
lphaType)) { |
| 251 return NULL; |
| 252 } |
| 253 |
249 return SkNEW_ARGS(DecodingImageGenerator, | 254 return SkNEW_ARGS(DecodingImageGenerator, |
250 (data, autoStream.detach(), info, | 255 (data, autoStream.detach(), info, |
251 opts.fSampleSize, opts.fDitherImage)); | 256 opts.fSampleSize, opts.fDitherImage)); |
252 } | 257 } |
253 | 258 |
254 } // namespace | 259 } // namespace |
255 | 260 |
256 //////////////////////////////////////////////////////////////////////////////// | 261 //////////////////////////////////////////////////////////////////////////////// |
257 | 262 |
258 SkImageGenerator* SkDecodingImageGenerator::Create( | 263 SkImageGenerator* SkDecodingImageGenerator::Create( |
(...skipping 13 matching lines...) Expand all Loading... |
272 SkStreamRewindable* stream, | 277 SkStreamRewindable* stream, |
273 const SkDecodingImageGenerator::Options& opts) { | 278 const SkDecodingImageGenerator::Options& opts) { |
274 SkASSERT(stream != NULL); | 279 SkASSERT(stream != NULL); |
275 SkASSERT(stream->unique()); | 280 SkASSERT(stream->unique()); |
276 if ((stream == NULL) || !stream->unique()) { | 281 if ((stream == NULL) || !stream->unique()) { |
277 SkSafeUnref(stream); | 282 SkSafeUnref(stream); |
278 return NULL; | 283 return NULL; |
279 } | 284 } |
280 return CreateDecodingImageGenerator(NULL, stream, opts); | 285 return CreateDecodingImageGenerator(NULL, stream, opts); |
281 } | 286 } |
OLD | NEW |