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 "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 } | 507 } |
508 default: | 508 default: |
509 SkASSERT(false); | 509 SkASSERT(false); |
510 return false; | 510 return false; |
511 } | 511 } |
512 } | 512 } |
513 | 513 |
514 SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void* dst, | 514 SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void* dst, |
515 size_t rowBytes, const Options& options, | 515 size_t rowBytes, const Options& options, |
516 SkPMColor ctable[], int* ctableCount) { | 516 SkPMColor ctable[], int* ctableCount) { |
517 // Do not allow a regular decode if the caller has asked for a scanline deco der | |
518 if (NULL != this->scanlineDecoder()) { | |
519 SkCodecPrintf("cannot getPixels() if a scanline decoder has been created \n"); | |
520 return kInvalidInput; | |
scroggo
2015/06/30 14:50:17
This is intended to mean that the encoded data is
msarett
2015/06/30 20:43:05
I agree, InvalidParameters makes more sense.
| |
521 } | |
522 | |
517 if (!this->handleRewind()) { | 523 if (!this->handleRewind()) { |
518 return kCouldNotRewind; | 524 return kCouldNotRewind; |
519 } | 525 } |
520 if (requestedInfo.dimensions() != this->getInfo().dimensions()) { | 526 if (requestedInfo.dimensions() != this->getInfo().dimensions()) { |
521 return kInvalidScale; | 527 return kInvalidScale; |
522 } | 528 } |
523 if (!conversion_possible(requestedInfo, this->getInfo())) { | 529 if (!conversion_possible(requestedInfo, this->getInfo())) { |
524 return kInvalidConversion; | 530 return kInvalidConversion; |
525 } | 531 } |
526 | 532 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 bool fHasAlpha; | 733 bool fHasAlpha; |
728 int fCurrentRow; | 734 int fCurrentRow; |
729 int fHeight; | 735 int fHeight; |
730 size_t fSrcRowBytes; | 736 size_t fSrcRowBytes; |
731 bool fRewindNeeded; | 737 bool fRewindNeeded; |
732 SkAutoMalloc fGarbageRow; | 738 SkAutoMalloc fGarbageRow; |
733 uint8_t* fGarbageRowPtr; | 739 uint8_t* fGarbageRowPtr; |
734 | 740 |
735 | 741 |
736 | 742 |
737 | |
738 | 743 |
744 | |
739 typedef SkScanlineDecoder INHERITED; | 745 typedef SkScanlineDecoder INHERITED; |
740 }; | 746 }; |
741 | 747 |
742 | 748 |
743 SkScanlineDecoder* SkPngCodec::onGetScanlineDecoder(const SkImageInfo& dstInfo, | 749 SkScanlineDecoder* SkPngCodec::onGetScanlineDecoder(const SkImageInfo& dstInfo, |
744 const Options& options, SkPMColor ctable[], int* ctableCount) { | 750 const Options& options, SkPMColor ctable[], int* ctableCount) { |
745 if (!this->handleRewind()) { | 751 if (!this->handleRewind()) { |
746 return NULL; | 752 return NULL; |
747 } | 753 } |
748 | 754 |
(...skipping 18 matching lines...) Expand all Loading... | |
767 | 773 |
768 SkASSERT(fNumberPasses != INVALID_NUMBER_PASSES); | 774 SkASSERT(fNumberPasses != INVALID_NUMBER_PASSES); |
769 if (fNumberPasses > 1) { | 775 if (fNumberPasses > 1) { |
770 // interlaced image | 776 // interlaced image |
771 return SkNEW_ARGS(SkPngInterlacedScanlineDecoder, (dstInfo, this)); | 777 return SkNEW_ARGS(SkPngInterlacedScanlineDecoder, (dstInfo, this)); |
772 } | 778 } |
773 | 779 |
774 return SkNEW_ARGS(SkPngScanlineDecoder, (dstInfo, this)); | 780 return SkNEW_ARGS(SkPngScanlineDecoder, (dstInfo, this)); |
775 } | 781 } |
776 | 782 |
OLD | NEW |