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

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: 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. 137 // Don't clear if there are no frames or only one frame, and we're not
138 if (m_frameBufferCache.size() <= 1) 138 // specifically requested to clear all frames.
139 if (m_frameBufferCache.size() <= 1 && clearExceptFrame != kNotFound)
139 return 0; 140 return 0;
Peter Kasting 2014/01/14 00:46:18 Nit: Can't we just implement this by removing this
fs 2014/01/14 08:32:09 Yes, true. Will drop this block.
140 141
141 size_t frameBytesCleared = 0; 142 size_t frameBytesCleared = 0;
142 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) { 143 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) {
143 if (i != clearExceptFrame) { 144 if (i != clearExceptFrame) {
144 frameBytesCleared += frameBytesAtIndex(i); 145 frameBytesCleared += frameBytesAtIndex(i);
145 clearFrameBuffer(i); 146 clearFrameBuffer(i);
146 } 147 }
147 } 148 }
148 return frameBytesCleared; 149 return frameBytesCleared;
149 } 150 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Otherwise, the previous frame contributes to this frame. 193 // Otherwise, the previous frame contributes to this frame.
193 return (prevBuffer->originalFrameRect().contains(IntRect(IntPoint(), siz e())) 194 return (prevBuffer->originalFrameRect().contains(IntRect(IntPoint(), siz e()))
194 || (prevBuffer->requiredPreviousFrameIndex() == kNotFound)) ? kNotFo und : prevFrame; 195 || (prevBuffer->requiredPreviousFrameIndex() == kNotFound)) ? kNotFo und : prevFrame;
195 default: 196 default:
196 ASSERT_NOT_REACHED(); 197 ASSERT_NOT_REACHED();
197 return kNotFound; 198 return kNotFound;
198 } 199 }
199 } 200 }
200 201
201 } // namespace WebCore 202 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698