Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 return true; | 218 return true; |
| 219 } | 219 } |
| 220 | 220 |
| 221 size_t GIFImageDecoder::clearCacheExceptFrame(size_t clearExceptFrame) | 221 size_t GIFImageDecoder::clearCacheExceptFrame(size_t clearExceptFrame) |
| 222 { | 222 { |
| 223 // We need to preserve frames such that: | 223 // We need to preserve frames such that: |
| 224 // 1. We don't clear |clearExceptFrame|; | 224 // 1. We don't clear |clearExceptFrame|; |
| 225 // 2. We don't clear any frame from which a future initFrameBuffer() call | 225 // 2. We don't clear any frame from which a two* future initFrameBuffer() c alls |
|
tomhudson
2016/01/12 16:15:59
Nit: 'which a two' -> 'which two', although this c
aleksandar.stojiljkovic
2016/01/12 17:34:59
Done.
| |
| 226 // will copy bitmap data. | 226 // will copy bitmap data. |
| 227 // All other frames can be cleared. | 227 // All other frames can be cleared. |
| 228 while ((clearExceptFrame < m_frameBufferCache.size()) && (m_frameBufferCache [clearExceptFrame].status() == ImageFrame::FrameEmpty)) | 228 // *) Two frames range is chosen as dependent animated GIF frames usually de pend |
| 229 clearExceptFrame = m_frameBufferCache[clearExceptFrame].requiredPrevious FrameIndex(); | 229 // on the previous or the frame before previous. |
|
urvang
2016/01/12 18:02:01
As an extreme example, what if all frames in a GIF
aleksandar.stojiljkovic
2016/01/12 18:19:14
Theoretically, you're right.
While exploring GIF r
| |
| 230 | 230 if (clearExceptFrame == kNotFound) |
| 231 return ImageDecoder::clearCacheExceptFrame(clearExceptFrame); | 231 return ImageDecoder::clearCacheExceptFrame(clearExceptFrame); |
| 232 SizeTHashSet clearExceptFrames; | |
| 233 for (int i = 0; i < 2; ++i, ++clearExceptFrame) { | |
| 234 size_t leave = clearExceptFrame; | |
| 235 while ((leave < m_frameBufferCache.size()) && (m_frameBufferCache[leave] .status() == ImageFrame::FrameEmpty)) | |
| 236 leave = m_frameBufferCache[leave].requiredPreviousFrameIndex(); | |
| 237 if (leave != kNotFound) | |
| 238 clearExceptFrames.add(leave); | |
| 239 } | |
| 240 if (clearExceptFrames.size() > 1) | |
| 241 return clearCacheExceptFrames(clearExceptFrames); | |
| 242 return ImageDecoder::clearCacheExceptFrame(clearExceptFrames.size() ? *(clea rExceptFrames.begin()) : kNotFound); | |
|
tomhudson
2016/01/12 16:15:59
These three lines are significantly more complicat
aleksandar.stojiljkovic
2016/01/12 17:34:59
Acknowledged.
aleksandar.stojiljkovic
2016/01/12 18:54:02
Fixed this in new patch.
Thanks for pointing - mea
| |
| 232 } | 243 } |
| 233 | 244 |
| 234 void GIFImageDecoder::clearFrameBuffer(size_t frameIndex) | 245 void GIFImageDecoder::clearFrameBuffer(size_t frameIndex) |
| 235 { | 246 { |
| 236 if (m_reader && m_frameBufferCache[frameIndex].status() == ImageFrame::Frame Partial) { | 247 if (m_reader && m_frameBufferCache[frameIndex].status() == ImageFrame::Frame Partial) { |
| 237 // Reset the state of the partial frame in the reader so that the frame | 248 // Reset the state of the partial frame in the reader so that the frame |
| 238 // can be decoded again when requested. | 249 // can be decoded again when requested. |
| 239 m_reader->clearDecodeState(frameIndex); | 250 m_reader->clearDecodeState(frameIndex); |
| 240 } | 251 } |
| 241 ImageDecoder::clearFrameBuffer(frameIndex); | 252 ImageDecoder::clearFrameBuffer(frameIndex); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 | 346 |
| 336 // Update our status to be partially complete. | 347 // Update our status to be partially complete. |
| 337 buffer->setStatus(ImageFrame::FramePartial); | 348 buffer->setStatus(ImageFrame::FramePartial); |
| 338 | 349 |
| 339 // Reset the alpha pixel tracker for this frame. | 350 // Reset the alpha pixel tracker for this frame. |
| 340 m_currentBufferSawAlpha = false; | 351 m_currentBufferSawAlpha = false; |
| 341 return true; | 352 return true; |
| 342 } | 353 } |
| 343 | 354 |
| 344 } // namespace blink | 355 } // namespace blink |
| OLD | NEW |