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.h" | 8 #include "SkCodec.h" |
9 #include "SkCodecAnimation.h" | 9 #include "SkCodecAnimation.h" |
10 #include "SkColorSpace.h" | 10 #include "SkColorSpace.h" |
11 #include "SkColorTable.h" | 11 #include "SkColorTable.h" |
12 #include "SkImageInfo.h" | 12 #include "SkImageInfo.h" |
13 #include "SkSwizzler.h" | 13 #include "SkSwizzler.h" |
14 #include "../private/SkTArray.h" | |
15 | 14 |
16 struct GifFileType; | 15 struct GifFileType; |
17 struct SavedImage; | 16 struct SavedImage; |
18 | 17 |
19 /* | 18 /* |
20 * | 19 * |
21 * This class implements the decoding for gif images | 20 * This class implements the decoding for gif images |
22 * | 21 * |
23 */ | 22 */ |
24 class SkGifCodec : public SkCodec { | 23 class SkGifCodec : public SkCodec { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 */ | 60 */ |
62 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, | 61 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, |
63 SkPMColor*, int*, int*) override; | 62 SkPMColor*, int*, int*) override; |
64 | 63 |
65 SkEncodedFormat onGetEncodedFormat() const override { | 64 SkEncodedFormat onGetEncodedFormat() const override { |
66 return kGIF_SkEncodedFormat; | 65 return kGIF_SkEncodedFormat; |
67 } | 66 } |
68 | 67 |
69 uint64_t onGetFillValue(const SkImageInfo&) const override; | 68 uint64_t onGetFillValue(const SkImageInfo&) const override; |
70 | 69 |
71 size_t onGetFrameCount() override { | 70 std::vector<FrameInfo> onGetFrameInfo() override; |
72 return (size_t) fFrameInfos.count(); | |
73 } | |
74 | 71 |
75 size_t onGetRequiredFrame(size_t) override; | |
76 | |
77 size_t onGetFrameDuration(size_t) override; | |
78 private: | 72 private: |
79 | 73 |
80 /* | 74 /* |
81 * A gif may contain many image frames, all of different sizes. | 75 * A gif may contain many image frames, all of different sizes. |
82 * This function checks if the gif dimensions are valid, based on the frame | 76 * This function checks if the gif dimensions are valid, based on the frame |
83 * dimensions, and corrects the gif dimensions if necessary. | 77 * dimensions, and corrects the gif dimensions if necessary. |
84 * | 78 * |
85 * @param gif Pointer to the library type that manages the gif decode | 79 * @param gif Pointer to the library type that manages the gif decode |
86 * @param size Size of the image that we will decode. | 80 * @param size Size of the image that we will decode. |
87 * Will be set by this function if the return value is tru
e. | 81 * Will be set by this function if the return value is tru
e. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 * @param stream the stream of image data | 139 * @param stream the stream of image data |
146 * @param gif pointer to library type that manages gif decode | 140 * @param gif pointer to library type that manages gif decode |
147 * takes ownership | 141 * takes ownership |
148 * @param transIndex The transparent index. An invalid value | 142 * @param transIndex The transparent index. An invalid value |
149 * indicates that there is no transparent index. | 143 * indicates that there is no transparent index. |
150 */ | 144 */ |
151 SkGifCodec(int width, int height, const SkEncodedInfo& info, SkStream* strea
m, | 145 SkGifCodec(int width, int height, const SkEncodedInfo& info, SkStream* strea
m, |
152 GifFileType* gif, uint32_t transIndex); | 146 GifFileType* gif, uint32_t transIndex); |
153 | 147 |
154 | 148 |
155 struct FrameInfo : public SkCodecAnimation::FrameInfo { | 149 struct GifFrameInfo : public SkCodecAnimation::FrameInfo { |
156 uint32_t fTransIndex; | 150 uint32_t fTransIndex; |
157 }; | 151 }; |
158 | 152 |
159 SkAutoTCallVProc<GifFileType, CloseGif> fGif; // owned | 153 SkAutoTCallVProc<GifFileType, CloseGif> fGif; // owned |
160 SkAutoTDeleteArray<uint8_t> fSrcBuffer; | 154 SkAutoTDeleteArray<uint8_t> fSrcBuffer; |
161 uint32_t fFillIndex; | 155 uint32_t fFillIndex; |
162 SkAutoTDelete<SkSwizzler> fSwizzler; | 156 SkAutoTDelete<SkSwizzler> fSwizzler; |
163 SkAutoTUnref<SkColorTable> fColorTable; | 157 SkAutoTUnref<SkColorTable> fColorTable; |
164 SkTArray<FrameInfo> fFrameInfos; | 158 std::vector<GifFrameInfo> fFrameInfos; |
165 | 159 |
166 typedef SkCodec INHERITED; | 160 typedef SkCodec INHERITED; |
167 }; | 161 }; |
OLD | NEW |