OLD | NEW |
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 info.addMember(m_data, "data"); | 139 info.addMember(m_data, "data"); |
140 info.addMember(m_frameBufferCache, "frameBufferCache"); | 140 info.addMember(m_frameBufferCache, "frameBufferCache"); |
141 } | 141 } |
142 | 142 |
143 size_t ImageDecoder::clearCacheExceptFrame(size_t clearExceptFrame) | 143 size_t ImageDecoder::clearCacheExceptFrame(size_t clearExceptFrame) |
144 { | 144 { |
145 // Don't clear if there are no frames or only one frame. | 145 // Don't clear if there are no frames or only one frame. |
146 if (m_frameBufferCache.size() <= 1) | 146 if (m_frameBufferCache.size() <= 1) |
147 return 0; | 147 return 0; |
148 | 148 |
149 // We need to preserve frames such that: | |
150 // 1. We don't clear |clearExceptFrame|; | |
151 // 2. We don't clear any frame from which a future initFrameBuffer() call | |
152 // will copy bitmap data. | |
153 // All other frames can be cleared. | |
154 while ((clearExceptFrame < m_frameBufferCache.size()) && (m_frameBufferCache
[clearExceptFrame].status() == ImageFrame::FrameEmpty)) | |
155 clearExceptFrame = m_frameBufferCache[clearExceptFrame].requiredPrevious
FrameIndex(); | |
156 | |
157 size_t frameBytesCleared = 0; | 149 size_t frameBytesCleared = 0; |
158 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) { | 150 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) { |
159 if (i != clearExceptFrame) { | 151 if (i != clearExceptFrame) { |
160 frameBytesCleared += frameBytesAtIndex(i); | 152 frameBytesCleared += frameBytesAtIndex(i); |
161 clearFrameBuffer(i); | 153 clearFrameBuffer(i); |
162 } | 154 } |
163 } | 155 } |
164 return frameBytesCleared; | 156 return frameBytesCleared; |
165 } | 157 } |
166 | 158 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // Otherwise, the previous frame contributes to this frame. | 195 // Otherwise, the previous frame contributes to this frame. |
204 return (prevBuffer->originalFrameRect().contains(IntRect(IntPoint(), siz
e())) | 196 return (prevBuffer->originalFrameRect().contains(IntRect(IntPoint(), siz
e())) |
205 || (prevBuffer->requiredPreviousFrameIndex() == notFound)) ? notFoun
d : prevFrame; | 197 || (prevBuffer->requiredPreviousFrameIndex() == notFound)) ? notFoun
d : prevFrame; |
206 default: | 198 default: |
207 ASSERT_NOT_REACHED(); | 199 ASSERT_NOT_REACHED(); |
208 return notFound; | 200 return notFound; |
209 } | 201 } |
210 } | 202 } |
211 | 203 |
212 } // namespace WebCore | 204 } // namespace WebCore |
OLD | NEW |