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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
594 public: | 594 public: |
595 SkPngScanlineDecoder(const SkImageInfo& dstInfo, SkPngCodec* codec) | 595 SkPngScanlineDecoder(const SkImageInfo& dstInfo, SkPngCodec* codec) |
596 : INHERITED(dstInfo) | 596 : INHERITED(dstInfo) |
597 , fCodec(codec) | 597 , fCodec(codec) |
598 , fHasAlpha(false) | 598 , fHasAlpha(false) |
599 { | 599 { |
600 fStorage.reset(dstInfo.width() * SkSwizzler::BytesPerPixel(fCodec->fSrcC onfig)); | 600 fStorage.reset(dstInfo.width() * SkSwizzler::BytesPerPixel(fCodec->fSrcC onfig)); |
601 fSrcRow = static_cast<uint8_t*>(fStorage.get()); | 601 fSrcRow = static_cast<uint8_t*>(fStorage.get()); |
602 } | 602 } |
603 | 603 |
604 ~SkPngScanlineDecoder() { | 604 ~SkPngScanlineDecoder() {} |
scroggo
2015/07/20 20:07:25
nit: I think you can remove this line completely,
| |
605 fCodec->finish(); | |
606 } | |
607 | 605 |
608 SkCodec::Result onGetScanlines(void* dst, int count, size_t rowBytes) overri de { | 606 SkCodec::Result onGetScanlines(void* dst, int count, size_t rowBytes) overri de { |
609 if (setjmp(png_jmpbuf(fCodec->fPng_ptr))) { | 607 if (setjmp(png_jmpbuf(fCodec->fPng_ptr))) { |
610 SkCodecPrintf("setjmp long jump!\n"); | 608 SkCodecPrintf("setjmp long jump!\n"); |
611 return SkCodec::kInvalidInput; | 609 return SkCodec::kInvalidInput; |
612 } | 610 } |
613 | 611 |
614 for (int i = 0; i < count; i++) { | 612 for (int i = 0; i < count; i++) { |
615 png_read_rows(fCodec->fPng_ptr, &fSrcRow, png_bytepp_NULL, 1); | 613 png_read_rows(fCodec->fPng_ptr, &fSrcRow, png_bytepp_NULL, 1); |
616 fCodec->fSwizzler->setDstRow(dst); | 614 fCodec->fSwizzler->setDstRow(dst); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 , fCodec(codec) | 653 , fCodec(codec) |
656 , fHasAlpha(false) | 654 , fHasAlpha(false) |
657 , fCurrentRow(0) | 655 , fCurrentRow(0) |
658 , fHeight(dstInfo.height()) | 656 , fHeight(dstInfo.height()) |
659 { | 657 { |
660 fSrcRowBytes = dstInfo.width() * SkSwizzler::BytesPerPixel(fCodec->fSrcC onfig); | 658 fSrcRowBytes = dstInfo.width() * SkSwizzler::BytesPerPixel(fCodec->fSrcC onfig); |
661 fGarbageRow.reset(fSrcRowBytes); | 659 fGarbageRow.reset(fSrcRowBytes); |
662 fGarbageRowPtr = static_cast<uint8_t*>(fGarbageRow.get()); | 660 fGarbageRowPtr = static_cast<uint8_t*>(fGarbageRow.get()); |
663 } | 661 } |
664 | 662 |
665 ~SkPngInterlacedScanlineDecoder() { | 663 ~SkPngInterlacedScanlineDecoder() {} |
scroggo
2015/07/20 20:07:25
Again, I *think* the compiler will generate the sa
| |
666 fCodec->finish(); | |
667 } | |
668 | 664 |
669 SkCodec::Result onGetScanlines(void* dst, int count, size_t dstRowBytes) ove rride { | 665 SkCodec::Result onGetScanlines(void* dst, int count, size_t dstRowBytes) ove rride { |
670 //rewind stream if have previously called onGetScanlines, | 666 //rewind stream if have previously called onGetScanlines, |
671 //since we need entire progressive image to get scanlines | 667 //since we need entire progressive image to get scanlines |
672 if (!fCodec->handleRewind()) { | 668 if (!fCodec->handleRewind()) { |
673 return SkCodec::kCouldNotRewind; | 669 return SkCodec::kCouldNotRewind; |
674 } | 670 } |
675 if (setjmp(png_jmpbuf(fCodec->fPng_ptr))) { | 671 if (setjmp(png_jmpbuf(fCodec->fPng_ptr))) { |
676 SkCodecPrintf("setjmp long jump!\n"); | 672 SkCodecPrintf("setjmp long jump!\n"); |
677 return SkCodec::kInvalidInput; | 673 return SkCodec::kInvalidInput; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
760 | 756 |
761 SkASSERT(codec->fNumberPasses != INVALID_NUMBER_PASSES); | 757 SkASSERT(codec->fNumberPasses != INVALID_NUMBER_PASSES); |
762 if (codec->fNumberPasses > 1) { | 758 if (codec->fNumberPasses > 1) { |
763 // interlaced image | 759 // interlaced image |
764 return SkNEW_ARGS(SkPngInterlacedScanlineDecoder, (dstInfo, codec.detach ())); | 760 return SkNEW_ARGS(SkPngInterlacedScanlineDecoder, (dstInfo, codec.detach ())); |
765 } | 761 } |
766 | 762 |
767 return SkNEW_ARGS(SkPngScanlineDecoder, (dstInfo, codec.detach())); | 763 return SkNEW_ARGS(SkPngScanlineDecoder, (dstInfo, codec.detach())); |
768 } | 764 } |
769 | 765 |
OLD | NEW |