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 * Copyright (C) 2007-2009 Torch Mobile, Inc | 5 * Copyright (C) 2007-2009 Torch Mobile, Inc |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 // Zero-height images can cause problems for some ports. If we have an | 149 // Zero-height images can cause problems for some ports. If we have an |
150 // empty image dimension, just bail. | 150 // empty image dimension, just bail. |
151 if (size().isEmpty()) | 151 if (size().isEmpty()) |
152 return 0; | 152 return 0; |
153 | 153 |
154 // Return the buffer contents as a native image. For some ports, the data | 154 // Return the buffer contents as a native image. For some ports, the data |
155 // is already in a native container, and this just increments its refcount. | 155 // is already in a native container, and this just increments its refcount. |
156 return buffer->asNewNativeImage(); | 156 return buffer->asNewNativeImage(); |
157 } | 157 } |
158 | 158 |
159 float ImageSource::frameDurationAtIndex(size_t index) | 159 float ImageSource::frameDurationAtIndex(size_t index) const |
160 { | 160 { |
161 if (!m_decoder) | 161 if (!m_decoder) |
162 return 0; | 162 return 0; |
163 | 163 |
164 ImageFrame* buffer = m_decoder->frameBufferAtIndex(index); | |
165 if (!buffer || buffer->status() == ImageFrame::FrameEmpty) | |
166 return 0; | |
167 | |
168 // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. | 164 // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. |
169 // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify | 165 // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify |
170 // a duration of <= 10 ms. See <rdar://problem/7689300> and <http://webkit.o rg/b/36082> | 166 // a duration of <= 10 ms. See <rdar://problem/7689300> and <http://webkit.o rg/b/36082> |
171 // for more information. | 167 // for more information. |
172 const float duration = buffer->duration() / 1000.0f; | 168 const float duration = m_decoder->frameDurationAtIndex(index) / 1000.0f; |
173 if (duration < 0.011f) | 169 if (duration < 0.011f) |
174 return 0.100f; | 170 return 0.100f; |
175 return duration; | 171 return duration; |
176 } | 172 } |
177 | 173 |
178 ImageOrientation ImageSource::orientationAtIndex(size_t) const | 174 ImageOrientation ImageSource::orientationAtIndex(size_t) const |
179 { | 175 { |
180 return m_decoder ? m_decoder->orientation() : DefaultImageOrientation; | 176 return m_decoder ? m_decoder->orientation() : DefaultImageOrientation; |
181 } | 177 } |
182 | 178 |
183 bool ImageSource::frameHasAlphaAtIndex(size_t index) | 179 bool ImageSource::frameHasAlphaAtIndex(size_t index) const |
184 { | 180 { |
185 if (!m_decoder) | 181 if (!m_decoder) |
Peter Kasting
2013/04/23 21:43:20
Nit: Shorter:
return !m_decoder || m_decoder-
Alpha Left Google
2013/04/25 23:02:44
Done.
| |
186 return true; | 182 return true; |
187 return m_decoder->frameHasAlphaAtIndex(index); | 183 return m_decoder->frameHasAlphaAtIndex(index); |
188 } | 184 } |
189 | 185 |
190 bool ImageSource::frameIsCompleteAtIndex(size_t index) | 186 bool ImageSource::frameIsCompleteAtIndex(size_t index) const |
191 { | 187 { |
192 if (!m_decoder) | 188 if (!m_decoder) |
Peter Kasting
2013/04/23 21:43:20
Nit: Shorter:
return m_decoder && m_decoder->
Alpha Left Google
2013/04/25 23:02:44
Done.
| |
193 return false; | 189 return false; |
194 | 190 return m_decoder->frameIsCompleteAtIndex(index); |
195 ImageFrame* buffer = m_decoder->frameBufferAtIndex(index); | |
196 return buffer && buffer->status() == ImageFrame::FrameComplete; | |
197 } | 191 } |
198 | 192 |
199 unsigned ImageSource::frameBytesAtIndex(size_t index) const | 193 unsigned ImageSource::frameBytesAtIndex(size_t index) const |
200 { | 194 { |
201 if (!m_decoder) | 195 if (!m_decoder) |
202 return 0; | 196 return 0; |
203 return m_decoder->frameBytesAtIndex(index); | 197 return m_decoder->frameBytesAtIndex(index); |
204 } | 198 } |
205 | 199 |
206 void ImageSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 200 void ImageSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
207 { | 201 { |
208 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image); | 202 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image); |
209 info.addMember(m_decoder, "decoder"); | 203 info.addMember(m_decoder, "decoder"); |
210 } | 204 } |
211 | 205 |
212 } | 206 } |
OLD | NEW |