Chromium Code Reviews| 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 blink { | 34 namespace blink { |
| 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 |
| 58 void ImageSource::setData(SharedBuffer& data, bool allDataReceived) | 56 void ImageSource::setData(SharedBuffer& data, bool allDataReceived) |
| 59 { | 57 { |
| 60 // Make the decoder by sniffing the bytes. | 58 // Create a decoder by sniffing the encoded data. If insufficient data bytes are available to |
|
tkent
2014/08/18 07:31:00
nit: I recommend to wrap code comments in 80 colum
Noel Gordon
2014/08/18 07:54:50
Acknowledged.
| |
| 61 // This method will examine the data and instantiate an instance of the appr opriate decoder plugin. | 59 // 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) | 60 if (!m_decoder) |
| 65 m_decoder = DeferredImageDecoder::create(data, m_alphaOption, m_gammaAnd ColorProfileOption); | 61 m_decoder = DeferredImageDecoder::create(data, m_alphaOption, m_gammaAnd ColorProfileOption); |
| 66 | 62 |
| 67 if (m_decoder) | 63 if (m_decoder) |
| 68 m_decoder->setData(data, allDataReceived); | 64 m_decoder->setData(data, allDataReceived); |
| 69 } | 65 } |
| 70 | 66 |
| 71 String ImageSource::filenameExtension() const | 67 String ImageSource::filenameExtension() const |
| 72 { | 68 { |
| 73 return m_decoder ? m_decoder->filenameExtension() : String(); | 69 return m_decoder ? m_decoder->filenameExtension() : String(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 return !m_decoder || m_decoder->frameHasAlphaAtIndex(index); | 155 return !m_decoder || m_decoder->frameHasAlphaAtIndex(index); |
| 160 } | 156 } |
| 161 | 157 |
| 162 bool ImageSource::frameIsCompleteAtIndex(size_t index) const | 158 bool ImageSource::frameIsCompleteAtIndex(size_t index) const |
| 163 { | 159 { |
| 164 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); | 160 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); |
| 165 } | 161 } |
| 166 | 162 |
| 167 unsigned ImageSource::frameBytesAtIndex(size_t index) const | 163 unsigned ImageSource::frameBytesAtIndex(size_t index) const |
| 168 { | 164 { |
| 169 if (!m_decoder) | 165 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0; |
| 170 return 0; | |
| 171 return m_decoder->frameBytesAtIndex(index); | |
| 172 } | 166 } |
| 173 | 167 |
| 174 } // namespace blink | 168 } // namespace blink |
| OLD | NEW |