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

Side by Side Diff: Source/platform/graphics/BitmapImage.cpp

Issue 1359953002: [BitmapImage] Don't destroy lazy-decoded frames Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
« 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 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 destroyMetadataAndNotify(m_source.clearCacheExceptFrame(destroyAll ? kNotFou nd : m_currentFrame)); 133 destroyMetadataAndNotify(m_source.clearCacheExceptFrame(destroyAll ? kNotFou nd : m_currentFrame));
134 } 134 }
135 135
136 void BitmapImage::destroyDecodedDataIfNecessary() 136 void BitmapImage::destroyDecodedDataIfNecessary()
137 { 137 {
138 // Animated images >5MB are considered large enough that we'll only hang on 138 // Animated images >5MB are considered large enough that we'll only hang on
139 // to one frame at a time. 139 // to one frame at a time.
140 static const size_t cLargeAnimationCutoff = 5242880; 140 static const size_t cLargeAnimationCutoff = 5242880;
141 size_t allFrameBytes = 0; 141 size_t allFrameBytes = 0;
142 for (size_t i = 0; i < m_frames.size(); ++i) 142 for (size_t i = 0; i < m_frames.size(); ++i) {
143 // The memory for lazy-decoded frames is managed externally.
144 if (m_frames[i].m_frame && m_frames[i].m_frame->isLazyGenerated()) {
145 // We don't mix lazy/non-lazy frames.
146 ASSERT(!allFrameBytes);
147 break;
148 }
149
143 allFrameBytes += m_frames[i].m_frameBytes; 150 allFrameBytes += m_frames[i].m_frameBytes;
151 }
144 152
145 if (allFrameBytes > cLargeAnimationCutoff) { 153 if (allFrameBytes > cLargeAnimationCutoff) {
146 destroyDecodedData(false); 154 destroyDecodedData(false);
147 } 155 }
148 } 156 }
149 157
150 void BitmapImage::destroyMetadataAndNotify(size_t frameBytesCleared) 158 void BitmapImage::destroyMetadataAndNotify(size_t frameBytesCleared)
151 { 159 {
152 if (frameBytesCleared && imageObserver()) 160 if (frameBytesCleared && imageObserver())
153 imageObserver()->decodedSizeChanged(this, -safeCast<int>(frameBytesClear ed)); 161 imageObserver()->decodedSizeChanged(this, -safeCast<int>(frameBytesClear ed));
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 destroyDecodedDataIfNecessary(); 671 destroyDecodedDataIfNecessary();
664 672
665 // We need to draw this frame if we advanced to it while not skipping, or if 673 // We need to draw this frame if we advanced to it while not skipping, or if
666 // while trying to skip frames we hit the last frame and thus had to stop. 674 // while trying to skip frames we hit the last frame and thus had to stop.
667 if (skippingFrames != advancedAnimation) 675 if (skippingFrames != advancedAnimation)
668 imageObserver()->animationAdvanced(this); 676 imageObserver()->animationAdvanced(this);
669 return advancedAnimation; 677 return advancedAnimation;
670 } 678 }
671 679
672 } // namespace blink 680 } // 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