OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 181 |
182 bool DeferredImageDecoder::frameHasAlphaAtIndex(size_t index) const | 182 bool DeferredImageDecoder::frameHasAlphaAtIndex(size_t index) const |
183 { | 183 { |
184 if (m_actualDecoder) | 184 if (m_actualDecoder) |
185 return m_actualDecoder->frameHasAlphaAtIndex(index); | 185 return m_actualDecoder->frameHasAlphaAtIndex(index); |
186 if (!m_frameGenerator->isMultiFrame()) | 186 if (!m_frameGenerator->isMultiFrame()) |
187 return m_frameGenerator->hasAlpha(index); | 187 return m_frameGenerator->hasAlpha(index); |
188 return true; | 188 return true; |
189 } | 189 } |
190 | 190 |
191 bool DeferredImageDecoder::frameIsCompleteAtIndex(size_t index) const | 191 bool DeferredImageDecoder::frameIsFullyReceivedAtIndex(size_t index) const |
192 { | 192 { |
193 if (m_actualDecoder) | 193 if (m_actualDecoder) |
194 return m_actualDecoder->frameIsCompleteAtIndex(index); | 194 return m_actualDecoder->frameIsFullyReceivedAtIndex(index); |
195 if (index < m_frameData.size()) | 195 if (index < m_frameData.size()) |
196 return m_frameData[index].m_isComplete; | 196 return m_frameData[index].m_isFullyReceived; |
197 return false; | 197 return false; |
198 } | 198 } |
199 | 199 |
200 float DeferredImageDecoder::frameDurationAtIndex(size_t index) const | 200 float DeferredImageDecoder::frameDurationAtIndex(size_t index) const |
201 { | 201 { |
202 if (m_actualDecoder) | 202 if (m_actualDecoder) |
203 return m_actualDecoder->frameDurationAtIndex(index); | 203 return m_actualDecoder->frameDurationAtIndex(index); |
204 if (index < m_frameData.size()) | 204 if (index < m_frameData.size()) |
205 return m_frameData[index].m_duration; | 205 return m_frameData[index].m_duration; |
206 return 0; | 206 return 0; |
(...skipping 30 matching lines...) Expand all Loading... |
237 | 237 |
238 const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN
one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u); | 238 const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN
one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u); |
239 const SkISize decodedSize = SkISize::Make(m_actualDecoder->decodedSize().wid
th(), m_actualDecoder->decodedSize().height()); | 239 const SkISize decodedSize = SkISize::Make(m_actualDecoder->decodedSize().wid
th(), m_actualDecoder->decodedSize().height()); |
240 m_frameGenerator = ImageFrameGenerator::create(decodedSize, !isSingleFrame); | 240 m_frameGenerator = ImageFrameGenerator::create(decodedSize, !isSingleFrame); |
241 } | 241 } |
242 | 242 |
243 void DeferredImageDecoder::prepareLazyDecodedFrames() | 243 void DeferredImageDecoder::prepareLazyDecodedFrames() |
244 { | 244 { |
245 if (!s_enabled | 245 if (!s_enabled |
246 || !m_actualDecoder | 246 || !m_actualDecoder |
247 || !m_actualDecoder->isSizeAvailable() | 247 || !m_actualDecoder->isSizeAvailable()) |
248 || m_actualDecoder->filenameExtension() == "ico") | |
249 return; | 248 return; |
250 | 249 |
251 activateLazyDecoding(); | 250 activateLazyDecoding(); |
252 | 251 |
253 const size_t previousSize = m_frameData.size(); | 252 const size_t previousSize = m_frameData.size(); |
254 m_frameData.resize(m_actualDecoder->frameCount()); | 253 m_frameData.resize(m_actualDecoder->frameCount()); |
255 | 254 |
256 // We have encountered a broken image file. Simply bail. | 255 // We have encountered a broken image file. Simply bail. |
257 if (m_frameData.size() < previousSize) | 256 if (m_frameData.size() < previousSize) |
258 return; | 257 return; |
259 | 258 |
260 for (size_t i = previousSize; i < m_frameData.size(); ++i) { | 259 for (size_t i = previousSize; i < m_frameData.size(); ++i) { |
261 m_frameData[i].m_haveMetadata = true; | 260 m_frameData[i].m_haveMetadata = true; |
262 m_frameData[i].m_duration = m_actualDecoder->frameDurationAtIndex(i); | 261 m_frameData[i].m_duration = m_actualDecoder->frameDurationAtIndex(i); |
263 m_frameData[i].m_orientation = m_actualDecoder->orientation(); | 262 m_frameData[i].m_orientation = m_actualDecoder->orientation(); |
264 m_frameData[i].m_isComplete = m_actualDecoder->frameIsCompleteAtIndex(i)
; | 263 m_frameData[i].m_isFullyReceived = m_actualDecoder->frameIsFullyReceived
AtIndex(i); |
265 } | 264 } |
266 | 265 |
267 // The last lazy decoded frame created from previous call might be | 266 // The last lazy decoded frame created from previous call might be |
268 // incomplete so update its state. | 267 // incomplete so update its state. |
269 if (previousSize) { | 268 if (previousSize) { |
270 const size_t lastFrame = previousSize - 1; | 269 const size_t lastFrame = previousSize - 1; |
271 m_frameData[lastFrame].m_isComplete = m_actualDecoder->frameIsCompleteAt
Index(lastFrame); | 270 m_frameData[lastFrame].m_isFullyReceived = m_actualDecoder->frameIsFully
ReceivedAtIndex(lastFrame); |
272 } | 271 } |
273 | 272 |
274 if (m_allDataReceived) { | 273 if (m_allDataReceived) { |
275 m_repetitionCount = m_actualDecoder->repetitionCount(); | 274 m_repetitionCount = m_actualDecoder->repetitionCount(); |
276 m_actualDecoder.clear(); | 275 m_actualDecoder.clear(); |
277 // Hold on to m_rwBuffer, which is still needed by createFrameAtIndex. | 276 // Hold on to m_rwBuffer, which is still needed by createFrameAtIndex. |
278 } | 277 } |
279 } | 278 } |
280 | 279 |
281 inline SkImageInfo imageInfoFrom(const SkISize& decodedSize, bool knownToBeOpaqu
e) | 280 inline SkImageInfo imageInfoFrom(const SkISize& decodedSize, bool knownToBeOpaqu
e) |
(...skipping 19 matching lines...) Expand all Loading... |
301 return image.release(); | 300 return image.release(); |
302 } | 301 } |
303 | 302 |
304 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const | 303 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const |
305 { | 304 { |
306 // TODO: Implement. | 305 // TODO: Implement. |
307 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; | 306 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; |
308 } | 307 } |
309 | 308 |
310 } // namespace blink | 309 } // namespace blink |
OLD | NEW |