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

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: more correct way to write it. 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.s ize() == 1)
231 || (m_frameBufferCache[clearExceptFrame].disposalMethod() != ImageFrame: :DisposeOverwritePrevious))
232 return ImageDecoder::clearCacheExceptFrame(clearExceptFrame);
233 // For case with DisposeOverwritePrevious, enumerate through required to
234 // find the one that is complete.
235 size_t frame2 = m_frameBufferCache[clearExceptFrame].requiredPreviousFrameIn dex();
236 while ((frame2 < m_frameBufferCache.size()) && (m_frameBufferCache[frame2].s tatus() == ImageFrame::FrameEmpty))
237 frame2 = m_frameBufferCache[frame2].requiredPreviousFrameIndex();
238 return clearCacheExceptTwoFrames(clearExceptFrame, frame2);
239 }
230 240
231 return ImageDecoder::clearCacheExceptFrame(clearExceptFrame); 241
242 size_t GIFImageDecoder::clearCacheExceptTwoFrames(size_t dontClearFrame1, size_t dontClearFrame2)
243 {
244 size_t frameBytesCleared = 0;
245 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) {
246 if (m_frameBufferCache[i].status() != ImageFrame::FrameEmpty && i != don tClearFrame1 && i != dontClearFrame2) {
247 frameBytesCleared += frameBytesAtIndex(i);
248 clearFrameBuffer(i);
249 }
250 }
251 return frameBytesCleared;
232 } 252 }
233 253
234 void GIFImageDecoder::clearFrameBuffer(size_t frameIndex) 254 void GIFImageDecoder::clearFrameBuffer(size_t frameIndex)
235 { 255 {
236 if (m_reader && m_frameBufferCache[frameIndex].status() == ImageFrame::Frame Partial) { 256 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 257 // Reset the state of the partial frame in the reader so that the frame
238 // can be decoded again when requested. 258 // can be decoded again when requested.
239 m_reader->clearDecodeState(frameIndex); 259 m_reader->clearDecodeState(frameIndex);
240 } 260 }
241 ImageDecoder::clearFrameBuffer(frameIndex); 261 ImageDecoder::clearFrameBuffer(frameIndex);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 355
336 // Update our status to be partially complete. 356 // Update our status to be partially complete.
337 buffer->setStatus(ImageFrame::FramePartial); 357 buffer->setStatus(ImageFrame::FramePartial);
338 358
339 // Reset the alpha pixel tracker for this frame. 359 // Reset the alpha pixel tracker for this frame.
340 m_currentBufferSawAlpha = false; 360 m_currentBufferSawAlpha = false;
341 return true; 361 return true;
342 } 362 }
343 363
344 } // namespace blink 364 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698