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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 if (opts.fRequireUnpremul && info.alphaType() != kOpaque_SkAlphaType) { | 251 if (opts.fRequireUnpremul && info.alphaType() != kOpaque_SkAlphaType) { |
252 info = info.makeAlphaType(kUnpremul_SkAlphaType); | 252 info = info.makeAlphaType(kUnpremul_SkAlphaType); |
253 } | 253 } |
254 | 254 |
255 SkAlphaType newAlphaType = info.alphaType(); | 255 SkAlphaType newAlphaType = info.alphaType(); |
256 if (!SkColorTypeValidateAlphaType(info.colorType(), info.alphaType(), &newAl
phaType)) { | 256 if (!SkColorTypeValidateAlphaType(info.colorType(), info.alphaType(), &newAl
phaType)) { |
257 return NULL; | 257 return NULL; |
258 } | 258 } |
259 | 259 |
260 return SkNEW_ARGS(DecodingImageGenerator, | 260 return new DecodingImageGenerator(data, autoStream.detach(), info.makeAlphaT
ype(newAlphaType), |
261 (data, autoStream.detach(), info.makeAlphaType(newAlphaTyp
e), | 261 opts.fSampleSize, opts.fDitherImage); |
262 opts.fSampleSize, opts.fDitherImage)); | |
263 } | 262 } |
264 | 263 |
265 } // namespace | 264 } // namespace |
266 | 265 |
267 //////////////////////////////////////////////////////////////////////////////// | 266 //////////////////////////////////////////////////////////////////////////////// |
268 | 267 |
269 SkImageGenerator* SkDecodingImageGenerator::Create( | 268 SkImageGenerator* SkDecodingImageGenerator::Create( |
270 SkData* data, | 269 SkData* data, |
271 const SkDecodingImageGenerator::Options& opts) { | 270 const SkDecodingImageGenerator::Options& opts) { |
272 SkASSERT(data != NULL); | 271 SkASSERT(data != NULL); |
273 if (NULL == data) { | 272 if (NULL == data) { |
274 return NULL; | 273 return NULL; |
275 } | 274 } |
276 SkStreamRewindable* stream = SkNEW_ARGS(SkMemoryStream, (data)); | 275 SkStreamRewindable* stream = new SkMemoryStream(data); |
277 SkASSERT(stream != NULL); | 276 SkASSERT(stream != NULL); |
278 return CreateDecodingImageGenerator(data, stream, opts); | 277 return CreateDecodingImageGenerator(data, stream, opts); |
279 } | 278 } |
280 | 279 |
281 SkImageGenerator* SkDecodingImageGenerator::Create( | 280 SkImageGenerator* SkDecodingImageGenerator::Create( |
282 SkStreamRewindable* stream, | 281 SkStreamRewindable* stream, |
283 const SkDecodingImageGenerator::Options& opts) { | 282 const SkDecodingImageGenerator::Options& opts) { |
284 SkASSERT(stream != NULL); | 283 SkASSERT(stream != NULL); |
285 if (stream == NULL) { | 284 if (stream == NULL) { |
286 return NULL; | 285 return NULL; |
287 } | 286 } |
288 return CreateDecodingImageGenerator(NULL, stream, opts); | 287 return CreateDecodingImageGenerator(NULL, stream, opts); |
289 } | 288 } |
OLD | NEW |