Chromium Code Reviews| 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) | 242 , m_decodedFramesCount(0) |
| 243 , m_parseCompleted(false) | 243 , m_parseCompleted(false) |
| 244 { | 244 { |
| 245 } | 245 } |
| 246 | 246 |
| 247 ~GIFImageReader() | 247 ~GIFImageReader() |
| 248 { | 248 { |
| 249 } | 249 } |
| 250 | 250 |
| 251 void setData(PassRefPtr<WebCore::SharedBuffer> data) { m_data = data; } | 251 void setData(PassRefPtr<WebCore::SharedBuffer> data) { m_data = data; } |
| 252 // FIXME: haltAtFrame should be size_t. | 252 bool parse(WebCore::GIFImageDecoder::GIFParseQuery); |
| 253 bool decode(WebCore::GIFImageDecoder::GIFQuery, unsigned haltAtFrame); | 253 bool decode(const BitVector& frames); |
|
Alpha Left Google
2013/05/18 00:39:35
Why not just give the index? User of this API (GIF
Xianzhu
2013/05/20 04:30:59
Done.
| |
| 254 | 254 |
| 255 size_t imagesCount() const | 255 size_t imagesCount() const |
| 256 { | 256 { |
| 257 if (m_frames.isEmpty()) | 257 if (m_frames.isEmpty()) |
| 258 return 0; | 258 return 0; |
| 259 | 259 |
| 260 // This avoids counting an empty frame when the file is truncated right after | 260 // This avoids counting an empty frame when the file is truncated right after |
| 261 // GIFControlExtension but before GIFImageHeader. | 261 // GIFControlExtension but before GIFImageHeader. |
| 262 // FIXME: This extra complexity is not necessary and we should just repo rt m_frames.size(). | 262 // 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; | 263 return m_frames.last()->isHeaderDefined() ? m_frames.size() : m_frames.s ize() - 1; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 283 } | 283 } |
| 284 | 284 |
| 285 const GIFFrameContext* frameContext(size_t index) const | 285 const GIFFrameContext* frameContext(size_t index) const |
| 286 { | 286 { |
| 287 return index < m_frames.size() ? m_frames[index].get() : 0; | 287 return index < m_frames.size() ? m_frames[index].get() : 0; |
| 288 } | 288 } |
| 289 | 289 |
| 290 bool parseCompleted() const { return m_parseCompleted; } | 290 bool parseCompleted() const { return m_parseCompleted; } |
| 291 | 291 |
| 292 private: | 292 private: |
| 293 bool parse(size_t dataPosition, size_t len, bool parseSizeOnly); | 293 bool parseData(size_t dataPosition, size_t len, WebCore::GIFImageDecoder::GI FParseQuery); |
| 294 void setRemainingBytes(size_t); | 294 void setRemainingBytes(size_t); |
| 295 | 295 |
| 296 const unsigned char* data(size_t dataPosition) const | 296 const unsigned char* data(size_t dataPosition) const |
| 297 { | 297 { |
| 298 return reinterpret_cast<const unsigned char*>(m_data->data()) + dataPosi tion; | 298 return reinterpret_cast<const unsigned char*>(m_data->data()) + dataPosi tion; |
| 299 } | 299 } |
| 300 | 300 |
| 301 void addFrameIfNecessary(); | 301 void addFrameIfNecessary(); |
| 302 bool currentFrameIsFirstFrame() const | 302 bool currentFrameIsFirstFrame() const |
| 303 { | 303 { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 315 int m_screenBgcolor; // Logical screen background color. | 315 int m_screenBgcolor; // Logical screen background color. |
| 316 int m_version; // Either 89 for GIF89 or 87 for GIF87. | 316 int m_version; // Either 89 for GIF89 or 87 for GIF87. |
| 317 unsigned m_screenWidth; // Logical screen width & height. | 317 unsigned m_screenWidth; // Logical screen width & height. |
| 318 unsigned m_screenHeight; | 318 unsigned m_screenHeight; |
| 319 bool m_isGlobalColormapDefined; | 319 bool m_isGlobalColormapDefined; |
| 320 size_t m_globalColormapPosition; // (3* MAX_COLORS in size) Default colormap if local not supplied, 3 bytes for each color. | 320 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. | 321 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. | 322 int m_loopCount; // Netscape specific extension block to control the number of animation loops a GIF renders. |
| 323 | 323 |
| 324 Vector<OwnPtr<GIFFrameContext> > m_frames; | 324 Vector<OwnPtr<GIFFrameContext> > m_frames; |
| 325 size_t m_currentDecodingFrame; | 325 size_t m_decodedFramesCount; |
|
Alpha Left Google
2013/05/18 00:39:35
I don't think we need this any more. See my commen
Xianzhu
2013/05/20 04:30:59
Done.
| |
| 326 | 326 |
| 327 RefPtr<WebCore::SharedBuffer> m_data; | 327 RefPtr<WebCore::SharedBuffer> m_data; |
| 328 bool m_parseCompleted; | 328 bool m_parseCompleted; |
| 329 }; | 329 }; |
| 330 | 330 |
| 331 #endif | 331 #endif |
| OLD | NEW |