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

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

Issue 2155973002: Save a bitmap copy when advancing to dependent GIF and WebP animation frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unecessary color check in ImageBitmap. Thanks dcheng@. Created 4 years, 2 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 { 349 {
350 // Initialize the frame rect in our buffer. 350 // Initialize the frame rect in our buffer.
351 ImageFrame* const buffer = &m_frameBufferCache[frameIndex]; 351 ImageFrame* const buffer = &m_frameBufferCache[frameIndex];
352 352
353 size_t requiredPreviousFrameIndex = buffer->requiredPreviousFrameIndex(); 353 size_t requiredPreviousFrameIndex = buffer->requiredPreviousFrameIndex();
354 if (requiredPreviousFrameIndex == kNotFound) { 354 if (requiredPreviousFrameIndex == kNotFound) {
355 // This frame doesn't rely on any previous data. 355 // This frame doesn't rely on any previous data.
356 if (!buffer->setSizeAndColorProfile(size().width(), size().height(), Ima geFrame::ICCProfile())) 356 if (!buffer->setSizeAndColorProfile(size().width(), size().height(), Ima geFrame::ICCProfile()))
357 return setFailed(); 357 return setFailed();
358 } else { 358 } else {
359 const ImageFrame* prevBuffer = &m_frameBufferCache[requiredPreviousFrame Index]; 359 ImageFrame* prevBuffer = &m_frameBufferCache[requiredPreviousFrameIndex] ;
360 ASSERT(prevBuffer->getStatus() == ImageFrame::FrameComplete); 360 ASSERT(prevBuffer->getStatus() == ImageFrame::FrameComplete);
361 361
362 // Preserve the last frame as the starting state for this frame. 362 // We try to reuse |prevBuffer| as starting state to avoid copying.
363 if (!buffer->copyBitmapData(*prevBuffer)) 363 // For DisposeOverwritePrevious, the next frame will also use
364 // |prevBuffer| as its starting state, so we can't take over its image
365 // data using takeBitmapDataIfWritable. Copy the data instead.
366 if ((buffer->getDisposalMethod() == ImageFrame::DisposeOverwritePrevious || !buffer->takeBitmapDataIfWritable(prevBuffer)) && !buffer->copyBitmapData(*p revBuffer))
Ken Russell (switch to Gerrit) 2016/09/29 00:40:04 This is a lot of logic for a single if-statement.
aleksandar.stojiljkovic 2016/09/29 08:03:53 It is a nit suggested by pkasting@ and it takes le
364 return setFailed(); 367 return setFailed();
365 368
366 if (prevBuffer->getDisposalMethod() == ImageFrame::DisposeOverwriteBgcol or) { 369 if (prevBuffer->getDisposalMethod() == ImageFrame::DisposeOverwriteBgcol or) {
367 // We want to clear the previous frame to transparent, without 370 // We want to clear the previous frame to transparent, without
368 // affecting pixels in the image outside of the frame. 371 // affecting pixels in the image outside of the frame.
369 const IntRect& prevRect = prevBuffer->originalFrameRect(); 372 const IntRect& prevRect = prevBuffer->originalFrameRect();
370 ASSERT(!prevRect.contains(IntRect(IntPoint(), size()))); 373 ASSERT(!prevRect.contains(IntRect(IntPoint(), size())));
371 buffer->zeroFillFrameRect(prevRect); 374 buffer->zeroFillFrameRect(prevRect);
Ken Russell (switch to Gerrit) 2016/09/29 00:40:04 I don't understand why this preexisting code is ca
aleksandar.stojiljkovic 2016/09/29 08:03:53 Partly covered in the comment above. At this point
372 } 375 }
373 } 376 }
374 377
375 // Update our status to be partially complete. 378 // Update our status to be partially complete.
376 buffer->setStatus(ImageFrame::FramePartial); 379 buffer->setStatus(ImageFrame::FramePartial);
377 380
378 // Reset the alpha pixel tracker for this frame. 381 // Reset the alpha pixel tracker for this frame.
379 m_currentBufferSawAlpha = false; 382 m_currentBufferSawAlpha = false;
380 return true; 383 return true;
381 } 384 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 m_purgeAggressively = true; 420 m_purgeAggressively = true;
418 return; 421 return;
419 } 422 }
420 423
421 const uint64_t totalMemoryUsage = frameMemoryUsage * index; 424 const uint64_t totalMemoryUsage = frameMemoryUsage * index;
422 if (totalMemoryUsage > m_maxDecodedBytes) { 425 if (totalMemoryUsage > m_maxDecodedBytes) {
423 m_purgeAggressively = true; 426 m_purgeAggressively = true;
424 } 427 }
425 } 428 }
426 } // namespace blink 429 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698