| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk> | 3 * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk> |
| 4 * Copyright (C) 2008, Google Inc. All rights reserved. | 4 * Copyright (C) 2008, Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "config.h" | 28 #include "config.h" |
| 29 #include "platform/graphics/ImageSource.h" | 29 #include "platform/graphics/ImageSource.h" |
| 30 | 30 |
| 31 #include "platform/graphics/ColorSpaceProfile.h" |
| 31 #include "platform/graphics/DeferredImageDecoder.h" | 32 #include "platform/graphics/DeferredImageDecoder.h" |
| 32 #include "platform/image-decoders/ImageDecoder.h" | 33 #include "platform/image-decoders/ImageDecoder.h" |
| 33 #include "third_party/skia/include/core/SkImage.h" | 34 #include "third_party/skia/include/core/SkImage.h" |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 ImageSource::ImageSource() | 38 ImageSource::ImageSource() |
| 38 { | 39 { |
| 39 } | 40 } |
| 40 | 41 |
| 41 ImageSource::~ImageSource() | 42 ImageSource::~ImageSource() |
| 42 { | 43 { |
| 43 } | 44 } |
| 44 | 45 |
| 45 size_t ImageSource::clearCacheExceptFrame(size_t clearExceptFrame) | 46 size_t ImageSource::clearCacheExceptFrame(size_t clearExceptFrame) |
| 46 { | 47 { |
| 47 return m_decoder ? m_decoder->clearCacheExceptFrame(clearExceptFrame) : 0; | 48 return m_decoder ? m_decoder->clearCacheExceptFrame(clearExceptFrame) : 0; |
| 48 } | 49 } |
| 49 | 50 |
| 51 void ImageSource::resetDecoder() |
| 52 { |
| 53 m_decoder.clear(); |
| 54 } |
| 55 |
| 50 void ImageSource::setData(SharedBuffer& data, bool allDataReceived) | 56 void ImageSource::setData(SharedBuffer& data, bool allDataReceived) |
| 51 { | 57 { |
| 52 // Create a decoder by sniffing the encoded data. If insufficient data bytes
are available to | 58 // Create a decoder by sniffing the encoded data. If insufficient data bytes
are available to |
| 53 // determine the encoded image type, no decoder is created. | 59 // determine the encoded image type, no decoder is created. |
| 54 if (!m_decoder) | 60 if (!m_decoder) { |
| 55 m_decoder = DeferredImageDecoder::create(data, ImageDecoder::AlphaPremul
tiplied, ImageDecoder::GammaAndColorProfileApplied); | 61 m_decoder = DeferredImageDecoder::create(data, ImageDecoder::AlphaPremul
tiplied, ImageDecoder::GammaAndColorProfileApplied); |
| 62 if (m_decoder) { |
| 63 fprintf(stderr, "ImageSource: %p created decoder device profile %p\n
", this, m_deviceProfile.get()); |
| 64 m_decoder->setDeviceProfile(m_deviceProfile.get()); |
| 65 } |
| 66 } |
| 56 | 67 |
| 57 if (m_decoder) | 68 if (m_decoder) |
| 58 m_decoder->setData(data, allDataReceived); | 69 m_decoder->setData(data, allDataReceived); |
| 59 } | 70 } |
| 60 | 71 |
| 61 String ImageSource::filenameExtension() const | 72 String ImageSource::filenameExtension() const |
| 62 { | 73 { |
| 63 return m_decoder ? m_decoder->filenameExtension() : String(); | 74 return m_decoder ? m_decoder->filenameExtension() : String(); |
| 64 } | 75 } |
| 65 | 76 |
| 66 bool ImageSource::isSizeAvailable() | 77 bool ImageSource::isSizeAvailable() |
| 67 { | 78 { |
| 68 return m_decoder && m_decoder->isSizeAvailable(); | 79 return m_decoder && m_decoder->isSizeAvailable(); |
| 69 } | 80 } |
| 70 | 81 |
| 71 bool ImageSource::hasColorProfile() const | 82 bool ImageSource::hasColorProfile() const |
| 72 { | 83 { |
| 73 return m_decoder && m_decoder->hasColorProfile(); | 84 return m_decoder && m_decoder->hasColorProfile(); |
| 74 } | 85 } |
| 75 | 86 |
| 87 PassRefPtr<ColorSpaceProfile> ImageSource::colorProfile() const |
| 88 { |
| 89 return m_decoder ? m_decoder->colorProfile() : nullptr; |
| 90 } |
| 91 |
| 92 void ImageSource::setDeviceProfile(ColorSpaceProfile* profile) |
| 93 { |
| 94 m_deviceProfile = profile; |
| 95 |
| 96 if (m_decoder) |
| 97 m_decoder->setDeviceProfile(profile); |
| 98 } |
| 99 |
| 76 IntSize ImageSource::size(RespectImageOrientationEnum shouldRespectOrientation)
const | 100 IntSize ImageSource::size(RespectImageOrientationEnum shouldRespectOrientation)
const |
| 77 { | 101 { |
| 78 return frameSizeAtIndex(0, shouldRespectOrientation); | 102 return frameSizeAtIndex(0, shouldRespectOrientation); |
| 79 } | 103 } |
| 80 | 104 |
| 81 IntSize ImageSource::frameSizeAtIndex(size_t index, RespectImageOrientationEnum
shouldRespectOrientation) const | 105 IntSize ImageSource::frameSizeAtIndex(size_t index, RespectImageOrientationEnum
shouldRespectOrientation) const |
| 82 { | 106 { |
| 83 if (!m_decoder) | 107 if (!m_decoder) |
| 84 return IntSize(); | 108 return IntSize(); |
| 85 | 109 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 103 size_t ImageSource::frameCount() const | 127 size_t ImageSource::frameCount() const |
| 104 { | 128 { |
| 105 return m_decoder ? m_decoder->frameCount() : 0; | 129 return m_decoder ? m_decoder->frameCount() : 0; |
| 106 } | 130 } |
| 107 | 131 |
| 108 PassRefPtr<SkImage> ImageSource::createFrameAtIndex(size_t index) | 132 PassRefPtr<SkImage> ImageSource::createFrameAtIndex(size_t index) |
| 109 { | 133 { |
| 110 if (!m_decoder) | 134 if (!m_decoder) |
| 111 return nullptr; | 135 return nullptr; |
| 112 | 136 |
| 137 fprintf(stderr, "ImageSource %p createFrameAtIndex(index=%d)\n", this, (int)
index); |
| 138 |
| 113 return m_decoder->createFrameAtIndex(index); | 139 return m_decoder->createFrameAtIndex(index); |
| 114 } | 140 } |
| 115 | 141 |
| 116 float ImageSource::frameDurationAtIndex(size_t index) const | 142 float ImageSource::frameDurationAtIndex(size_t index) const |
| 117 { | 143 { |
| 118 if (!m_decoder) | 144 if (!m_decoder) |
| 119 return 0; | 145 return 0; |
| 120 | 146 |
| 121 // Many annoying ads specify a 0 duration to make an image flash as quickly
as possible. | 147 // Many annoying ads specify a 0 duration to make an image flash as quickly
as possible. |
| 122 // We follow Firefox's behavior and use a duration of 100 ms for any frames
that specify | 148 // We follow Firefox's behavior and use a duration of 100 ms for any frames
that specify |
| (...skipping 19 matching lines...) Expand all Loading... |
| 142 { | 168 { |
| 143 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); | 169 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); |
| 144 } | 170 } |
| 145 | 171 |
| 146 size_t ImageSource::frameBytesAtIndex(size_t index) const | 172 size_t ImageSource::frameBytesAtIndex(size_t index) const |
| 147 { | 173 { |
| 148 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0; | 174 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0; |
| 149 } | 175 } |
| 150 | 176 |
| 151 } // namespace blink | 177 } // namespace blink |
| OLD | NEW |