| 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 PassRefPtr<SharedBuffer> ImageSource::data() { | 44 PassRefPtr<SharedBuffer> ImageSource::data() { |
| 45 return m_decoder ? m_decoder->data() : nullptr; | 45 return m_decoder ? m_decoder->data() : nullptr; |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool ImageSource::setData(PassRefPtr<SharedBuffer> passData, | 48 bool ImageSource::setData(PassRefPtr<SharedBuffer> passData, |
| 49 bool allDataReceived) { | 49 bool allDataReceived) { |
| 50 RefPtr<SharedBuffer> data = passData; | 50 RefPtr<SharedBuffer> data = passData; |
| 51 | 51 |
| 52 if (m_decoder) { | 52 if (m_decoder) { |
| 53 m_decoder->setData(data.release(), allDataReceived); | 53 m_decoder->setData(data.release(), allDataReceived); |
| 54 // If the decoder is pre-instantiated, it means we've already validated the
data/signature | 54 // If the decoder is pre-instantiated, it means we've already validated the |
| 55 // at some point. | 55 // data/signature at some point. |
| 56 return true; | 56 return true; |
| 57 } | 57 } |
| 58 | 58 |
| 59 m_decoder = DeferredImageDecoder::create( | 59 m_decoder = DeferredImageDecoder::create( |
| 60 data, allDataReceived, ImageDecoder::AlphaPremultiplied, | 60 data, allDataReceived, ImageDecoder::AlphaPremultiplied, |
| 61 ImageDecoder::GammaAndColorProfileApplied); | 61 ImageDecoder::GammaAndColorProfileApplied); |
| 62 | 62 |
| 63 // Insufficient data is not a failure. | 63 // Insufficient data is not a failure. |
| 64 return m_decoder || !ImageDecoder::hasSufficientDataToSniffImageType(*data); | 64 return m_decoder || !ImageDecoder::hasSufficientDataToSniffImageType(*data); |
| 65 } | 65 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (!m_decoder) | 111 if (!m_decoder) |
| 112 return nullptr; | 112 return nullptr; |
| 113 | 113 |
| 114 return m_decoder->createFrameAtIndex(index); | 114 return m_decoder->createFrameAtIndex(index); |
| 115 } | 115 } |
| 116 | 116 |
| 117 float ImageSource::frameDurationAtIndex(size_t index) const { | 117 float ImageSource::frameDurationAtIndex(size_t index) const { |
| 118 if (!m_decoder) | 118 if (!m_decoder) |
| 119 return 0; | 119 return 0; |
| 120 | 120 |
| 121 // Many annoying ads specify a 0 duration to make an image flash as quickly as
possible. | 121 // Many annoying ads specify a 0 duration to make an image flash as quickly as |
| 122 // We follow Firefox's behavior and use a duration of 100 ms for any frames th
at specify | 122 // possible. We follow Firefox's behavior and use a duration of 100 ms for any |
| 123 // a duration of <= 10 ms. See <rdar://problem/7689300> and <http://webkit.org
/b/36082> | 123 // frames that specify a duration of <= 10 ms. See <rdar://problem/7689300> |
| 124 // for more information. | 124 // and <http://webkit.org/b/36082> for more information. |
| 125 const float duration = m_decoder->frameDurationAtIndex(index) / 1000.0f; | 125 const float duration = m_decoder->frameDurationAtIndex(index) / 1000.0f; |
| 126 if (duration < 0.011f) | 126 if (duration < 0.011f) |
| 127 return 0.100f; | 127 return 0.100f; |
| 128 return duration; | 128 return duration; |
| 129 } | 129 } |
| 130 | 130 |
| 131 ImageOrientation ImageSource::orientationAtIndex(size_t index) const { | 131 ImageOrientation ImageSource::orientationAtIndex(size_t index) const { |
| 132 return m_decoder ? m_decoder->orientationAtIndex(index) | 132 return m_decoder ? m_decoder->orientationAtIndex(index) |
| 133 : DefaultImageOrientation; | 133 : DefaultImageOrientation; |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool ImageSource::frameHasAlphaAtIndex(size_t index) const { | 136 bool ImageSource::frameHasAlphaAtIndex(size_t index) const { |
| 137 return !m_decoder || m_decoder->frameHasAlphaAtIndex(index); | 137 return !m_decoder || m_decoder->frameHasAlphaAtIndex(index); |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool ImageSource::frameIsCompleteAtIndex(size_t index) const { | 140 bool ImageSource::frameIsCompleteAtIndex(size_t index) const { |
| 141 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); | 141 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); |
| 142 } | 142 } |
| 143 | 143 |
| 144 size_t ImageSource::frameBytesAtIndex(size_t index) const { | 144 size_t ImageSource::frameBytesAtIndex(size_t index) const { |
| 145 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0; | 145 return m_decoder ? m_decoder->frameBytesAtIndex(index) : 0; |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |