Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: src/codec/SkCodec_libpng.cpp

Issue 1242423002: Remove png_read_end from SkPngScanlineDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698