| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 size_t ImageSource::clearCacheExceptFrame(size_t clearExceptFrame) | 44 size_t ImageSource::clearCacheExceptFrame(size_t clearExceptFrame) |
| 45 { | 45 { |
| 46 return m_decoder ? m_decoder->clearCacheExceptFrame(clearExceptFrame) : 0; | 46 return m_decoder ? m_decoder->clearCacheExceptFrame(clearExceptFrame) : 0; |
| 47 } | 47 } |
| 48 | 48 |
| 49 PassRefPtr<SharedBuffer> ImageSource::data() | 49 PassRefPtr<SharedBuffer> ImageSource::data() |
| 50 { | 50 { |
| 51 return m_decoder ? m_decoder->data() : nullptr; | 51 return m_decoder ? m_decoder->data() : nullptr; |
| 52 } | 52 } |
| 53 | 53 |
| 54 ImageDecoder::SniffResult ImageSource::setData(SharedBuffer& data, bool allDataR
eceived) | 54 bool ImageSource::setData(PassRefPtr<SharedBuffer> passData, bool allDataReceive
d) |
| 55 { | 55 { |
| 56 ImageDecoder::SniffResult result = ImageDecoder::determineImageType(data); | 56 RefPtr<SharedBuffer> data = passData; |
| 57 if (!m_decoder) | |
| 58 m_decoder = DeferredImageDecoder::create(result, ImageDecoder::AlphaPrem
ultiplied, ImageDecoder::GammaAndColorProfileApplied); | |
| 59 | 57 |
| 60 if (m_decoder) | 58 if (m_decoder) { |
| 61 m_decoder->setData(data, allDataReceived); | 59 m_decoder->setData(data.release(), allDataReceived); |
| 60 // If the decoder is pre-instantiated, it means we've already validated
the data/signature |
| 61 // at some point. |
| 62 return true; |
| 63 } |
| 62 | 64 |
| 63 return result; | 65 m_decoder = DeferredImageDecoder::create(data, allDataReceived, ImageDecoder
::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); |
| 66 |
| 67 // Insufficient data is not a failure. |
| 68 return m_decoder || !ImageDecoder::hasSufficientDataToSniffImageType(*data); |
| 64 } | 69 } |
| 65 | 70 |
| 66 String ImageSource::filenameExtension() const | 71 String ImageSource::filenameExtension() const |
| 67 { | 72 { |
| 68 return m_decoder ? m_decoder->filenameExtension() : String(); | 73 return m_decoder ? m_decoder->filenameExtension() : String(); |
| 69 } | 74 } |
| 70 | 75 |
| 71 bool ImageSource::isSizeAvailable() | 76 bool ImageSource::isSizeAvailable() |
| 72 { | 77 { |
| 73 return m_decoder && m_decoder->isSizeAvailable(); | 78 return m_decoder && m_decoder->isSizeAvailable(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 { | 152 { |
| 148 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); | 153 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); |
| 149 } | 154 } |
| 150 | 155 |
| 151 size_t ImageSource::frameBytesAtIndex(size_t index) const | 156 size_t ImageSource::frameBytesAtIndex(size_t index) const |
| 152 { | 157 { |
| 153 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0; | 158 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0; |
| 154 } | 159 } |
| 155 | 160 |
| 156 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |