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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp

Issue 2516593003: Pull up clearCacheExceptFrame to ImageDecoder. (Closed)
Patch Set: Make clearCacheExceptFrame non-virtual Created 4 years, 1 month 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 277 }
278 278
279 buffer.setStatus(ImageFrame::FramePartial); 279 buffer.setStatus(ImageFrame::FramePartial);
280 // The buffer is transparent outside the decoded area while the image is 280 // The buffer is transparent outside the decoded area while the image is
281 // loading. The correct alpha value for the frame will be set when it is fully 281 // loading. The correct alpha value for the frame will be set when it is fully
282 // decoded. 282 // decoded.
283 buffer.setHasAlpha(true); 283 buffer.setHasAlpha(true);
284 return true; 284 return true;
285 } 285 }
286 286
287 size_t WEBPImageDecoder::clearCacheExceptFrame(size_t clearExceptFrame) {
288 // Don't clear if there are no frames, or only one.
289 if (m_frameBufferCache.size() <= 1)
290 return 0;
291
292 // If |clearExceptFrame| has status FrameComplete, we only preserve that
293 // frame. Otherwise, we *also* preserve the most recent previous frame with
294 // status FrameComplete whose data will be required to decode
295 // |clearExceptFrame|, either in initFrameBuffer() or ApplyPostProcessing().
296 // This frame index is stored in |clearExceptFrame2|. All other frames can
297 // be cleared.
298 size_t clearExceptFrame2 = kNotFound;
299 if (clearExceptFrame < m_frameBufferCache.size() &&
300 m_frameBufferCache[clearExceptFrame].getStatus() !=
301 ImageFrame::FrameComplete) {
302 clearExceptFrame2 =
303 m_frameBufferCache[clearExceptFrame].requiredPreviousFrameIndex();
304 }
305
306 while ((clearExceptFrame2 < m_frameBufferCache.size()) &&
307 (m_frameBufferCache[clearExceptFrame2].getStatus() !=
308 ImageFrame::FrameComplete)) {
309 clearExceptFrame2 =
310 m_frameBufferCache[clearExceptFrame2].requiredPreviousFrameIndex();
311 }
312
313 return clearCacheExceptTwoFrames(clearExceptFrame, clearExceptFrame2);
314 }
315
316 void WEBPImageDecoder::clearFrameBuffer(size_t frameIndex) { 287 void WEBPImageDecoder::clearFrameBuffer(size_t frameIndex) {
317 if (m_demux && m_demuxState >= WEBP_DEMUX_PARSED_HEADER && 288 if (m_demux && m_demuxState >= WEBP_DEMUX_PARSED_HEADER &&
318 m_frameBufferCache[frameIndex].getStatus() == ImageFrame::FramePartial) { 289 m_frameBufferCache[frameIndex].getStatus() == ImageFrame::FramePartial) {
319 // Clear the decoder state so that this partial frame can be decoded again 290 // Clear the decoder state so that this partial frame can be decoded again
320 // when requested. 291 // when requested.
321 clearDecoder(); 292 clearDecoder();
322 } 293 }
323 ImageDecoder::clearFrameBuffer(frameIndex); 294 ImageDecoder::clearFrameBuffer(frameIndex);
324 } 295 }
325 296
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 return false; 528 return false;
558 } 529 }
559 // FALLTHROUGH 530 // FALLTHROUGH
560 default: 531 default:
561 clear(); 532 clear();
562 return setFailed(); 533 return setFailed();
563 } 534 }
564 } 535 }
565 536
566 } // namespace blink 537 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698