| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 ImageFrame::DisposeOverwriteBgcolor) && | 224 ImageFrame::DisposeOverwriteBgcolor) && |
| 225 !prevBuffer->hasAlpha() && | 225 !prevBuffer->hasAlpha() && |
| 226 buffer.originalFrameRect().contains(prevBuffer->originalFrameRect())) | 226 buffer.originalFrameRect().contains(prevBuffer->originalFrameRect())) |
| 227 buffer.setHasAlpha(false); | 227 buffer.setHasAlpha(false); |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 return true; | 231 return true; |
| 232 } | 232 } |
| 233 | 233 |
| 234 size_t GIFImageDecoder::clearCacheExceptFrame(size_t clearExceptFrame) { | |
| 235 // We expect that after this call, we'll be asked to decode frames after | |
| 236 // this one. So we want to avoid clearing frames such that those requests | |
| 237 // would force re-decoding from the beginning of the image. | |
| 238 // | |
| 239 // When |clearExceptFrame| is e.g. DisposeKeep, simply not clearing that | |
| 240 // frame is sufficient, as the next frame will be based on it, and in | |
| 241 // general future frames can't be based on anything previous. | |
| 242 // | |
| 243 // However, if this frame is DisposeOverwritePrevious, then subsequent | |
| 244 // frames will depend on this frame's required previous frame. In this | |
| 245 // case, we need to preserve both this frame and that one. | |
| 246 size_t clearExceptFrame2 = kNotFound; | |
| 247 if (clearExceptFrame < m_frameBufferCache.size()) { | |
| 248 const ImageFrame& frame = m_frameBufferCache[clearExceptFrame]; | |
| 249 if ((frame.getStatus() != ImageFrame::FrameEmpty) && | |
| 250 (frame.getDisposalMethod() == ImageFrame::DisposeOverwritePrevious)) { | |
| 251 clearExceptFrame2 = clearExceptFrame; | |
| 252 clearExceptFrame = frame.requiredPreviousFrameIndex(); | |
| 253 } | |
| 254 } | |
| 255 | |
| 256 // Now |clearExceptFrame| indicates the frame that future frames will | |
| 257 // depend on. But if decoding is skipping forward past intermediate frames, | |
| 258 // this frame may be FrameEmpty. So we need to keep traversing back through | |
| 259 // the required previous frames until we find the nearest non-empty | |
| 260 // ancestor. Preserving that will minimize the amount of future decoding | |
| 261 // needed. | |
| 262 while ((clearExceptFrame < m_frameBufferCache.size()) && | |
| 263 (m_frameBufferCache[clearExceptFrame].getStatus() == | |
| 264 ImageFrame::FrameEmpty)) | |
| 265 clearExceptFrame = | |
| 266 m_frameBufferCache[clearExceptFrame].requiredPreviousFrameIndex(); | |
| 267 return clearCacheExceptTwoFrames(clearExceptFrame, clearExceptFrame2); | |
| 268 } | |
| 269 | |
| 270 void GIFImageDecoder::clearFrameBuffer(size_t frameIndex) { | 234 void GIFImageDecoder::clearFrameBuffer(size_t frameIndex) { |
| 271 if (m_reader && | 235 if (m_reader && |
| 272 m_frameBufferCache[frameIndex].getStatus() == ImageFrame::FramePartial) { | 236 m_frameBufferCache[frameIndex].getStatus() == ImageFrame::FramePartial) { |
| 273 // Reset the state of the partial frame in the reader so that the frame | 237 // Reset the state of the partial frame in the reader so that the frame |
| 274 // can be decoded again when requested. | 238 // can be decoded again when requested. |
| 275 m_reader->clearDecodeState(frameIndex); | 239 m_reader->clearDecodeState(frameIndex); |
| 276 } | 240 } |
| 277 ImageDecoder::clearFrameBuffer(frameIndex); | 241 ImageDecoder::clearFrameBuffer(frameIndex); |
| 278 } | 242 } |
| 279 | 243 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 } | 336 } |
| 373 | 337 |
| 374 // Update our status to be partially complete. | 338 // Update our status to be partially complete. |
| 375 buffer->setStatus(ImageFrame::FramePartial); | 339 buffer->setStatus(ImageFrame::FramePartial); |
| 376 | 340 |
| 377 // Reset the alpha pixel tracker for this frame. | 341 // Reset the alpha pixel tracker for this frame. |
| 378 m_currentBufferSawAlpha = false; | 342 m_currentBufferSawAlpha = false; |
| 379 return true; | 343 return true; |
| 380 } | 344 } |
| 381 } // namespace blink | 345 } // namespace blink |
| OLD | NEW |