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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 , m_uniqueID(DecodingImageGenerator::kNeedNewImageUniqueID) | 48 , m_uniqueID(DecodingImageGenerator::kNeedNewImageUniqueID) |
49 {} | 49 {} |
50 | 50 |
51 ImageOrientation m_orientation; | 51 ImageOrientation m_orientation; |
52 float m_duration; | 52 float m_duration; |
53 bool m_isComplete; | 53 bool m_isComplete; |
54 size_t m_frameBytes; | 54 size_t m_frameBytes; |
55 uint32_t m_uniqueID; | 55 uint32_t m_uniqueID; |
56 }; | 56 }; |
57 | 57 |
58 bool DeferredImageDecoder::s_enabled = true; | |
59 | |
60 PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::create(const SharedBuffer
& data, ImageDecoder::AlphaOption alphaOption, ImageDecoder::GammaAndColorProfil
eOption colorOptions) | 58 PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::create(const SharedBuffer
& data, ImageDecoder::AlphaOption alphaOption, ImageDecoder::GammaAndColorProfil
eOption colorOptions) |
61 { | 59 { |
62 OwnPtr<ImageDecoder> actualDecoder = ImageDecoder::create(data, alphaOption,
colorOptions); | 60 OwnPtr<ImageDecoder> actualDecoder = ImageDecoder::create(data, alphaOption,
colorOptions); |
63 | 61 |
64 if (!actualDecoder) | 62 if (!actualDecoder) |
65 return nullptr; | 63 return nullptr; |
66 | 64 |
67 return adoptPtr(new DeferredImageDecoder(std::move(actualDecoder))); | 65 return adoptPtr(new DeferredImageDecoder(std::move(actualDecoder))); |
68 } | 66 } |
69 | 67 |
70 PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::createForTesting(PassOwnP
tr<ImageDecoder> actualDecoder) | 68 PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::createForTesting(PassOwnP
tr<ImageDecoder> actualDecoder) |
71 { | 69 { |
72 return adoptPtr(new DeferredImageDecoder(std::move(actualDecoder))); | 70 return adoptPtr(new DeferredImageDecoder(std::move(actualDecoder))); |
73 } | 71 } |
74 | 72 |
75 DeferredImageDecoder::DeferredImageDecoder(PassOwnPtr<ImageDecoder> actualDecode
r) | 73 DeferredImageDecoder::DeferredImageDecoder(PassOwnPtr<ImageDecoder> actualDecode
r) |
76 : m_allDataReceived(false) | 74 : m_allDataReceived(false) |
77 , m_actualDecoder(std::move(actualDecoder)) | 75 , m_actualDecoder(std::move(actualDecoder)) |
78 , m_repetitionCount(cAnimationNone) | 76 , m_repetitionCount(cAnimationNone) |
79 , m_hasColorProfile(false) | 77 , m_hasColorProfile(false) |
80 , m_canYUVDecode(false) | 78 , m_canYUVDecode(false) |
81 { | 79 { |
82 } | 80 } |
83 | 81 |
84 DeferredImageDecoder::~DeferredImageDecoder() | 82 DeferredImageDecoder::~DeferredImageDecoder() |
85 { | 83 { |
86 } | 84 } |
87 | 85 |
88 void DeferredImageDecoder::setEnabled(bool enabled) | |
89 { | |
90 s_enabled = enabled; | |
91 } | |
92 | |
93 bool DeferredImageDecoder::enabled() | |
94 { | |
95 return s_enabled; | |
96 } | |
97 | |
98 String DeferredImageDecoder::filenameExtension() const | 86 String DeferredImageDecoder::filenameExtension() const |
99 { | 87 { |
100 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx
tension; | 88 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx
tension; |
101 } | 89 } |
102 | 90 |
103 PassRefPtr<SkImage> DeferredImageDecoder::createFrameAtIndex(size_t index) | 91 PassRefPtr<SkImage> DeferredImageDecoder::createFrameAtIndex(size_t index) |
104 { | 92 { |
105 if (m_frameGenerator && m_frameGenerator->decodeFailed()) | 93 if (m_frameGenerator && m_frameGenerator->decodeFailed()) |
106 return nullptr; | 94 return nullptr; |
107 | 95 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() && (m_filename
Extension == "jpg"); | 240 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() && (m_filename
Extension == "jpg"); |
253 m_hasColorProfile = m_actualDecoder->hasColorProfile(); | 241 m_hasColorProfile = m_actualDecoder->hasColorProfile(); |
254 | 242 |
255 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); |
256 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()); |
257 m_frameGenerator = ImageFrameGenerator::create(decodedSize, !isSingleFrame); | 245 m_frameGenerator = ImageFrameGenerator::create(decodedSize, !isSingleFrame); |
258 } | 246 } |
259 | 247 |
260 void DeferredImageDecoder::prepareLazyDecodedFrames() | 248 void DeferredImageDecoder::prepareLazyDecodedFrames() |
261 { | 249 { |
262 if (!s_enabled | 250 if (!m_actualDecoder |
263 || !m_actualDecoder | |
264 || !m_actualDecoder->isSizeAvailable() | 251 || !m_actualDecoder->isSizeAvailable() |
265 || m_actualDecoder->filenameExtension() == "ico") | 252 || m_actualDecoder->filenameExtension() == "ico") |
266 return; | 253 return; |
267 | 254 |
268 activateLazyDecoding(); | 255 activateLazyDecoding(); |
269 | 256 |
270 const size_t previousSize = m_frameData.size(); | 257 const size_t previousSize = m_frameData.size(); |
271 m_frameData.resize(m_actualDecoder->frameCount()); | 258 m_frameData.resize(m_actualDecoder->frameCount()); |
272 | 259 |
273 // We have encountered a broken image file. Simply bail. | 260 // We have encountered a broken image file. Simply bail. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 319 } |
333 | 320 |
334 } // namespace blink | 321 } // namespace blink |
335 | 322 |
336 namespace WTF { | 323 namespace WTF { |
337 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec
torTraits<blink::DeferredFrameData> { | 324 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec
torTraits<blink::DeferredFrameData> { |
338 STATIC_ONLY(VectorTraits); | 325 STATIC_ONLY(VectorTraits); |
339 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. |
340 }; | 327 }; |
341 } | 328 } |
OLD | NEW |