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 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 void ImageSource::setData(SharedBuffer& data, bool allDataReceived) | 54 bool ImageSource::setData(SharedBuffer& data, bool allDataReceived) |
| 55 { | 55 { |
| 56 // Create a decoder by sniffing the encoded data. If insufficient data bytes are available to | 56 // Create a decoder by sniffing the encoded data. If insufficient data bytes are available to |
| 57 // determine the encoded image type, no decoder is created. | 57 // determine the encoded image type, no decoder is created. |
| 58 if (!m_decoder) | 58 if (!m_decoder) |
| 59 m_decoder = DeferredImageDecoder::create(data, ImageDecoder::AlphaPremul tiplied, ImageDecoder::GammaAndColorProfileApplied); | 59 m_decoder = DeferredImageDecoder::create(data, ImageDecoder::AlphaPremul tiplied, ImageDecoder::GammaAndColorProfileApplied); |
| 60 | 60 |
| 61 if (m_decoder) | 61 if (m_decoder) { |
| 62 m_decoder->setData(data, allDataReceived); | 62 m_decoder->setData(data, allDataReceived); |
| 63 return true; | |
| 64 } | |
| 65 // If enough data has been received to know that we won't have a valid decod ed, bail. | |
|
pdr.
2016/07/20 20:39:16
nit: valid decoded -> valid decode
Nate Chapin
2016/07/20 22:50:00
Done.
| |
| 66 return data.size() < ImageDecoder::longestSignatureLength(); | |
|
pdr.
2016/07/20 20:39:16
This signature length check is now in two places,
Nate Chapin
2016/07/20 22:50:00
The failure to create a decoder could be because w
| |
| 63 } | 67 } |
| 64 | 68 |
| 65 String ImageSource::filenameExtension() const | 69 String ImageSource::filenameExtension() const |
| 66 { | 70 { |
| 67 return m_decoder ? m_decoder->filenameExtension() : String(); | 71 return m_decoder ? m_decoder->filenameExtension() : String(); |
| 68 } | 72 } |
| 69 | 73 |
| 70 bool ImageSource::isSizeAvailable() | 74 bool ImageSource::isSizeAvailable() |
| 71 { | 75 { |
| 72 return m_decoder && m_decoder->isSizeAvailable(); | 76 return m_decoder && m_decoder->isSizeAvailable(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 { | 150 { |
| 147 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); | 151 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); |
| 148 } | 152 } |
| 149 | 153 |
| 150 size_t ImageSource::frameBytesAtIndex(size_t index) const | 154 size_t ImageSource::frameBytesAtIndex(size_t index) const |
| 151 { | 155 { |
| 152 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0; | 156 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0; |
| 153 } | 157 } |
| 154 | 158 |
| 155 } // namespace blink | 159 } // namespace blink |
| OLD | NEW |