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 #ifndef SkCodec_DEFINED | 8 #ifndef SkCodec_DEFINED |
9 #define SkCodec_DEFINED | 9 #define SkCodec_DEFINED |
10 | 10 |
11 #include "../private/SkTemplates.h" | 11 #include "../private/SkTemplates.h" |
12 #include "SkColor.h" | 12 #include "SkColor.h" |
13 #include "SkEncodedFormat.h" | 13 #include "SkEncodedFormat.h" |
14 #include "SkEncodedInfo.h" | 14 #include "SkEncodedInfo.h" |
15 #include "SkImageInfo.h" | 15 #include "SkImageInfo.h" |
16 #include "SkSize.h" | 16 #include "SkSize.h" |
17 #include "SkStream.h" | 17 #include "SkStream.h" |
18 #include "SkTypes.h" | 18 #include "SkTypes.h" |
19 #include "SkYUVSizeInfo.h" | 19 #include "SkYUVSizeInfo.h" |
20 | 20 |
21 #include <vector> | |
22 | |
21 class SkColorSpace; | 23 class SkColorSpace; |
22 class SkData; | 24 class SkData; |
23 class SkPngChunkReader; | 25 class SkPngChunkReader; |
24 class SkSampler; | 26 class SkSampler; |
25 | 27 |
26 namespace DM { | 28 namespace DM { |
27 class CodecSrc; | 29 class CodecSrc; |
28 class ColorCodecSrc; | 30 class ColorCodecSrc; |
29 } | 31 } |
30 class ColorCodecBench; | 32 class ColorCodecBench; |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 /** | 601 /** |
600 * Returns the output y-coordinate of the row that corresponds to an input | 602 * Returns the output y-coordinate of the row that corresponds to an input |
601 * y-coordinate. The input y-coordinate represents where the scanline | 603 * y-coordinate. The input y-coordinate represents where the scanline |
602 * is located in the encoded data. | 604 * is located in the encoded data. |
603 * | 605 * |
604 * This will equal inputScanline, except in the case of strangely | 606 * This will equal inputScanline, except in the case of strangely |
605 * encoded image types (bottom-up bmps, interlaced gifs). | 607 * encoded image types (bottom-up bmps, interlaced gifs). |
606 */ | 608 */ |
607 int outputScanline(int inputScanline) const; | 609 int outputScanline(int inputScanline) const; |
608 | 610 |
609 /** | |
610 * Return the number of frames in the image. | |
611 * | |
612 * May require reading through the stream to determine the number of | |
613 * frames. | |
614 * | |
615 * As such, future decoding calls may require a rewind. | |
616 */ | |
617 size_t getFrameCount() { | |
618 return this->onGetFrameCount(); | |
619 } | |
620 | |
621 // The required frame for an independent frame is marked as | 611 // The required frame for an independent frame is marked as |
622 // kIndependentFrame. | 612 // kIndependentFrame. |
623 static constexpr size_t kIndependentFrame = static_cast<size_t>(-1); | 613 static constexpr size_t kIndependentFrame = static_cast<size_t>(-1); |
624 | 614 |
625 /** | 615 /** |
626 * For a multiframed image, return the image that frame |index| needs to | 616 * Information about individual frames in a multi-framed image. |
627 * be blended with. | |
628 * | |
629 * If the frame needs no blending, return kIndependentFrame. | |
630 */ | 617 */ |
631 size_t getRequiredFrame(size_t index) { | 618 struct FrameInfo { |
632 return this->onGetRequiredFrame(index); | 619 /** |
633 } | 620 * The frame that this frame needs to be blended with, or |
621 * kIndependentFrame. | |
622 */ | |
623 size_t fRequiredFrame; | |
624 | |
625 /** | |
626 * Number of 1/100 seconds to show this frame. | |
627 */ | |
628 size_t fDuration; | |
629 }; | |
634 | 630 |
635 /** | 631 /** |
636 * For a multiframed image, return the number of 1/100 seconds to | 632 * Return info about the frames in the image. |
637 * show frame |index|. | 633 * |
634 * May require reading through the stream to determine the number of | |
635 * frames. | |
636 * | |
637 * As such, future decoding calls may require a rewind. | |
638 * | |
639 * For single-frame images, this will return an empty vector. | |
638 */ | 640 */ |
639 size_t getFrameDuration(size_t index) { | 641 std::vector<FrameInfo> getFrameInfo() { |
scroggo
2016/09/26 15:51:43
sgtm
| |
640 return this->onGetFrameDuration(index); | 642 return this->onGetFrameInfo(); |
641 } | 643 } |
642 | 644 |
643 protected: | 645 protected: |
644 /** | 646 /** |
645 * Takes ownership of SkStream* | 647 * Takes ownership of SkStream* |
646 */ | 648 */ |
647 SkCodec(int width, | 649 SkCodec(int width, |
648 int height, | 650 int height, |
649 const SkEncodedInfo&, | 651 const SkEncodedInfo&, |
650 SkStream*, | 652 SkStream*, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
773 /** | 775 /** |
774 * Returns the number of scanlines that have been decoded so far. | 776 * Returns the number of scanlines that have been decoded so far. |
775 * This is unaffected by the SkScanlineOrder. | 777 * This is unaffected by the SkScanlineOrder. |
776 * | 778 * |
777 * Returns -1 if we have not started a scanline decode. | 779 * Returns -1 if we have not started a scanline decode. |
778 */ | 780 */ |
779 int currScanline() const { return fCurrScanline; } | 781 int currScanline() const { return fCurrScanline; } |
780 | 782 |
781 virtual int onOutputScanline(int inputScanline) const; | 783 virtual int onOutputScanline(int inputScanline) const; |
782 | 784 |
783 virtual size_t onGetFrameCount() { | 785 virtual std::vector<FrameInfo> onGetFrameInfo() { |
784 return 1; | 786 // empty vector - this is not animated. |
785 } | 787 return {}; |
786 | |
787 virtual size_t onGetRequiredFrame(size_t) { | |
788 return kIndependentFrame; | |
789 } | |
790 | |
791 virtual size_t onGetFrameDuration(size_t) { | |
792 return 0; | |
793 } | 788 } |
794 | 789 |
795 /** | 790 /** |
796 * Used for testing with qcms. | 791 * Used for testing with qcms. |
797 * FIXME: Remove this when we are done comparing with qcms. | 792 * FIXME: Remove this when we are done comparing with qcms. |
798 */ | 793 */ |
799 virtual sk_sp<SkData> getICCData() const { return nullptr; } | 794 virtual sk_sp<SkData> getICCData() const { return nullptr; } |
800 private: | 795 private: |
801 const SkEncodedInfo fEncodedInfo; | 796 const SkEncodedInfo fEncodedInfo; |
802 const SkImageInfo fSrcInfo; | 797 const SkImageInfo fSrcInfo; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
875 // For testing with qcms | 870 // For testing with qcms |
876 // FIXME: Remove these when we are done comparing with qcms. | 871 // FIXME: Remove these when we are done comparing with qcms. |
877 friend class DM::ColorCodecSrc; | 872 friend class DM::ColorCodecSrc; |
878 friend class ColorCodecBench; | 873 friend class ColorCodecBench; |
879 | 874 |
880 friend class DM::CodecSrc; // for fillIncompleteImage | 875 friend class DM::CodecSrc; // for fillIncompleteImage |
881 friend class SkSampledCodec; | 876 friend class SkSampledCodec; |
882 friend class SkIcoCodec; | 877 friend class SkIcoCodec; |
883 }; | 878 }; |
884 #endif // SkCodec_DEFINED | 879 #endif // SkCodec_DEFINED |
OLD | NEW |