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