| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } while (frameToDecode != kNotFound && | 328 } while (frameToDecode != kNotFound && |
| 329 m_frameBufferCache[frameToDecode].getStatus() != | 329 m_frameBufferCache[frameToDecode].getStatus() != |
| 330 ImageFrame::FrameComplete); | 330 ImageFrame::FrameComplete); |
| 331 | 331 |
| 332 for (auto i = framesToDecode.rbegin(); i != framesToDecode.rend(); ++i) { | 332 for (auto i = framesToDecode.rbegin(); i != framesToDecode.rend(); ++i) { |
| 333 if (!m_reader->decode(*i)) { | 333 if (!m_reader->decode(*i)) { |
| 334 setFailed(); | 334 setFailed(); |
| 335 return; | 335 return; |
| 336 } | 336 } |
| 337 | 337 |
| 338 if (m_purgeAggressively) | |
| 339 clearCacheExceptFrame(*i); | |
| 340 | |
| 341 // We need more data to continue decoding. | 338 // We need more data to continue decoding. |
| 342 if (m_frameBufferCache[*i].getStatus() != ImageFrame::FrameComplete) | 339 if (m_frameBufferCache[*i].getStatus() != ImageFrame::FrameComplete) |
| 343 break; | 340 break; |
| 341 |
| 342 if (m_purgeAggressively) |
| 343 clearCacheExceptFrame(*i); |
| 344 } | 344 } |
| 345 | 345 |
| 346 // It is also a fatal error if all data is received and we have decoded all | 346 // It is also a fatal error if all data is received and we have decoded all |
| 347 // frames available but the file is truncated. | 347 // frames available but the file is truncated. |
| 348 if (index >= m_frameBufferCache.size() - 1 && isAllDataReceived() && | 348 if (index >= m_frameBufferCache.size() - 1 && isAllDataReceived() && |
| 349 m_reader && !m_reader->parseCompleted()) | 349 m_reader && !m_reader->parseCompleted()) |
| 350 setFailed(); | 350 setFailed(); |
| 351 } | 351 } |
| 352 | 352 |
| 353 void GIFImageDecoder::parse(GIFParseQuery query) { | 353 void GIFImageDecoder::parse(GIFParseQuery query) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 m_purgeAggressively = true; | 440 m_purgeAggressively = true; |
| 441 return; | 441 return; |
| 442 } | 442 } |
| 443 | 443 |
| 444 const uint64_t totalMemoryUsage = frameMemoryUsage * index; | 444 const uint64_t totalMemoryUsage = frameMemoryUsage * index; |
| 445 if (totalMemoryUsage > m_maxDecodedBytes) { | 445 if (totalMemoryUsage > m_maxDecodedBytes) { |
| 446 m_purgeAggressively = true; | 446 m_purgeAggressively = true; |
| 447 } | 447 } |
| 448 } | 448 } |
| 449 } // namespace blink | 449 } // namespace blink |
| OLD | NEW |