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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 , m_bytesToConsume(6) // Number of bytes for GIF type, either "GIF87a" o
r "GIF89a". | 232 , m_bytesToConsume(6) // Number of bytes for GIF type, either "GIF87a" o
r "GIF89a". |
233 , m_bytesRead(0) | 233 , m_bytesRead(0) |
234 , m_screenBgcolor(0) | 234 , m_screenBgcolor(0) |
235 , m_version(0) | 235 , m_version(0) |
236 , m_screenWidth(0) | 236 , m_screenWidth(0) |
237 , m_screenHeight(0) | 237 , m_screenHeight(0) |
238 , m_isGlobalColormapDefined(false) | 238 , m_isGlobalColormapDefined(false) |
239 , m_globalColormapPosition(0) | 239 , m_globalColormapPosition(0) |
240 , m_globalColormapSize(0) | 240 , m_globalColormapSize(0) |
241 , m_loopCount(cLoopCountNotSeen) | 241 , m_loopCount(cLoopCountNotSeen) |
242 , m_currentDecodingFrame(0) | |
243 , m_parseCompleted(false) | 242 , m_parseCompleted(false) |
244 { | 243 { |
245 } | 244 } |
246 | 245 |
247 ~GIFImageReader() | 246 ~GIFImageReader() |
248 { | 247 { |
249 } | 248 } |
250 | 249 |
251 void setData(PassRefPtr<WebCore::SharedBuffer> data) { m_data = data; } | 250 void setData(PassRefPtr<WebCore::SharedBuffer> data) { m_data = data; } |
252 // FIXME: haltAtFrame should be size_t. | 251 bool parse(WebCore::GIFImageDecoder::GIFParseQuery); |
253 bool decode(WebCore::GIFImageDecoder::GIFQuery, unsigned haltAtFrame); | 252 bool decode(size_t frameIndex); |
254 | 253 |
255 size_t imagesCount() const | 254 size_t imagesCount() const |
256 { | 255 { |
257 if (m_frames.isEmpty()) | 256 if (m_frames.isEmpty()) |
258 return 0; | 257 return 0; |
259 | 258 |
260 // This avoids counting an empty frame when the file is truncated right
after | 259 // This avoids counting an empty frame when the file is truncated right
after |
261 // GIFControlExtension but before GIFImageHeader. | 260 // GIFControlExtension but before GIFImageHeader. |
262 // FIXME: This extra complexity is not necessary and we should just repo
rt m_frames.size(). | 261 // FIXME: This extra complexity is not necessary and we should just repo
rt m_frames.size(). |
263 return m_frames.last()->isHeaderDefined() ? m_frames.size() : m_frames.s
ize() - 1; | 262 return m_frames.last()->isHeaderDefined() ? m_frames.size() : m_frames.s
ize() - 1; |
(...skipping 19 matching lines...) Expand all Loading... |
283 } | 282 } |
284 | 283 |
285 const GIFFrameContext* frameContext(size_t index) const | 284 const GIFFrameContext* frameContext(size_t index) const |
286 { | 285 { |
287 return index < m_frames.size() ? m_frames[index].get() : 0; | 286 return index < m_frames.size() ? m_frames[index].get() : 0; |
288 } | 287 } |
289 | 288 |
290 bool parseCompleted() const { return m_parseCompleted; } | 289 bool parseCompleted() const { return m_parseCompleted; } |
291 | 290 |
292 private: | 291 private: |
293 bool parse(size_t dataPosition, size_t len, bool parseSizeOnly); | 292 bool parseData(size_t dataPosition, size_t len, WebCore::GIFImageDecoder::GI
FParseQuery); |
294 void setRemainingBytes(size_t); | 293 void setRemainingBytes(size_t); |
295 | 294 |
296 const unsigned char* data(size_t dataPosition) const | 295 const unsigned char* data(size_t dataPosition) const |
297 { | 296 { |
298 return reinterpret_cast<const unsigned char*>(m_data->data()) + dataPosi
tion; | 297 return reinterpret_cast<const unsigned char*>(m_data->data()) + dataPosi
tion; |
299 } | 298 } |
300 | 299 |
301 void addFrameIfNecessary(); | 300 void addFrameIfNecessary(); |
302 bool currentFrameIsFirstFrame() const | 301 bool currentFrameIsFirstFrame() const |
303 { | 302 { |
(...skipping 11 matching lines...) Expand all Loading... |
315 int m_screenBgcolor; // Logical screen background color. | 314 int m_screenBgcolor; // Logical screen background color. |
316 int m_version; // Either 89 for GIF89 or 87 for GIF87. | 315 int m_version; // Either 89 for GIF89 or 87 for GIF87. |
317 unsigned m_screenWidth; // Logical screen width & height. | 316 unsigned m_screenWidth; // Logical screen width & height. |
318 unsigned m_screenHeight; | 317 unsigned m_screenHeight; |
319 bool m_isGlobalColormapDefined; | 318 bool m_isGlobalColormapDefined; |
320 size_t m_globalColormapPosition; // (3* MAX_COLORS in size) Default colormap
if local not supplied, 3 bytes for each color. | 319 size_t m_globalColormapPosition; // (3* MAX_COLORS in size) Default colormap
if local not supplied, 3 bytes for each color. |
321 int m_globalColormapSize; // Size of global colormap array. | 320 int m_globalColormapSize; // Size of global colormap array. |
322 int m_loopCount; // Netscape specific extension block to control the number
of animation loops a GIF renders. | 321 int m_loopCount; // Netscape specific extension block to control the number
of animation loops a GIF renders. |
323 | 322 |
324 Vector<OwnPtr<GIFFrameContext> > m_frames; | 323 Vector<OwnPtr<GIFFrameContext> > m_frames; |
325 size_t m_currentDecodingFrame; | |
326 | 324 |
327 RefPtr<WebCore::SharedBuffer> m_data; | 325 RefPtr<WebCore::SharedBuffer> m_data; |
328 bool m_parseCompleted; | 326 bool m_parseCompleted; |
329 }; | 327 }; |
330 | 328 |
331 #endif | 329 #endif |
OLD | NEW |