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

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

Issue 2382143004: Purge image frame after checking for sufficient data. (Closed)
Patch Set: Rebasing. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698