| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "platform/graphics/DeferredImageDecoder.h" | 26 #include "platform/graphics/DeferredImageDecoder.h" |
| 27 | 27 |
| 28 #include "platform/RuntimeEnabledFeatures.h" | 28 #include "platform/RuntimeEnabledFeatures.h" |
| 29 #include "platform/graphics/ColorSpaceFilter.h" |
| 29 #include "platform/graphics/DecodingImageGenerator.h" | 30 #include "platform/graphics/DecodingImageGenerator.h" |
| 30 #include "platform/graphics/FrameData.h" | 31 #include "platform/graphics/FrameData.h" |
| 31 #include "platform/graphics/ImageDecodingStore.h" | 32 #include "platform/graphics/ImageDecodingStore.h" |
| 32 #include "platform/graphics/ImageFrameGenerator.h" | 33 #include "platform/graphics/ImageFrameGenerator.h" |
| 33 #include "third_party/skia/include/core/SkImage.h" | 34 #include "third_party/skia/include/core/SkImage.h" |
| 34 #include "wtf/PassOwnPtr.h" | 35 #include "wtf/PassOwnPtr.h" |
| 35 | 36 |
| 36 namespace blink { | 37 namespace blink { |
| 37 | 38 |
| 38 bool DeferredImageDecoder::s_enabled = true; | 39 bool DeferredImageDecoder::s_enabled = true; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::createForTesting(PassOwnP
tr<ImageDecoder> actualDecoder) | 51 PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::createForTesting(PassOwnP
tr<ImageDecoder> actualDecoder) |
| 51 { | 52 { |
| 52 return adoptPtr(new DeferredImageDecoder(std::move(actualDecoder))); | 53 return adoptPtr(new DeferredImageDecoder(std::move(actualDecoder))); |
| 53 } | 54 } |
| 54 | 55 |
| 55 DeferredImageDecoder::DeferredImageDecoder(PassOwnPtr<ImageDecoder> actualDecode
r) | 56 DeferredImageDecoder::DeferredImageDecoder(PassOwnPtr<ImageDecoder> actualDecode
r) |
| 56 : m_allDataReceived(false) | 57 : m_allDataReceived(false) |
| 57 , m_lastDataSize(0) | 58 , m_lastDataSize(0) |
| 58 , m_actualDecoder(std::move(actualDecoder)) | 59 , m_actualDecoder(std::move(actualDecoder)) |
| 59 , m_repetitionCount(cAnimationNone) | 60 , m_repetitionCount(cAnimationNone) |
| 61 , m_canYUVDecode(false) |
| 60 , m_hasColorProfile(false) | 62 , m_hasColorProfile(false) |
| 61 , m_canYUVDecode(false) | |
| 62 { | 63 { |
| 63 } | 64 } |
| 64 | 65 |
| 65 DeferredImageDecoder::~DeferredImageDecoder() | 66 DeferredImageDecoder::~DeferredImageDecoder() |
| 66 { | 67 { |
| 67 } | 68 } |
| 68 | 69 |
| 69 void DeferredImageDecoder::setEnabled(bool enabled) | 70 void DeferredImageDecoder::setEnabled(bool enabled) |
| 70 { | 71 { |
| 71 s_enabled = enabled; | 72 s_enabled = enabled; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // m_actualDecoder is 0 only if image decoding is deferred and that means | 128 // m_actualDecoder is 0 only if image decoding is deferred and that means |
| 128 // the image header decoded successfully and the size is available. | 129 // the image header decoded successfully and the size is available. |
| 129 return m_actualDecoder ? m_actualDecoder->isSizeAvailable() : true; | 130 return m_actualDecoder ? m_actualDecoder->isSizeAvailable() : true; |
| 130 } | 131 } |
| 131 | 132 |
| 132 bool DeferredImageDecoder::hasColorProfile() const | 133 bool DeferredImageDecoder::hasColorProfile() const |
| 133 { | 134 { |
| 134 return m_actualDecoder ? m_actualDecoder->hasColorProfile() : m_hasColorProf
ile; | 135 return m_actualDecoder ? m_actualDecoder->hasColorProfile() : m_hasColorProf
ile; |
| 135 } | 136 } |
| 136 | 137 |
| 138 PassRefPtr<ColorSpaceProfile> DeferredImageDecoder::colorProfile() const |
| 139 { |
| 140 if (m_actualDecoder) |
| 141 return m_actualDecoder->colorProfile(); |
| 142 |
| 143 return m_colorProfile; |
| 144 } |
| 145 |
| 137 IntSize DeferredImageDecoder::size() const | 146 IntSize DeferredImageDecoder::size() const |
| 138 { | 147 { |
| 139 return m_actualDecoder ? m_actualDecoder->size() : m_size; | 148 return m_actualDecoder ? m_actualDecoder->size() : m_size; |
| 140 } | 149 } |
| 141 | 150 |
| 142 IntSize DeferredImageDecoder::frameSizeAtIndex(size_t index) const | 151 IntSize DeferredImageDecoder::frameSizeAtIndex(size_t index) const |
| 143 { | 152 { |
| 144 // FIXME: LocalFrame size is assumed to be uniform. This might not be true f
or | 153 // FIXME: LocalFrame size is assumed to be uniform. This might not be true f
or |
| 145 // future supported codecs. | 154 // future supported codecs. |
| 146 return m_actualDecoder ? m_actualDecoder->frameSizeAtIndex(index) : m_size; | 155 return m_actualDecoder ? m_actualDecoder->frameSizeAtIndex(index) : m_size; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 void DeferredImageDecoder::activateLazyDecoding() | 227 void DeferredImageDecoder::activateLazyDecoding() |
| 219 { | 228 { |
| 220 if (m_frameGenerator) | 229 if (m_frameGenerator) |
| 221 return; | 230 return; |
| 222 | 231 |
| 223 m_size = m_actualDecoder->size(); | 232 m_size = m_actualDecoder->size(); |
| 224 m_filenameExtension = m_actualDecoder->filenameExtension(); | 233 m_filenameExtension = m_actualDecoder->filenameExtension(); |
| 225 // JPEG images support YUV decoding: other decoders do not, WEBP could in fu
ture. | 234 // JPEG images support YUV decoding: other decoders do not, WEBP could in fu
ture. |
| 226 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() && (m_filename
Extension == "jpg"); | 235 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() && (m_filename
Extension == "jpg"); |
| 227 m_hasColorProfile = m_actualDecoder->hasColorProfile(); | 236 m_hasColorProfile = m_actualDecoder->hasColorProfile(); |
| 237 m_colorProfile = m_hasColorProfile ? m_actualDecoder->colorProfile() : nullp
tr; |
| 228 | 238 |
| 229 const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN
one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u); | 239 const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN
one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u); |
| 230 m_frameGenerator = ImageFrameGenerator::create(SkISize::Make(m_actualDecoder
->decodedSize().width(), m_actualDecoder->decodedSize().height()), m_data, m_all
DataReceived, !isSingleFrame); | 240 m_frameGenerator = ImageFrameGenerator::create(SkISize::Make(m_actualDecoder
->decodedSize().width(), m_actualDecoder->decodedSize().height()), m_data, m_all
DataReceived, !isSingleFrame); |
| 231 } | 241 } |
| 232 | 242 |
| 233 void DeferredImageDecoder::prepareLazyDecodedFrames() | 243 void DeferredImageDecoder::prepareLazyDecodedFrames() |
| 234 { | 244 { |
| 235 if (!s_enabled | 245 if (!s_enabled |
| 236 || !m_actualDecoder | 246 || !m_actualDecoder |
| 237 || !m_actualDecoder->isSizeAvailable() | 247 || !m_actualDecoder->isSizeAvailable() |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 return image.release(); | 300 return image.release(); |
| 291 } | 301 } |
| 292 | 302 |
| 293 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const | 303 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const |
| 294 { | 304 { |
| 295 // TODO: Implement. | 305 // TODO: Implement. |
| 296 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; | 306 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; |
| 297 } | 307 } |
| 298 | 308 |
| 299 } // namespace blink | 309 } // namespace blink |
| OLD | NEW |