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

Side by Side Diff: Source/platform/image-decoders/ImageDecoder.cpp

Issue 201793002: Revert of Allow frames to be free'd even for static images (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 unsigned ImageDecoder::frameBytesAtIndex(size_t index) const 127 unsigned ImageDecoder::frameBytesAtIndex(size_t index) const
128 { 128 {
129 if (m_frameBufferCache.size() <= index || m_frameBufferCache[index].status() == ImageFrame::FrameEmpty) 129 if (m_frameBufferCache.size() <= index || m_frameBufferCache[index].status() == ImageFrame::FrameEmpty)
130 return 0; 130 return 0;
131 // FIXME: Use the dimension of the requested frame. 131 // FIXME: Use the dimension of the requested frame.
132 return m_size.area() * sizeof(ImageFrame::PixelData); 132 return m_size.area() * sizeof(ImageFrame::PixelData);
133 } 133 }
134 134
135 size_t ImageDecoder::clearCacheExceptFrame(size_t clearExceptFrame) 135 size_t ImageDecoder::clearCacheExceptFrame(size_t clearExceptFrame)
136 { 136 {
137 // Don't clear if there are no frames or only one frame.
138 if (m_frameBufferCache.size() <= 1)
139 return 0;
140
137 size_t frameBytesCleared = 0; 141 size_t frameBytesCleared = 0;
138 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) { 142 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) {
139 if (i != clearExceptFrame) { 143 if (i != clearExceptFrame) {
140 frameBytesCleared += frameBytesAtIndex(i); 144 frameBytesCleared += frameBytesAtIndex(i);
141 clearFrameBuffer(i); 145 clearFrameBuffer(i);
142 } 146 }
143 } 147 }
144 return frameBytesCleared; 148 return frameBytesCleared;
145 } 149 }
146 150
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Otherwise, the previous frame contributes to this frame. 192 // Otherwise, the previous frame contributes to this frame.
189 return (prevBuffer->originalFrameRect().contains(IntRect(IntPoint(), siz e())) 193 return (prevBuffer->originalFrameRect().contains(IntRect(IntPoint(), siz e()))
190 || (prevBuffer->requiredPreviousFrameIndex() == kNotFound)) ? kNotFo und : prevFrame; 194 || (prevBuffer->requiredPreviousFrameIndex() == kNotFound)) ? kNotFo und : prevFrame;
191 default: 195 default:
192 ASSERT_NOT_REACHED(); 196 ASSERT_NOT_REACHED();
193 return kNotFound; 197 return kNotFound;
194 } 198 }
195 } 199 }
196 200
197 } // namespace WebCore 201 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/graphics/ImageFrameGeneratorTest.cpp ('k') | Source/platform/image-decoders/ImageDecoderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698