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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 // Set position and number of colors for the RGB table in the data stream. | 163 // Set position and number of colors for the RGB table in the data stream. |
164 void setTablePositionAndSize(size_t position, size_t colors) | 164 void setTablePositionAndSize(size_t position, size_t colors) |
165 { | 165 { |
166 m_position = position; | 166 m_position = position; |
167 m_colors = colors; | 167 m_colors = colors; |
168 } | 168 } |
169 void setDefined() { m_isDefined = true; } | 169 void setDefined() { m_isDefined = true; } |
170 bool isDefined() const { return m_isDefined; } | 170 bool isDefined() const { return m_isDefined; } |
| 171 size_t getPosition() const { return m_position; } |
| 172 size_t getTableSize() const { return m_colors; } |
171 | 173 |
172 // Build RGBA table using the data stream. | 174 // Build RGBA table using the data stream. |
173 void buildTable(blink::FastSharedBufferReader*); | 175 void buildTable(blink::FastSharedBufferReader*); |
174 const Table& table() const { return m_table; } | 176 const Table& table() const { return m_table; } |
175 | 177 |
176 private: | 178 private: |
177 bool m_isDefined; | 179 bool m_isDefined; |
178 size_t m_position; | 180 size_t m_position; |
179 size_t m_colors; | 181 size_t m_colors; |
180 Table m_table; | 182 Table m_table; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 : m_client(client) | 287 : m_client(client) |
286 , m_state(GIFType) | 288 , m_state(GIFType) |
287 , m_bytesToConsume(6) // Number of bytes for GIF type, either "GIF87a" o
r "GIF89a". | 289 , m_bytesToConsume(6) // Number of bytes for GIF type, either "GIF87a" o
r "GIF89a". |
288 , m_bytesRead(0) | 290 , m_bytesRead(0) |
289 , m_version(0) | 291 , m_version(0) |
290 , m_screenWidth(0) | 292 , m_screenWidth(0) |
291 , m_screenHeight(0) | 293 , m_screenHeight(0) |
292 , m_sentSizeToClient(false) | 294 , m_sentSizeToClient(false) |
293 , m_loopCount(cLoopCountNotSeen) | 295 , m_loopCount(cLoopCountNotSeen) |
294 , m_parseCompleted(false) | 296 , m_parseCompleted(false) |
| 297 , m_backgroundIndex(-1) |
295 { | 298 { |
296 } | 299 } |
297 | 300 |
298 ~GIFImageReader() | 301 ~GIFImageReader() |
299 { | 302 { |
300 } | 303 } |
301 | 304 |
302 void setData(PassRefPtr<blink::SharedBuffer> data) { m_data = data; } | 305 void setData(PassRefPtr<blink::SharedBuffer> data) { m_data = data; } |
303 bool parse(blink::GIFImageDecoder::GIFParseQuery); | 306 bool parse(blink::GIFImageDecoder::GIFParseQuery); |
304 bool decode(size_t frameIndex); | 307 bool decode(size_t frameIndex); |
(...skipping 17 matching lines...) Expand all Loading... |
322 | 325 |
323 const GIFFrameContext* frameContext(size_t index) const | 326 const GIFFrameContext* frameContext(size_t index) const |
324 { | 327 { |
325 return index < m_frames.size() ? m_frames[index].get() : 0; | 328 return index < m_frames.size() ? m_frames[index].get() : 0; |
326 } | 329 } |
327 | 330 |
328 bool parseCompleted() const { return m_parseCompleted; } | 331 bool parseCompleted() const { return m_parseCompleted; } |
329 | 332 |
330 void clearDecodeState(size_t index) { m_frames[index]->clearDecodeState(); } | 333 void clearDecodeState(size_t index) { m_frames[index]->clearDecodeState(); } |
331 | 334 |
| 335 unsigned short backgroundIndex() const { return m_backgroundIndex; } |
| 336 |
332 private: | 337 private: |
333 bool parseData(size_t dataPosition, size_t len, blink::GIFImageDecoder::GIFP
arseQuery); | 338 bool parseData(size_t dataPosition, size_t len, blink::GIFImageDecoder::GIFP
arseQuery); |
334 void setRemainingBytes(size_t); | 339 void setRemainingBytes(size_t); |
335 | 340 |
336 void addFrameIfNecessary(); | 341 void addFrameIfNecessary(); |
337 bool currentFrameIsFirstFrame() const | 342 bool currentFrameIsFirstFrame() const |
338 { | 343 { |
339 return m_frames.isEmpty() || (m_frames.size() == 1u && !m_frames[0]->isC
omplete()); | 344 return m_frames.isEmpty() || (m_frames.size() == 1u && !m_frames[0]->isC
omplete()); |
340 } | 345 } |
341 | 346 |
342 blink::GIFImageDecoder* m_client; | 347 blink::GIFImageDecoder* m_client; |
343 | 348 |
344 // Parsing state machine. | 349 // Parsing state machine. |
345 GIFState m_state; // Current decoder master state. | 350 GIFState m_state; // Current decoder master state. |
346 size_t m_bytesToConsume; // Number of bytes to consume for next stage of par
sing. | 351 size_t m_bytesToConsume; // Number of bytes to consume for next stage of par
sing. |
347 size_t m_bytesRead; // Number of bytes processed. | 352 size_t m_bytesRead; // Number of bytes processed. |
348 | 353 |
349 // Global (multi-image) state. | 354 // Global (multi-image) state. |
350 int m_version; // Either 89 for GIF89 or 87 for GIF87. | 355 int m_version; // Either 89 for GIF89 or 87 for GIF87. |
351 unsigned m_screenWidth; // Logical screen width & height. | 356 unsigned m_screenWidth; // Logical screen width & height. |
352 unsigned m_screenHeight; | 357 unsigned m_screenHeight; |
353 bool m_sentSizeToClient; | 358 bool m_sentSizeToClient; |
354 GIFColorMap m_globalColorMap; | 359 GIFColorMap m_globalColorMap; |
355 int m_loopCount; // Netscape specific extension block to control the number
of animation loops a GIF renders. | 360 int m_loopCount; // Netscape specific extension block to control the number
of animation loops a GIF renders. |
356 | 361 |
357 Vector<OwnPtr<GIFFrameContext>> m_frames; | 362 Vector<OwnPtr<GIFFrameContext>> m_frames; |
358 | 363 |
359 RefPtr<blink::SharedBuffer> m_data; | 364 RefPtr<blink::SharedBuffer> m_data; |
360 bool m_parseCompleted; | 365 bool m_parseCompleted; |
| 366 unsigned short m_backgroundIndex; |
361 }; | 367 }; |
362 | 368 |
363 #endif | 369 #endif |
OLD | NEW |