| OLD | NEW |
| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // decoded. | 258 // decoded. |
| 259 buffer.setHasAlpha(true); | 259 buffer.setHasAlpha(true); |
| 260 } | 260 } |
| 261 | 261 |
| 262 bool WEBPImageDecoder::canReusePreviousFrameBuffer(size_t frameIndex) const { | 262 bool WEBPImageDecoder::canReusePreviousFrameBuffer(size_t frameIndex) const { |
| 263 DCHECK(frameIndex < m_frameBufferCache.size()); | 263 DCHECK(frameIndex < m_frameBufferCache.size()); |
| 264 return m_frameBufferCache[frameIndex].getAlphaBlendSource() != | 264 return m_frameBufferCache[frameIndex].getAlphaBlendSource() != |
| 265 ImageFrame::BlendAtopPreviousFrame; | 265 ImageFrame::BlendAtopPreviousFrame; |
| 266 } | 266 } |
| 267 | 267 |
| 268 size_t WEBPImageDecoder::clearCacheExceptFrame(size_t clearExceptFrame) { | |
| 269 // Don't clear if there are no frames, or only one. | |
| 270 if (m_frameBufferCache.size() <= 1) | |
| 271 return 0; | |
| 272 | |
| 273 // If |clearExceptFrame| has status FrameComplete, we only preserve that | |
| 274 // frame. Otherwise, we *also* preserve the most recent previous frame with | |
| 275 // status FrameComplete whose data will be required to decode | |
| 276 // |clearExceptFrame|, either in initFrameBuffer() or ApplyPostProcessing(). | |
| 277 // This frame index is stored in |clearExceptFrame2|. All other frames can | |
| 278 // be cleared. | |
| 279 size_t clearExceptFrame2 = kNotFound; | |
| 280 if (clearExceptFrame < m_frameBufferCache.size() && | |
| 281 m_frameBufferCache[clearExceptFrame].getStatus() != | |
| 282 ImageFrame::FrameComplete) { | |
| 283 clearExceptFrame2 = | |
| 284 m_frameBufferCache[clearExceptFrame].requiredPreviousFrameIndex(); | |
| 285 } | |
| 286 | |
| 287 while ((clearExceptFrame2 < m_frameBufferCache.size()) && | |
| 288 (m_frameBufferCache[clearExceptFrame2].getStatus() != | |
| 289 ImageFrame::FrameComplete)) { | |
| 290 clearExceptFrame2 = | |
| 291 m_frameBufferCache[clearExceptFrame2].requiredPreviousFrameIndex(); | |
| 292 } | |
| 293 | |
| 294 return clearCacheExceptTwoFrames(clearExceptFrame, clearExceptFrame2); | |
| 295 } | |
| 296 | |
| 297 void WEBPImageDecoder::clearFrameBuffer(size_t frameIndex) { | 268 void WEBPImageDecoder::clearFrameBuffer(size_t frameIndex) { |
| 298 if (m_demux && m_demuxState >= WEBP_DEMUX_PARSED_HEADER && | 269 if (m_demux && m_demuxState >= WEBP_DEMUX_PARSED_HEADER && |
| 299 m_frameBufferCache[frameIndex].getStatus() == ImageFrame::FramePartial) { | 270 m_frameBufferCache[frameIndex].getStatus() == ImageFrame::FramePartial) { |
| 300 // Clear the decoder state so that this partial frame can be decoded again | 271 // Clear the decoder state so that this partial frame can be decoded again |
| 301 // when requested. | 272 // when requested. |
| 302 clearDecoder(); | 273 clearDecoder(); |
| 303 } | 274 } |
| 304 ImageDecoder::clearFrameBuffer(frameIndex); | 275 ImageDecoder::clearFrameBuffer(frameIndex); |
| 305 } | 276 } |
| 306 | 277 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 return false; | 509 return false; |
| 539 } | 510 } |
| 540 // FALLTHROUGH | 511 // FALLTHROUGH |
| 541 default: | 512 default: |
| 542 clear(); | 513 clear(); |
| 543 return setFailed(); | 514 return setFailed(); |
| 544 } | 515 } |
| 545 } | 516 } |
| 546 | 517 |
| 547 } // namespace blink | 518 } // namespace blink |
| OLD | NEW |