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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 float m_duration; | 54 float m_duration; |
55 bool m_isComplete; | 55 bool m_isComplete; |
56 size_t m_frameBytes; | 56 size_t m_frameBytes; |
57 uint32_t m_uniqueID; | 57 uint32_t m_uniqueID; |
58 }; | 58 }; |
59 | 59 |
60 std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::create( | 60 std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::create( |
61 PassRefPtr<SharedBuffer> passData, | 61 PassRefPtr<SharedBuffer> passData, |
62 bool dataComplete, | 62 bool dataComplete, |
63 ImageDecoder::AlphaOption alphaOption, | 63 ImageDecoder::AlphaOption alphaOption, |
64 ImageDecoder::GammaAndColorProfileOption colorOptions) { | 64 ImageDecoder::ColorSpaceOption colorOptions) { |
65 RefPtr<SharedBuffer> data = passData; | 65 RefPtr<SharedBuffer> data = passData; |
66 | 66 |
67 std::unique_ptr<ImageDecoder> actualDecoder = | 67 std::unique_ptr<ImageDecoder> actualDecoder = |
68 ImageDecoder::create(data, dataComplete, alphaOption, colorOptions); | 68 ImageDecoder::create(data, dataComplete, alphaOption, colorOptions); |
69 | 69 |
70 if (!actualDecoder) | 70 if (!actualDecoder) |
71 return nullptr; | 71 return nullptr; |
72 | 72 |
73 std::unique_ptr<DeferredImageDecoder> decoder( | 73 std::unique_ptr<DeferredImageDecoder> decoder( |
74 new DeferredImageDecoder(std::move(actualDecoder))); | 74 new DeferredImageDecoder(std::move(actualDecoder))); |
75 | 75 |
76 // Since we've just instantiated a fresh decoder, there's no need to reset its | 76 // Since we've just instantiated a fresh decoder, there's no need to reset its |
77 // data. | 77 // data. |
78 decoder->setDataInternal(data.release(), dataComplete, false); | 78 decoder->setDataInternal(data.release(), dataComplete, false); |
79 | 79 |
80 return decoder; | 80 return decoder; |
81 } | 81 } |
82 | 82 |
83 std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::createForTesting( | 83 std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::createForTesting( |
84 std::unique_ptr<ImageDecoder> actualDecoder) { | 84 std::unique_ptr<ImageDecoder> actualDecoder) { |
85 return wrapUnique(new DeferredImageDecoder(std::move(actualDecoder))); | 85 return wrapUnique(new DeferredImageDecoder(std::move(actualDecoder))); |
86 } | 86 } |
87 | 87 |
88 DeferredImageDecoder::DeferredImageDecoder( | 88 DeferredImageDecoder::DeferredImageDecoder( |
89 std::unique_ptr<ImageDecoder> actualDecoder) | 89 std::unique_ptr<ImageDecoder> actualDecoder) |
90 : m_allDataReceived(false), | 90 : m_allDataReceived(false), |
91 m_actualDecoder(std::move(actualDecoder)), | 91 m_actualDecoder(std::move(actualDecoder)), |
92 m_repetitionCount(cAnimationNone), | 92 m_repetitionCount(cAnimationNone), |
93 m_hasColorProfile(false), | 93 m_hasColorSpace(false), |
94 m_canYUVDecode(false), | 94 m_canYUVDecode(false), |
95 m_hasHotSpot(false) {} | 95 m_hasHotSpot(false) {} |
96 | 96 |
97 DeferredImageDecoder::~DeferredImageDecoder() {} | 97 DeferredImageDecoder::~DeferredImageDecoder() {} |
98 | 98 |
99 String DeferredImageDecoder::filenameExtension() const { | 99 String DeferredImageDecoder::filenameExtension() const { |
100 return m_actualDecoder ? m_actualDecoder->filenameExtension() | 100 return m_actualDecoder ? m_actualDecoder->filenameExtension() |
101 : m_filenameExtension; | 101 : m_filenameExtension; |
102 } | 102 } |
103 | 103 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 172 } |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 bool DeferredImageDecoder::isSizeAvailable() { | 176 bool DeferredImageDecoder::isSizeAvailable() { |
177 // m_actualDecoder is 0 only if image decoding is deferred and that means | 177 // m_actualDecoder is 0 only if image decoding is deferred and that means |
178 // the image header decoded successfully and the size is available. | 178 // the image header decoded successfully and the size is available. |
179 return m_actualDecoder ? m_actualDecoder->isSizeAvailable() : true; | 179 return m_actualDecoder ? m_actualDecoder->isSizeAvailable() : true; |
180 } | 180 } |
181 | 181 |
182 bool DeferredImageDecoder::hasColorProfile() const { | 182 bool DeferredImageDecoder::hasColorSpace() const { |
183 return m_actualDecoder ? m_actualDecoder->hasColorProfile() | 183 return m_actualDecoder ? m_actualDecoder->hasColorSpace() : m_hasColorSpace; |
184 : m_hasColorProfile; | |
185 } | 184 } |
186 | 185 |
187 IntSize DeferredImageDecoder::size() const { | 186 IntSize DeferredImageDecoder::size() const { |
188 return m_actualDecoder ? m_actualDecoder->size() : m_size; | 187 return m_actualDecoder ? m_actualDecoder->size() : m_size; |
189 } | 188 } |
190 | 189 |
191 IntSize DeferredImageDecoder::frameSizeAtIndex(size_t index) const { | 190 IntSize DeferredImageDecoder::frameSizeAtIndex(size_t index) const { |
192 // FIXME: LocalFrame size is assumed to be uniform. This might not be true for | 191 // FIXME: LocalFrame size is assumed to be uniform. This might not be true for |
193 // future supported codecs. | 192 // future supported codecs. |
194 return m_actualDecoder ? m_actualDecoder->frameSizeAtIndex(index) : m_size; | 193 return m_actualDecoder ? m_actualDecoder->frameSizeAtIndex(index) : m_size; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 if (m_frameGenerator) | 259 if (m_frameGenerator) |
261 return; | 260 return; |
262 | 261 |
263 m_size = m_actualDecoder->size(); | 262 m_size = m_actualDecoder->size(); |
264 m_hasHotSpot = m_actualDecoder->hotSpot(m_hotSpot); | 263 m_hasHotSpot = m_actualDecoder->hotSpot(m_hotSpot); |
265 m_filenameExtension = m_actualDecoder->filenameExtension(); | 264 m_filenameExtension = m_actualDecoder->filenameExtension(); |
266 // JPEG images support YUV decoding; other decoders do not. (WebP could in the | 265 // JPEG images support YUV decoding; other decoders do not. (WebP could in the |
267 // future.) | 266 // future.) |
268 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() && | 267 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() && |
269 (m_filenameExtension == "jpg"); | 268 (m_filenameExtension == "jpg"); |
270 m_hasColorProfile = m_actualDecoder->hasColorProfile(); | 269 m_hasColorSpace = m_actualDecoder->hasColorSpace(); |
271 | 270 |
272 const bool isSingleFrame = | 271 const bool isSingleFrame = |
273 m_actualDecoder->repetitionCount() == cAnimationNone || | 272 m_actualDecoder->repetitionCount() == cAnimationNone || |
274 (m_allDataReceived && m_actualDecoder->frameCount() == 1u); | 273 (m_allDataReceived && m_actualDecoder->frameCount() == 1u); |
275 const SkISize decodedSize = | 274 const SkISize decodedSize = |
276 SkISize::Make(m_actualDecoder->decodedSize().width(), | 275 SkISize::Make(m_actualDecoder->decodedSize().width(), |
277 m_actualDecoder->decodedSize().height()); | 276 m_actualDecoder->decodedSize().height()); |
278 m_frameGenerator = ImageFrameGenerator::create(decodedSize, !isSingleFrame); | 277 m_frameGenerator = ImageFrameGenerator::create(decodedSize, !isSingleFrame); |
279 } | 278 } |
280 | 279 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 364 |
366 namespace WTF { | 365 namespace WTF { |
367 template <> | 366 template <> |
368 struct VectorTraits<blink::DeferredFrameData> | 367 struct VectorTraits<blink::DeferredFrameData> |
369 : public SimpleClassVectorTraits<blink::DeferredFrameData> { | 368 : public SimpleClassVectorTraits<blink::DeferredFrameData> { |
370 STATIC_ONLY(VectorTraits); | 369 STATIC_ONLY(VectorTraits); |
371 static const bool canInitializeWithMemset = | 370 static const bool canInitializeWithMemset = |
372 false; // Not all DeferredFrameData members initialize to 0. | 371 false; // Not all DeferredFrameData members initialize to 0. |
373 }; | 372 }; |
374 } | 373 } |
OLD | NEW |