| 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 12 matching lines...) Expand all Loading... |
| 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/DeferredImageDecoder.h" | 31 #include "platform/graphics/DeferredImageDecoder.h" |
| 32 #include "platform/image-decoders/ImageDecoder.h" | 32 #include "platform/image-decoders/ImageDecoder.h" |
| 33 #include "wtf/PassOwnPtr.h" | |
| 34 #include "wtf/PassRefPtr.h" | |
| 35 | 33 |
| 36 namespace WebCore { | 34 namespace WebCore { |
| 37 | 35 |
| 38 ImageSource::ImageSource(ImageSource::AlphaOption alphaOption, ImageSource::Gamm
aAndColorProfileOption gammaAndColorProfileOption) | 36 ImageSource::ImageSource(ImageSource::AlphaOption alphaOption, ImageSource::Gamm
aAndColorProfileOption gammaAndColorProfileOption) |
| 39 : m_alphaOption(alphaOption) | 37 : m_alphaOption(alphaOption) |
| 40 , m_gammaAndColorProfileOption(gammaAndColorProfileOption) | 38 , m_gammaAndColorProfileOption(gammaAndColorProfileOption) |
| 41 { | 39 { |
| 42 } | 40 } |
| 43 | 41 |
| 44 ImageSource::~ImageSource() | 42 ImageSource::~ImageSource() |
| 45 { | 43 { |
| 46 } | 44 } |
| 47 | 45 |
| 48 size_t ImageSource::clearCacheExceptFrame(size_t clearExceptFrame) | 46 size_t ImageSource::clearCacheExceptFrame(size_t clearExceptFrame) |
| 49 { | 47 { |
| 50 return m_decoder ? m_decoder->clearCacheExceptFrame(clearExceptFrame) : 0; | 48 return m_decoder ? m_decoder->clearCacheExceptFrame(clearExceptFrame) : 0; |
| 51 } | 49 } |
| 52 | 50 |
| 53 bool ImageSource::initialized() const | 51 bool ImageSource::initialized() const |
| 54 { | 52 { |
| 55 return m_decoder; | 53 return m_decoder; |
| 56 } | 54 } |
| 57 | 55 |
| 56 void ImageSource::resetDecoder() |
| 57 { |
| 58 m_decoder.clear(); |
| 59 } |
| 60 |
| 58 void ImageSource::setData(SharedBuffer& data, bool allDataReceived) | 61 void ImageSource::setData(SharedBuffer& data, bool allDataReceived) |
| 59 { | 62 { |
| 60 // Make the decoder by sniffing the bytes. | 63 // Create a decoder by sniffing the encoded data. If insufficient data bytes
are available to |
| 61 // This method will examine the data and instantiate an instance of the appr
opriate decoder plugin. | 64 // determine the encoded image type, no decoder is created. |
| 62 // If insufficient bytes are available to determine the image type, no decod
er plugin will be | |
| 63 // made. | |
| 64 if (!m_decoder) | 65 if (!m_decoder) |
| 65 m_decoder = DeferredImageDecoder::create(data, m_alphaOption, m_gammaAnd
ColorProfileOption); | 66 m_decoder = DeferredImageDecoder::create(data, m_alphaOption, m_gammaAnd
ColorProfileOption); |
| 66 | 67 |
| 67 if (m_decoder) | 68 if (m_decoder) |
| 68 m_decoder->setData(data, allDataReceived); | 69 m_decoder->setData(data, allDataReceived); |
| 69 } | 70 } |
| 70 | 71 |
| 71 String ImageSource::filenameExtension() const | 72 String ImageSource::filenameExtension() const |
| 72 { | 73 { |
| 73 return m_decoder ? m_decoder->filenameExtension() : String(); | 74 return m_decoder ? m_decoder->filenameExtension() : String(); |
| 74 } | 75 } |
| 75 | 76 |
| 76 bool ImageSource::isSizeAvailable() | 77 bool ImageSource::isSizeAvailable() |
| 77 { | 78 { |
| 78 return m_decoder && m_decoder->isSizeAvailable(); | 79 return m_decoder && m_decoder->isSizeAvailable(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 bool ImageSource::hasColorProfile() const | 82 bool ImageSource::hasColorProfile() const |
| 82 { | 83 { |
| 83 return m_decoder && m_decoder->hasColorProfile(); | 84 return m_decoder && m_decoder->hasColorProfile(); |
| 84 } | 85 } |
| 85 | 86 |
| 87 PassRefPtr<ColorSpaceProfile> ImageSource::colorProfile() const |
| 88 { |
| 89 return m_decoder ? m_decoder->colorProfile() : nullptr; |
| 90 } |
| 91 |
| 86 IntSize ImageSource::size(RespectImageOrientationEnum shouldRespectOrientation)
const | 92 IntSize ImageSource::size(RespectImageOrientationEnum shouldRespectOrientation)
const |
| 87 { | 93 { |
| 88 return frameSizeAtIndex(0, shouldRespectOrientation); | 94 return frameSizeAtIndex(0, shouldRespectOrientation); |
| 89 } | 95 } |
| 90 | 96 |
| 91 IntSize ImageSource::frameSizeAtIndex(size_t index, RespectImageOrientationEnum
shouldRespectOrientation) const | 97 IntSize ImageSource::frameSizeAtIndex(size_t index, RespectImageOrientationEnum
shouldRespectOrientation) const |
| 92 { | 98 { |
| 93 if (!m_decoder) | 99 if (!m_decoder) |
| 94 return IntSize(); | 100 return IntSize(); |
| 95 | 101 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 return !m_decoder || m_decoder->frameHasAlphaAtIndex(index); | 165 return !m_decoder || m_decoder->frameHasAlphaAtIndex(index); |
| 160 } | 166 } |
| 161 | 167 |
| 162 bool ImageSource::frameIsCompleteAtIndex(size_t index) const | 168 bool ImageSource::frameIsCompleteAtIndex(size_t index) const |
| 163 { | 169 { |
| 164 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); | 170 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); |
| 165 } | 171 } |
| 166 | 172 |
| 167 unsigned ImageSource::frameBytesAtIndex(size_t index) const | 173 unsigned ImageSource::frameBytesAtIndex(size_t index) const |
| 168 { | 174 { |
| 169 if (!m_decoder) | 175 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0; |
| 170 return 0; | |
| 171 return m_decoder->frameBytesAtIndex(index); | |
| 172 } | 176 } |
| 173 | 177 |
| 174 } | 178 } |
| OLD | NEW |