| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 { | 69 { |
| 70 return adoptPtr(new DeferredImageDecoder(std::move(actualDecoder))); | 70 return adoptPtr(new DeferredImageDecoder(std::move(actualDecoder))); |
| 71 } | 71 } |
| 72 | 72 |
| 73 DeferredImageDecoder::DeferredImageDecoder(PassOwnPtr<ImageDecoder> actualDecode
r) | 73 DeferredImageDecoder::DeferredImageDecoder(PassOwnPtr<ImageDecoder> actualDecode
r) |
| 74 : m_allDataReceived(false) | 74 : m_allDataReceived(false) |
| 75 , m_actualDecoder(std::move(actualDecoder)) | 75 , m_actualDecoder(std::move(actualDecoder)) |
| 76 , m_repetitionCount(cAnimationNone) | 76 , m_repetitionCount(cAnimationNone) |
| 77 , m_hasColorProfile(false) | 77 , m_hasColorProfile(false) |
| 78 , m_canYUVDecode(false) | 78 , m_canYUVDecode(false) |
| 79 , m_hasHotSpot(false) | |
| 80 { | 79 { |
| 81 } | 80 } |
| 82 | 81 |
| 83 DeferredImageDecoder::~DeferredImageDecoder() | 82 DeferredImageDecoder::~DeferredImageDecoder() |
| 84 { | 83 { |
| 85 } | 84 } |
| 86 | 85 |
| 87 String DeferredImageDecoder::filenameExtension() const | 86 String DeferredImageDecoder::filenameExtension() const |
| 88 { | 87 { |
| 89 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx
tension; | 88 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx
tension; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 return m_frameData[index].m_orientation; | 228 return m_frameData[index].m_orientation; |
| 230 return DefaultImageOrientation; | 229 return DefaultImageOrientation; |
| 231 } | 230 } |
| 232 | 231 |
| 233 void DeferredImageDecoder::activateLazyDecoding() | 232 void DeferredImageDecoder::activateLazyDecoding() |
| 234 { | 233 { |
| 235 if (m_frameGenerator) | 234 if (m_frameGenerator) |
| 236 return; | 235 return; |
| 237 | 236 |
| 238 m_size = m_actualDecoder->size(); | 237 m_size = m_actualDecoder->size(); |
| 239 m_hasHotSpot = m_actualDecoder->hotSpot(m_hotSpot); | |
| 240 m_filenameExtension = m_actualDecoder->filenameExtension(); | 238 m_filenameExtension = m_actualDecoder->filenameExtension(); |
| 241 // JPEG images support YUV decoding: other decoders do not, WEBP could in fu
ture. | 239 // JPEG images support YUV decoding: other decoders do not, WEBP could in fu
ture. |
| 242 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() && (m_filename
Extension == "jpg"); | 240 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() && (m_filename
Extension == "jpg"); |
| 243 m_hasColorProfile = m_actualDecoder->hasColorProfile(); | 241 m_hasColorProfile = m_actualDecoder->hasColorProfile(); |
| 244 | 242 |
| 245 const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN
one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u); | 243 const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN
one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u); |
| 246 const SkISize decodedSize = SkISize::Make(m_actualDecoder->decodedSize().wid
th(), m_actualDecoder->decodedSize().height()); | 244 const SkISize decodedSize = SkISize::Make(m_actualDecoder->decodedSize().wid
th(), m_actualDecoder->decodedSize().height()); |
| 247 m_frameGenerator = ImageFrameGenerator::create(decodedSize, !isSingleFrame); | 245 m_frameGenerator = ImageFrameGenerator::create(decodedSize, !isSingleFrame); |
| 248 } | 246 } |
| 249 | 247 |
| 250 void DeferredImageDecoder::prepareLazyDecodedFrames() | 248 void DeferredImageDecoder::prepareLazyDecodedFrames() |
| 251 { | 249 { |
| 252 if (!m_actualDecoder | 250 if (!m_actualDecoder |
| 253 || !m_actualDecoder->isSizeAvailable()) | 251 || !m_actualDecoder->isSizeAvailable() |
| 252 || m_actualDecoder->filenameExtension() == "ico") |
| 254 return; | 253 return; |
| 255 | 254 |
| 256 activateLazyDecoding(); | 255 activateLazyDecoding(); |
| 257 | 256 |
| 258 const size_t previousSize = m_frameData.size(); | 257 const size_t previousSize = m_frameData.size(); |
| 259 m_frameData.resize(m_actualDecoder->frameCount()); | 258 m_frameData.resize(m_actualDecoder->frameCount()); |
| 260 | 259 |
| 261 // We have encountered a broken image file. Simply bail. | 260 // We have encountered a broken image file. Simply bail. |
| 262 if (m_frameData.size() < previousSize) | 261 if (m_frameData.size() < previousSize) |
| 263 return; | 262 return; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 m_frameData[index].m_uniqueID = image->uniqueID(); | 307 m_frameData[index].m_uniqueID = image->uniqueID(); |
| 309 } | 308 } |
| 310 | 309 |
| 311 generator->setCanYUVDecode(m_canYUVDecode); | 310 generator->setCanYUVDecode(m_canYUVDecode); |
| 312 | 311 |
| 313 return image.release(); | 312 return image.release(); |
| 314 } | 313 } |
| 315 | 314 |
| 316 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const | 315 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const |
| 317 { | 316 { |
| 318 if (m_actualDecoder) | 317 // TODO: Implement. |
| 319 return m_actualDecoder->hotSpot(hotSpot); | 318 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; |
| 320 if (m_hasHotSpot) | |
| 321 hotSpot = m_hotSpot; | |
| 322 return m_hasHotSpot; | |
| 323 } | 319 } |
| 324 | 320 |
| 325 } // namespace blink | 321 } // namespace blink |
| 326 | 322 |
| 327 namespace WTF { | 323 namespace WTF { |
| 328 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec
torTraits<blink::DeferredFrameData> { | 324 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec
torTraits<blink::DeferredFrameData> { |
| 329 STATIC_ONLY(VectorTraits); | 325 STATIC_ONLY(VectorTraits); |
| 330 static const bool canInitializeWithMemset = false; // Not all DeferredFrameD
ata members initialize to 0. | 326 static const bool canInitializeWithMemset = false; // Not all DeferredFrameD
ata members initialize to 0. |
| 331 }; | 327 }; |
| 332 } | 328 } |
| OLD | NEW |