OLD | NEW |
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* ***** BEGIN LICENSE BLOCK ***** | 2 /* ***** BEGIN LICENSE BLOCK ***** |
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
4 * | 4 * |
5 * The contents of this file are subject to the Mozilla Public License Version | 5 * The contents of this file are subject to the Mozilla Public License Version |
6 * 1.1 (the "License"); you may not use this file except in compliance with | 6 * 1.1 (the "License"); you may not use this file except in compliance with |
7 * the License. You may obtain a copy of the License at | 7 * the License. You may obtain a copy of the License at |
8 * http://www.mozilla.org/MPL/ | 8 * http://www.mozilla.org/MPL/ |
9 * | 9 * |
10 * Software distributed under the License is distributed on an "AS IS" basis, | 10 * Software distributed under the License is distributed on an "AS IS" basis, |
(...skipping 25 matching lines...) Expand all Loading... |
36 * ***** END LICENSE BLOCK ***** */ | 36 * ***** END LICENSE BLOCK ***** */ |
37 | 37 |
38 #ifndef GIFImageReader_h | 38 #ifndef GIFImageReader_h |
39 #define GIFImageReader_h | 39 #define GIFImageReader_h |
40 | 40 |
41 // Define ourselves as the clientPtr. Mozilla just hacked their C++ callback cl
ass into this old C decoder, | 41 // Define ourselves as the clientPtr. Mozilla just hacked their C++ callback cl
ass into this old C decoder, |
42 // so we will too. | 42 // so we will too. |
43 #include "platform/SharedBuffer.h" | 43 #include "platform/SharedBuffer.h" |
44 #include "platform/image-decoders/FastSharedBufferReader.h" | 44 #include "platform/image-decoders/FastSharedBufferReader.h" |
45 #include "platform/image-decoders/gif/GIFImageDecoder.h" | 45 #include "platform/image-decoders/gif/GIFImageDecoder.h" |
| 46 #include "wtf/Allocator.h" |
46 #include "wtf/Noncopyable.h" | 47 #include "wtf/Noncopyable.h" |
47 #include "wtf/OwnPtr.h" | 48 #include "wtf/OwnPtr.h" |
48 #include "wtf/PassOwnPtr.h" | 49 #include "wtf/PassOwnPtr.h" |
49 #include "wtf/Vector.h" | 50 #include "wtf/Vector.h" |
50 | 51 |
51 #define MAX_DICTIONARY_ENTRY_BITS 12 | 52 #define MAX_DICTIONARY_ENTRY_BITS 12 |
52 #define MAX_DICTIONARY_ENTRIES 4096 // 2^MAX_DICTIONARY_ENTRY_BITS | 53 #define MAX_DICTIONARY_ENTRIES 4096 // 2^MAX_DICTIONARY_ENTRY_BITS |
53 #define MAX_COLORS 256 | 54 #define MAX_COLORS 256 |
54 #define BYTES_PER_COLORMAP_ENTRY 3 | 55 #define BYTES_PER_COLORMAP_ENTRY 3 |
55 | 56 |
(...skipping 19 matching lines...) Expand all Loading... |
75 GIFCommentExtension, | 76 GIFCommentExtension, |
76 GIFApplicationExtension, | 77 GIFApplicationExtension, |
77 GIFNetscapeExtensionBlock, | 78 GIFNetscapeExtensionBlock, |
78 GIFConsumeNetscapeExtension, | 79 GIFConsumeNetscapeExtension, |
79 GIFConsumeComment | 80 GIFConsumeComment |
80 }; | 81 }; |
81 | 82 |
82 struct GIFFrameContext; | 83 struct GIFFrameContext; |
83 | 84 |
84 // LZW decoder state machine. | 85 // LZW decoder state machine. |
85 class GIFLZWContext { | 86 class GIFLZWContext final { |
86 USING_FAST_MALLOC(GIFLZWContext); | 87 USING_FAST_MALLOC(GIFLZWContext); |
| 88 WTF_MAKE_NONCOPYABLE(GIFLZWContext); |
87 public: | 89 public: |
88 GIFLZWContext(blink::GIFImageDecoder* client, const GIFFrameContext* frameCo
ntext) | 90 GIFLZWContext(blink::GIFImageDecoder* client, const GIFFrameContext* frameCo
ntext) |
89 : codesize(0) | 91 : codesize(0) |
90 , codemask(0) | 92 , codemask(0) |
91 , clearCode(0) | 93 , clearCode(0) |
92 , avail(0) | 94 , avail(0) |
93 , oldcode(0) | 95 , oldcode(0) |
94 , firstchar(0) | 96 , firstchar(0) |
95 , bits(0) | 97 , bits(0) |
96 , datum(0) | 98 , datum(0) |
(...skipping 30 matching lines...) Expand all Loading... |
127 GIFRow rowBuffer; // Single scanline temporary buffer. | 129 GIFRow rowBuffer; // Single scanline temporary buffer. |
128 GIFRow::iterator rowIter; | 130 GIFRow::iterator rowIter; |
129 | 131 |
130 // Initialized during construction and read-only. | 132 // Initialized during construction and read-only. |
131 blink::GIFImageDecoder* m_client; | 133 blink::GIFImageDecoder* m_client; |
132 const GIFFrameContext* m_frameContext; | 134 const GIFFrameContext* m_frameContext; |
133 }; | 135 }; |
134 | 136 |
135 // Data structure for one LZW block. | 137 // Data structure for one LZW block. |
136 struct GIFLZWBlock { | 138 struct GIFLZWBlock { |
137 USING_FAST_MALLOC(GIFLZWBlock); | 139 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
138 public: | 140 public: |
139 GIFLZWBlock(size_t position, size_t size) | 141 GIFLZWBlock(size_t position, size_t size) |
140 : blockPosition(position) | 142 : blockPosition(position) |
141 , blockSize(size) | 143 , blockSize(size) |
142 { | 144 { |
143 } | 145 } |
144 | 146 |
145 size_t blockPosition; | 147 size_t blockPosition; |
146 size_t blockSize; | 148 size_t blockSize; |
147 }; | 149 }; |
148 | 150 |
149 class GIFColorMap { | 151 class GIFColorMap final { |
150 USING_FAST_MALLOC(GIFColorMap); | 152 DISALLOW_NEW(); |
151 public: | 153 public: |
152 typedef Vector<blink::ImageFrame::PixelData> Table; | 154 typedef Vector<blink::ImageFrame::PixelData> Table; |
153 | 155 |
154 GIFColorMap() | 156 GIFColorMap() |
155 : m_isDefined(false) | 157 : m_isDefined(false) |
156 , m_position(0) | 158 , m_position(0) |
157 , m_colors(0) | 159 , m_colors(0) |
158 { | 160 { |
159 } | 161 } |
160 | 162 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 OwnPtr<GIFLZWContext> m_lzwContext; | 271 OwnPtr<GIFLZWContext> m_lzwContext; |
270 Vector<GIFLZWBlock> m_lzwBlocks; // LZW blocks for this frame. | 272 Vector<GIFLZWBlock> m_lzwBlocks; // LZW blocks for this frame. |
271 GIFColorMap m_localColorMap; | 273 GIFColorMap m_localColorMap; |
272 | 274 |
273 size_t m_currentLzwBlock; | 275 size_t m_currentLzwBlock; |
274 bool m_isComplete; | 276 bool m_isComplete; |
275 bool m_isHeaderDefined; | 277 bool m_isHeaderDefined; |
276 bool m_isDataSizeDefined; | 278 bool m_isDataSizeDefined; |
277 }; | 279 }; |
278 | 280 |
279 class PLATFORM_EXPORT GIFImageReader { | 281 class PLATFORM_EXPORT GIFImageReader final { |
280 USING_FAST_MALLOC(GIFImageReader); WTF_MAKE_NONCOPYABLE(GIFImageReader); | 282 USING_FAST_MALLOC(GIFImageReader); WTF_MAKE_NONCOPYABLE(GIFImageReader); |
281 public: | 283 public: |
282 GIFImageReader(blink::GIFImageDecoder* client = 0) | 284 GIFImageReader(blink::GIFImageDecoder* client = 0) |
283 : m_client(client) | 285 : m_client(client) |
284 , m_state(GIFType) | 286 , m_state(GIFType) |
285 , m_bytesToConsume(6) // Number of bytes for GIF type, either "GIF87a" o
r "GIF89a". | 287 , m_bytesToConsume(6) // Number of bytes for GIF type, either "GIF87a" o
r "GIF89a". |
286 , m_bytesRead(0) | 288 , m_bytesRead(0) |
287 , m_version(0) | 289 , m_version(0) |
288 , m_screenWidth(0) | 290 , m_screenWidth(0) |
289 , m_screenHeight(0) | 291 , m_screenHeight(0) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 GIFColorMap m_globalColorMap; | 354 GIFColorMap m_globalColorMap; |
353 int m_loopCount; // Netscape specific extension block to control the number
of animation loops a GIF renders. | 355 int m_loopCount; // Netscape specific extension block to control the number
of animation loops a GIF renders. |
354 | 356 |
355 Vector<OwnPtr<GIFFrameContext>> m_frames; | 357 Vector<OwnPtr<GIFFrameContext>> m_frames; |
356 | 358 |
357 RefPtr<blink::SharedBuffer> m_data; | 359 RefPtr<blink::SharedBuffer> m_data; |
358 bool m_parseCompleted; | 360 bool m_parseCompleted; |
359 }; | 361 }; |
360 | 362 |
361 #endif | 363 #endif |
OLD | NEW |