OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkCodec_libpng.h" | 8 #include "SkCodec_libpng.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkColorTable.h" | 10 #include "SkColorTable.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 return false; | 359 return false; |
360 } | 360 } |
361 if (A.alphaType() == B.alphaType()) { | 361 if (A.alphaType() == B.alphaType()) { |
362 return true; | 362 return true; |
363 } | 363 } |
364 return premul_and_unpremul(A.alphaType(), B.alphaType()) | 364 return premul_and_unpremul(A.alphaType(), B.alphaType()) |
365 || premul_and_unpremul(B.alphaType(), A.alphaType()); | 365 || premul_and_unpremul(B.alphaType(), A.alphaType()); |
366 } | 366 } |
367 | 367 |
368 SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void*
dst, | 368 SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void*
dst, |
369 size_t rowBytes, SkPMColor ctable[], | 369 size_t rowBytes, const Options& options, |
370 int* ctableCount) { | 370 SkPMColor ctable[], int* ctableCount) { |
371 if (!this->rewindIfNeeded()) { | 371 if (!this->rewindIfNeeded()) { |
372 return kCouldNotRewind; | 372 return kCouldNotRewind; |
373 } | 373 } |
374 if (requestedInfo.dimensions() != this->getOriginalInfo().dimensions()) { | 374 if (requestedInfo.dimensions() != this->getOriginalInfo().dimensions()) { |
375 return kInvalidScale; | 375 return kInvalidScale; |
376 } | 376 } |
377 if (!conversion_possible(requestedInfo, this->getOriginalInfo())) { | 377 if (!conversion_possible(requestedInfo, this->getOriginalInfo())) { |
378 return kInvalidConversion; | 378 return kInvalidConversion; |
379 } | 379 } |
380 | 380 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // Note: we check the destination, since otherwise we would have | 426 // Note: we check the destination, since otherwise we would have |
427 // told png to upscale. | 427 // told png to upscale. |
428 SkASSERT(PNG_COLOR_TYPE_GRAY == pngColorType); | 428 SkASSERT(PNG_COLOR_TYPE_GRAY == pngColorType); |
429 sc = SkSwizzler::kGray; | 429 sc = SkSwizzler::kGray; |
430 } else if (this->getOriginalInfo().alphaType() == kOpaque_SkAlphaType) { | 430 } else if (this->getOriginalInfo().alphaType() == kOpaque_SkAlphaType) { |
431 sc = SkSwizzler::kRGBX; | 431 sc = SkSwizzler::kRGBX; |
432 } else { | 432 } else { |
433 sc = SkSwizzler::kRGBA; | 433 sc = SkSwizzler::kRGBA; |
434 } | 434 } |
435 const SkPMColor* colors = colorTable ? colorTable->readColors() : NULL; | 435 const SkPMColor* colors = colorTable ? colorTable->readColors() : NULL; |
436 // TODO: Support skipZeroes. | |
437 swizzler.reset(SkSwizzler::CreateSwizzler(sc, colors, requestedInfo, | 436 swizzler.reset(SkSwizzler::CreateSwizzler(sc, colors, requestedInfo, |
438 dst, rowBytes, false)); | 437 dst, rowBytes, |
| 438 options.fZeroInitialized)); |
439 if (!swizzler) { | 439 if (!swizzler) { |
440 // FIXME: CreateSwizzler could fail for another reason. | 440 // FIXME: CreateSwizzler could fail for another reason. |
441 return kUnimplemented; | 441 return kUnimplemented; |
442 } | 442 } |
443 | 443 |
444 // FIXME: Here is where we should likely insert some of the modifications | 444 // FIXME: Here is where we should likely insert some of the modifications |
445 // made in the factory. | 445 // made in the factory. |
446 png_read_update_info(fPng_ptr, fInfo_ptr); | 446 png_read_update_info(fPng_ptr, fInfo_ptr); |
447 | 447 |
448 if (numberPasses > 1) { | 448 if (numberPasses > 1) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 483 |
484 // FIXME: do we need substituteTranspColor? | 484 // FIXME: do we need substituteTranspColor? |
485 | 485 |
486 if (reallyHasAlpha && requestedInfo.alphaType() != kOpaque_SkAlphaType) { | 486 if (reallyHasAlpha && requestedInfo.alphaType() != kOpaque_SkAlphaType) { |
487 // FIXME: We want to alert the caller. Is this the right way? | 487 // FIXME: We want to alert the caller. Is this the right way? |
488 SkImageInfo* modInfo = const_cast<SkImageInfo*>(&requestedInfo); | 488 SkImageInfo* modInfo = const_cast<SkImageInfo*>(&requestedInfo); |
489 *modInfo = requestedInfo.makeAlphaType(kOpaque_SkAlphaType); | 489 *modInfo = requestedInfo.makeAlphaType(kOpaque_SkAlphaType); |
490 } | 490 } |
491 return kSuccess; | 491 return kSuccess; |
492 } | 492 } |
OLD | NEW |