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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 return SkImageGenerator::kSuccess; | 617 return SkImageGenerator::kSuccess; |
618 } | 618 } |
619 | 619 |
620 SkImageGenerator::Result onSkipScanlines(int count) override { | 620 SkImageGenerator::Result onSkipScanlines(int count) override { |
621 // FIXME: Could we use the return value of setjmp to specify the type of | 621 // FIXME: Could we use the return value of setjmp to specify the type of |
622 // error? | 622 // error? |
623 if (setjmp(png_jmpbuf(fCodec->fPng_ptr))) { | 623 if (setjmp(png_jmpbuf(fCodec->fPng_ptr))) { |
624 SkCodecPrintf("setjmp long jump!\n"); | 624 SkCodecPrintf("setjmp long jump!\n"); |
625 return SkImageGenerator::kInvalidInput; | 625 return SkImageGenerator::kInvalidInput; |
626 } | 626 } |
627 | 627 //there is a potential tradeoff of memory vs speed created by putting th
is in a loop. |
628 png_read_rows(fCodec->fPng_ptr, png_bytepp_NULL, png_bytepp_NULL, count)
; | 628 //calling png_read_rows in a loop is insignificantly slower than calling
it once with count |
| 629 //as png_read_rows has it's own loop which calls png_read_row count time
s. |
| 630 for (int i = 0; i < count; i++) { |
| 631 png_read_rows(fCodec->fPng_ptr, &fSrcRow, png_bytepp_NULL, 1); |
| 632 } |
629 return SkImageGenerator::kSuccess; | 633 return SkImageGenerator::kSuccess; |
630 } | 634 } |
631 | 635 |
632 void onFinish() override { | 636 void onFinish() override { |
633 fCodec->finish(); | 637 fCodec->finish(); |
634 } | 638 } |
635 | 639 |
636 bool onReallyHasAlpha() const override { return fHasAlpha; } | 640 bool onReallyHasAlpha() const override { return fHasAlpha; } |
637 | 641 |
638 private: | 642 private: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 | 675 |
672 SkASSERT(fNumberPasses != INVALID_NUMBER_PASSES); | 676 SkASSERT(fNumberPasses != INVALID_NUMBER_PASSES); |
673 if (fNumberPasses > 1) { | 677 if (fNumberPasses > 1) { |
674 // We cannot efficiently do scanline decoding. | 678 // We cannot efficiently do scanline decoding. |
675 return NULL; | 679 return NULL; |
676 } | 680 } |
677 | 681 |
678 return SkNEW_ARGS(SkPngScanlineDecoder, (dstInfo, this)); | 682 return SkNEW_ARGS(SkPngScanlineDecoder, (dstInfo, this)); |
679 } | 683 } |
680 | 684 |
OLD | NEW |