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

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

Issue 136503002: Allow frames to be free'd even for static images (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Prune excess h-space. Created 6 years, 11 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
141 size_t frameBytesCleared = 0; 137 size_t frameBytesCleared = 0;
142 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) { 138 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) {
143 if (i != clearExceptFrame) { 139 if (i != clearExceptFrame) {
144 frameBytesCleared += frameBytesAtIndex(i); 140 frameBytesCleared += frameBytesAtIndex(i);
145 clearFrameBuffer(i); 141 clearFrameBuffer(i);
146 } 142 }
147 } 143 }
148 return frameBytesCleared; 144 return frameBytesCleared;
149 } 145 }
150 146
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Otherwise, the previous frame contributes to this frame. 188 // Otherwise, the previous frame contributes to this frame.
193 return (prevBuffer->originalFrameRect().contains(IntRect(IntPoint(), siz e())) 189 return (prevBuffer->originalFrameRect().contains(IntRect(IntPoint(), siz e()))
194 || (prevBuffer->requiredPreviousFrameIndex() == kNotFound)) ? kNotFo und : prevFrame; 190 || (prevBuffer->requiredPreviousFrameIndex() == kNotFound)) ? kNotFo und : prevFrame;
195 default: 191 default:
196 ASSERT_NOT_REACHED(); 192 ASSERT_NOT_REACHED();
197 return kNotFound; 193 return kNotFound;
198 } 194 }
199 } 195 }
200 196
201 } // namespace WebCore 197 } // 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