OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef PNGImageDecoder_h | 26 #ifndef PNGImageDecoder_h |
27 #define PNGImageDecoder_h | 27 #define PNGImageDecoder_h |
28 | 28 |
29 #include "platform/image-decoders/ImageDecoder.h" | 29 #include "platform/image-decoders/ImageDecoder.h" |
30 #include "platform/image-decoders/png/PNGImageReader.h" | |
30 #include <memory> | 31 #include <memory> |
31 | 32 |
32 namespace blink { | 33 namespace blink { |
33 | 34 |
34 class PNGImageReader; | |
35 | |
36 class PLATFORM_EXPORT PNGImageDecoder final : public ImageDecoder { | 35 class PLATFORM_EXPORT PNGImageDecoder final : public ImageDecoder { |
37 WTF_MAKE_NONCOPYABLE(PNGImageDecoder); | 36 WTF_MAKE_NONCOPYABLE(PNGImageDecoder); |
38 | 37 |
39 public: | 38 public: |
40 PNGImageDecoder(AlphaOption, | 39 PNGImageDecoder(AlphaOption, |
41 const ColorBehavior&, | 40 const ColorBehavior&, |
42 size_t maxDecodedBytes, | 41 size_t maxDecodedBytes, |
43 size_t offset = 0); | 42 size_t offset = 0); |
44 ~PNGImageDecoder() override; | 43 ~PNGImageDecoder() override; |
45 | 44 |
46 // ImageDecoder: | 45 // ImageDecoder: |
47 String filenameExtension() const override { return "png"; } | 46 String filenameExtension() const override { return "png"; } |
47 int repetitionCount() const override; | |
48 bool frameIsCompleteAtIndex(size_t) const override; | |
49 float frameDurationAtIndex(size_t) const override; | |
50 bool setFailed() override; | |
48 | 51 |
49 // Callbacks from libpng | 52 // Callbacks from libpng |
50 void headerAvailable(); | 53 void headerAvailable(); |
51 void rowAvailable(unsigned char* row, unsigned rowIndex, int); | 54 void rowAvailable(unsigned char* row, unsigned rowIndex, int); |
52 void complete(); | 55 void complete(); |
Noel Gordon
2017/02/21 13:53:55
complete -> frameComplete
scroggo_chromium
2017/02/23 22:09:54
Done.
| |
53 | 56 |
57 // Additional methods used for APNG | |
Noel Gordon
2017/02/21 13:53:55
Remove this comment.
scroggo_chromium
2017/02/23 22:09:54
Done.
| |
58 void setRepetitionCount(int); | |
59 | |
54 private: | 60 private: |
Noel Gordon
2017/02/21 13:53:56
private:
using ParseQuery = PNGImageReader::Pars
scroggo_chromium
2017/02/23 22:09:54
Done.
| |
55 // ImageDecoder: | 61 // ImageDecoder: |
56 void decodeSize() override { decode(true); } | 62 void decodeSize() override { |
Noel Gordon
2017/02/21 13:53:56
Lets move parse() up to here to keep this group to
scroggo_chromium
2017/02/23 22:09:54
Done.
| |
57 void decode(size_t) override { decode(false); } | 63 parse(PNGImageReader::PNGParseQuery::PNGSizeQuery); |
64 } | |
65 void decode(size_t) override; | |
66 size_t decodeFrameCount() override; | |
67 void initializeNewFrame(size_t) override; | |
68 void clearFrameBuffer(size_t) override; | |
69 bool onInitFrameBuffer(size_t) override; | |
70 bool canReusePreviousFrameBuffer(size_t index) const override; | |
Noel Gordon
2017/02/21 13:53:56
bool canReusePreviousFrameBuffer(size_t) const ove
scroggo_chromium
2017/02/23 22:09:54
Done.
| |
58 | 71 |
59 // Decodes the image. If |onlySize| is true, stops decoding after | 72 void parse(PNGImageReader::PNGParseQuery); |
60 // calculating the image size. If decoding fails but there is no more | |
61 // data coming, sets the "decode failure" flag. | |
62 void decode(bool onlySize); | |
63 | 73 |
64 std::unique_ptr<PNGImageReader> m_reader; | 74 std::unique_ptr<PNGImageReader> m_reader; |
65 const unsigned m_offset; | 75 const unsigned m_offset; |
76 | |
Noel Gordon
2017/02/21 13:53:55
Remove this empty line.
scroggo_chromium
2017/02/23 22:09:54
Done.
| |
77 size_t m_currentFrame; | |
78 int m_repetitionCount; | |
79 bool m_hasAlphaChannel; | |
80 bool m_currentBufferSawAlpha; | |
66 }; | 81 }; |
67 | 82 |
68 } // namespace blink | 83 } // namespace blink |
69 | 84 |
70 #endif | 85 #endif |
OLD | NEW |