Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp

Issue 1574283002: GIF Animations "clear from cache related glitch" fix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: @pkasting, great that you figured out this - yes, DisposeOverwritePrevious fixes this. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 future initFrameBuffer() call
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 while ((clearExceptFrame < m_frameBufferCache.size()) && (m_frameBufferCache [clearExceptFrame].status() == ImageFrame::FrameEmpty))
229 clearExceptFrame = m_frameBufferCache[clearExceptFrame].requiredPrevious FrameIndex(); 229 clearExceptFrame = m_frameBufferCache[clearExceptFrame].requiredPrevious FrameIndex();
230 if ((clearExceptFrame < m_frameBufferCache.size()) && (m_frameBufferCache.si ze() > 1)
231 && (m_frameBufferCache[clearExceptFrame].disposalMethod() == ImageFrame: :DisposeOverwritePrevious))
232 return clearCacheExceptTwoFrames(clearExceptFrame, m_frameBufferCache[cl earExceptFrame].requiredPreviousFrameIndex());
Peter Kasting 2016/01/14 00:17:29 I don't think this is as correct as the algorithm
aleksandar.stojiljkovic 2016/01/14 11:32:53 I should have explained for not doing as you sugge
Peter Kasting 2016/01/14 22:58:39 I think you're mistaken about how both the existin
233 return ImageDecoder::clearCacheExceptFrame(clearExceptFrame);
234 }
230 235
231 return ImageDecoder::clearCacheExceptFrame(clearExceptFrame); 236
237 size_t GIFImageDecoder::clearCacheExceptTwoFrames(size_t dontClearFrame1, size_t dontClearFrame2)
238 {
239 size_t frameBytesCleared = 0;
240 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) {
241 if (m_frameBufferCache[i].status() != ImageFrame::FrameEmpty && i != don tClearFrame1 && i != dontClearFrame2) {
242 frameBytesCleared += frameBytesAtIndex(i);
243 clearFrameBuffer(i);
244 }
245 }
246 return frameBytesCleared;
232 } 247 }
233 248
234 void GIFImageDecoder::clearFrameBuffer(size_t frameIndex) 249 void GIFImageDecoder::clearFrameBuffer(size_t frameIndex)
235 { 250 {
236 if (m_reader && m_frameBufferCache[frameIndex].status() == ImageFrame::Frame Partial) { 251 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 252 // Reset the state of the partial frame in the reader so that the frame
238 // can be decoded again when requested. 253 // can be decoded again when requested.
239 m_reader->clearDecodeState(frameIndex); 254 m_reader->clearDecodeState(frameIndex);
240 } 255 }
241 ImageDecoder::clearFrameBuffer(frameIndex); 256 ImageDecoder::clearFrameBuffer(frameIndex);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 350
336 // Update our status to be partially complete. 351 // Update our status to be partially complete.
337 buffer->setStatus(ImageFrame::FramePartial); 352 buffer->setStatus(ImageFrame::FramePartial);
338 353
339 // Reset the alpha pixel tracker for this frame. 354 // Reset the alpha pixel tracker for this frame.
340 m_currentBufferSawAlpha = false; 355 m_currentBufferSawAlpha = false;
341 return true; 356 return true;
342 } 357 }
343 358
344 } // namespace blink 359 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698