| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 93     ImageFrame* buffer = m_actualDecoder->frameBufferAtIndex(index); | 93     ImageFrame* buffer = m_actualDecoder->frameBufferAtIndex(index); | 
| 94     if (!buffer || buffer->status() == ImageFrame::FrameEmpty) | 94     if (!buffer || buffer->status() == ImageFrame::FrameEmpty) | 
| 95         return nullptr; | 95         return nullptr; | 
| 96 | 96 | 
| 97     return adoptRef(SkImage::NewFromBitmap(buffer->bitmap())); | 97     return adoptRef(SkImage::NewFromBitmap(buffer->bitmap())); | 
| 98 } | 98 } | 
| 99 | 99 | 
| 100 void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived) | 100 void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived) | 
| 101 { | 101 { | 
| 102     if (m_actualDecoder) { | 102     if (m_actualDecoder) { | 
|  | 103         fprintf(stderr, "DeferredImageDecoder %p setData decoder %p\n", this, m_
     actualDecoder.get()); | 
| 103         m_data = RefPtr<SharedBuffer>(data); | 104         m_data = RefPtr<SharedBuffer>(data); | 
| 104         m_lastDataSize = data.size(); | 105         m_lastDataSize = data.size(); | 
| 105         m_allDataReceived = allDataReceived; | 106         m_allDataReceived = allDataReceived; | 
| 106         m_actualDecoder->setData(&data, allDataReceived); | 107         m_actualDecoder->setData(&data, allDataReceived); | 
| 107         prepareLazyDecodedFrames(); | 108         prepareLazyDecodedFrames(); | 
| 108     } | 109     } | 
| 109 | 110 | 
| 110     if (m_frameGenerator) | 111     if (m_frameGenerator) | 
| 111         m_frameGenerator->setData(&data, allDataReceived); | 112         m_frameGenerator->setData(&data, allDataReceived); | 
| 112 } | 113 } | 
| 113 | 114 | 
| 114 bool DeferredImageDecoder::isSizeAvailable() | 115 bool DeferredImageDecoder::isSizeAvailable() | 
| 115 { | 116 { | 
| 116     // m_actualDecoder is 0 only if image decoding is deferred and that means | 117     // m_actualDecoder is 0 only if image decoding is deferred and that means | 
| 117     // the image header decoded successfully and the size is available. | 118     // the image header decoded successfully and the size is available. | 
| 118     return m_actualDecoder ? m_actualDecoder->isSizeAvailable() : true; | 119     return m_actualDecoder ? m_actualDecoder->isSizeAvailable() : true; | 
| 119 } | 120 } | 
| 120 | 121 | 
| 121 bool DeferredImageDecoder::hasColorProfile() const | 122 bool DeferredImageDecoder::hasColorProfile() const | 
| 122 { | 123 { | 
| 123     return m_actualDecoder ? m_actualDecoder->hasColorProfile() : m_hasColorProf
     ile; | 124     return m_actualDecoder ? m_actualDecoder->hasColorProfile() : m_hasColorProf
     ile; | 
| 124 } | 125 } | 
| 125 | 126 | 
|  | 127 PassRefPtr<ColorSpaceProfile> DeferredImageDecoder::colorProfile() const | 
|  | 128 { | 
|  | 129     if (m_actualDecoder) | 
|  | 130         return m_actualDecoder->colorProfile(); | 
|  | 131 | 
|  | 132     return m_colorProfile; | 
|  | 133 } | 
|  | 134 | 
| 126 IntSize DeferredImageDecoder::size() const | 135 IntSize DeferredImageDecoder::size() const | 
| 127 { | 136 { | 
| 128     return m_actualDecoder ? m_actualDecoder->size() : m_size; | 137     return m_actualDecoder ? m_actualDecoder->size() : m_size; | 
| 129 } | 138 } | 
| 130 | 139 | 
| 131 IntSize DeferredImageDecoder::frameSizeAtIndex(size_t index) const | 140 IntSize DeferredImageDecoder::frameSizeAtIndex(size_t index) const | 
| 132 { | 141 { | 
| 133     // FIXME: LocalFrame size is assumed to be uniform. This might not be true f
     or | 142     // FIXME: LocalFrame size is assumed to be uniform. This might not be true f
     or | 
| 134     // future supported codecs. | 143     // future supported codecs. | 
| 135     return m_actualDecoder ? m_actualDecoder->frameSizeAtIndex(index) : m_size; | 144     return m_actualDecoder ? m_actualDecoder->frameSizeAtIndex(index) : m_size; | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 197 | 206 | 
| 198 ImageOrientation DeferredImageDecoder::orientationAtIndex(size_t index) const | 207 ImageOrientation DeferredImageDecoder::orientationAtIndex(size_t index) const | 
| 199 { | 208 { | 
| 200     if (m_actualDecoder) | 209     if (m_actualDecoder) | 
| 201         return m_actualDecoder->orientation(); | 210         return m_actualDecoder->orientation(); | 
| 202     if (index < m_frameData.size()) | 211     if (index < m_frameData.size()) | 
| 203         return m_frameData[index].m_orientation; | 212         return m_frameData[index].m_orientation; | 
| 204     return DefaultImageOrientation; | 213     return DefaultImageOrientation; | 
| 205 } | 214 } | 
| 206 | 215 | 
|  | 216 void DeferredImageDecoder::setDeviceProfile(ColorSpaceProfile* profile) | 
|  | 217 { | 
|  | 218     m_deviceProfile = profile; | 
|  | 219 | 
|  | 220     if (m_actualDecoder) | 
|  | 221         m_actualDecoder->setDeviceProfile(profile); | 
|  | 222 | 
|  | 223     if (m_frameGenerator) | 
|  | 224         m_frameGenerator->setDeviceProfile(profile); | 
|  | 225 } | 
|  | 226 | 
| 207 void DeferredImageDecoder::activateLazyDecoding() | 227 void DeferredImageDecoder::activateLazyDecoding() | 
| 208 { | 228 { | 
| 209     if (m_frameGenerator) | 229     if (m_frameGenerator) | 
| 210         return; | 230         return; | 
|  | 231 | 
|  | 232     fprintf(stderr, "DeferredImageDecoder %p activateLazyDecoding\n", this); | 
|  | 233 | 
| 211     m_size = m_actualDecoder->size(); | 234     m_size = m_actualDecoder->size(); | 
| 212     m_filenameExtension = m_actualDecoder->filenameExtension(); | 235     m_filenameExtension = m_actualDecoder->filenameExtension(); | 
| 213     m_hasColorProfile = m_actualDecoder->hasColorProfile(); | 236     m_hasColorProfile = m_actualDecoder->hasColorProfile(); | 
|  | 237     m_colorProfile = m_hasColorProfile ? m_actualDecoder->colorProfile() : nullp
     tr; | 
| 214     const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN
     one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u); | 238     const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN
     one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u); | 
| 215     m_frameGenerator = ImageFrameGenerator::create(SkISize::Make(m_actualDecoder
     ->decodedSize().width(), m_actualDecoder->decodedSize().height()), m_data, m_all
     DataReceived, !isSingleFrame); | 239     m_frameGenerator = ImageFrameGenerator::create(SkISize::Make(m_actualDecoder
     ->decodedSize().width(), m_actualDecoder->decodedSize().height()), m_data, m_all
     DataReceived, !isSingleFrame); | 
|  | 240     m_frameGenerator->setDeviceProfile(m_deviceProfile.get()); | 
| 216 } | 241 } | 
| 217 | 242 | 
| 218 void DeferredImageDecoder::prepareLazyDecodedFrames() | 243 void DeferredImageDecoder::prepareLazyDecodedFrames() | 
| 219 { | 244 { | 
| 220     if (!s_enabled | 245     if (!s_enabled | 
| 221         || !m_actualDecoder | 246         || !m_actualDecoder | 
| 222         || !m_actualDecoder->isSizeAvailable() | 247         || !m_actualDecoder->isSizeAvailable() | 
| 223         || m_actualDecoder->filenameExtension() == "ico") | 248         || m_actualDecoder->filenameExtension() == "ico") | 
| 224         return; | 249         return; | 
| 225 | 250 | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 272     return image.release(); | 297     return image.release(); | 
| 273 } | 298 } | 
| 274 | 299 | 
| 275 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const | 300 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const | 
| 276 { | 301 { | 
| 277     // TODO: Implement. | 302     // TODO: Implement. | 
| 278     return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; | 303     return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; | 
| 279 } | 304 } | 
| 280 | 305 | 
| 281 } // namespace blink | 306 } // namespace blink | 
| OLD | NEW | 
|---|