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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 if (!conversion_possible(requestedInfo, this->getInfo())) { | 470 if (!conversion_possible(requestedInfo, this->getInfo())) { |
471 return kInvalidConversion; | 471 return kInvalidConversion; |
472 } | 472 } |
473 if (options.fSubset) { | 473 if (options.fSubset) { |
474 // Subsets are not supported. | 474 // Subsets are not supported. |
475 return kUnimplemented; | 475 return kUnimplemented; |
476 } | 476 } |
477 if (requestedInfo.dimensions() != this->getInfo().dimensions()) { | 477 if (requestedInfo.dimensions() != this->getInfo().dimensions()) { |
478 return kInvalidScale; | 478 return kInvalidScale; |
479 } | 479 } |
480 if (!this->rewindIfNeeded()) { | |
481 return kCouldNotRewind; | |
482 } | |
483 | 480 |
484 // Note that ctable and ctableCount may be modified if there is a color tabl
e | 481 // Note that ctable and ctableCount may be modified if there is a color tabl
e |
485 const Result result = this->initializeSwizzler(requestedInfo, options, | 482 const Result result = this->initializeSwizzler(requestedInfo, options, |
486 ctable, ctableCount); | 483 ctable, ctableCount); |
487 if (result != kSuccess) { | 484 if (result != kSuccess) { |
488 return result; | 485 return result; |
489 } | 486 } |
490 // FIXME: Could we use the return value of setjmp to specify the type of | 487 // FIXME: Could we use the return value of setjmp to specify the type of |
491 // error? | 488 // error? |
492 if (setjmp(png_jmpbuf(fPng_ptr))) { | 489 if (setjmp(png_jmpbuf(fPng_ptr))) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 public: | 582 public: |
586 SkPngScanlineDecoder(const SkImageInfo& srcInfo, SkStream* stream, | 583 SkPngScanlineDecoder(const SkImageInfo& srcInfo, SkStream* stream, |
587 png_structp png_ptr, png_infop info_ptr, int bitDepth) | 584 png_structp png_ptr, png_infop info_ptr, int bitDepth) |
588 : INHERITED(srcInfo, stream, png_ptr, info_ptr, bitDepth, 1) | 585 : INHERITED(srcInfo, stream, png_ptr, info_ptr, bitDepth, 1) |
589 , fSrcRow(nullptr) | 586 , fSrcRow(nullptr) |
590 , fAlphaState(kUnknown_AlphaState) | 587 , fAlphaState(kUnknown_AlphaState) |
591 {} | 588 {} |
592 | 589 |
593 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti
ons, | 590 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti
ons, |
594 SkPMColor ctable[], int* ctableCount) override { | 591 SkPMColor ctable[], int* ctableCount) override { |
595 if (!this->rewindIfNeeded()) { | |
596 return kCouldNotRewind; | |
597 } | |
598 | |
599 if (!conversion_possible(dstInfo, this->getInfo())) { | 592 if (!conversion_possible(dstInfo, this->getInfo())) { |
600 return kInvalidConversion; | 593 return kInvalidConversion; |
601 } | 594 } |
602 | 595 |
603 // Check to see if scaling was requested. | 596 // Check to see if scaling was requested. |
604 if (dstInfo.dimensions() != this->getInfo().dimensions()) { | 597 if (dstInfo.dimensions() != this->getInfo().dimensions()) { |
605 if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(),
dstInfo)) { | 598 if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(),
dstInfo)) { |
606 return kInvalidScale; | 599 return kInvalidScale; |
607 } | 600 } |
608 } | 601 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 , fAlphaState(kUnknown_AlphaState) | 676 , fAlphaState(kUnknown_AlphaState) |
684 , fHeight(-1) | 677 , fHeight(-1) |
685 , fCanSkipRewind(false) | 678 , fCanSkipRewind(false) |
686 { | 679 { |
687 SkASSERT(numberPasses != 1); | 680 SkASSERT(numberPasses != 1); |
688 } | 681 } |
689 | 682 |
690 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti
ons, | 683 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti
ons, |
691 SkPMColor ctable[], int* ctableCount) override | 684 SkPMColor ctable[], int* ctableCount) override |
692 { | 685 { |
693 if (!this->rewindIfNeeded()) { | |
694 return kCouldNotRewind; | |
695 } | |
696 | |
697 if (!conversion_possible(dstInfo, this->getInfo())) { | 686 if (!conversion_possible(dstInfo, this->getInfo())) { |
698 return kInvalidConversion; | 687 return kInvalidConversion; |
699 } | 688 } |
700 | 689 |
701 // Check to see if scaling was requested. | 690 // Check to see if scaling was requested. |
702 if (dstInfo.dimensions() != this->getInfo().dimensions()) { | 691 if (dstInfo.dimensions() != this->getInfo().dimensions()) { |
703 if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(),
dstInfo)) { | 692 if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(),
dstInfo)) { |
704 return kInvalidScale; | 693 return kInvalidScale; |
705 } | 694 } |
706 } | 695 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 | 826 |
838 if (1 == numberPasses) { | 827 if (1 == numberPasses) { |
839 return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), png_p
tr, info_ptr, | 828 return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), png_p
tr, info_ptr, |
840 bitDepth); | 829 bitDepth); |
841 } | 830 } |
842 | 831 |
843 return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(),
png_ptr, | 832 return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(),
png_ptr, |
844 info_ptr, bitDepth, numberPasses); | 833 info_ptr, bitDepth, numberPasses); |
845 } | 834 } |
846 | 835 |
OLD | NEW |