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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 and avoid copy. |
Peter Kasting
2016/08/26 19:04:04
See comments in WebP decoder, they also apply to t
aleksandar.stojiljkovic
2016/08/26 21:53:51
Done.
| |
363 if (!buffer->copyBitmapData(*prevBuffer)) | 363 // For DisposeOverwritePrevious, the next frame will also use |
364 return setFailed(); | 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)) { | |
367 if (!buffer->copyBitmapData(*prevBuffer)) | |
368 return setFailed(); | |
369 } | |
365 | 370 |
366 if (prevBuffer->getDisposalMethod() == ImageFrame::DisposeOverwriteBgcol or) { | 371 if (prevBuffer->getDisposalMethod() == ImageFrame::DisposeOverwriteBgcol or) { |
367 // We want to clear the previous frame to transparent, without | 372 // We want to clear the previous frame to transparent, without |
368 // affecting pixels in the image outside of the frame. | 373 // affecting pixels in the image outside of the frame. |
369 const IntRect& prevRect = prevBuffer->originalFrameRect(); | 374 const IntRect& prevRect = prevBuffer->originalFrameRect(); |
370 ASSERT(!prevRect.contains(IntRect(IntPoint(), size()))); | 375 ASSERT(!prevRect.contains(IntRect(IntPoint(), size()))); |
371 buffer->zeroFillFrameRect(prevRect); | 376 buffer->zeroFillFrameRect(prevRect); |
372 } | 377 } |
373 } | 378 } |
374 | 379 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
417 m_purgeAggressively = true; | 422 m_purgeAggressively = true; |
418 return; | 423 return; |
419 } | 424 } |
420 | 425 |
421 const uint64_t totalMemoryUsage = frameMemoryUsage * index; | 426 const uint64_t totalMemoryUsage = frameMemoryUsage * index; |
422 if (totalMemoryUsage > m_maxDecodedBytes) { | 427 if (totalMemoryUsage > m_maxDecodedBytes) { |
423 m_purgeAggressively = true; | 428 m_purgeAggressively = true; |
424 } | 429 } |
425 } | 430 } |
426 } // namespace blink | 431 } // namespace blink |
OLD | NEW |