| 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 return !m_decoder || m_decoder->frameHasAlphaAtIndex(index); |
| 186 return true; | |
| 187 return m_decoder->frameHasAlphaAtIndex(index); | |
| 188 } | 182 } |
| 189 | 183 |
| 190 bool ImageSource::frameIsCompleteAtIndex(size_t index) | 184 bool ImageSource::frameIsCompleteAtIndex(size_t index) const |
| 191 { | 185 { |
| 192 if (!m_decoder) | 186 return m_decoder && m_decoder->frameIsCompleteAtIndex(index); |
| 193 return false; | |
| 194 | |
| 195 ImageFrame* buffer = m_decoder->frameBufferAtIndex(index); | |
| 196 return buffer && buffer->status() == ImageFrame::FrameComplete; | |
| 197 } | 187 } |
| 198 | 188 |
| 199 unsigned ImageSource::frameBytesAtIndex(size_t index) const | 189 unsigned ImageSource::frameBytesAtIndex(size_t index) const |
| 200 { | 190 { |
| 201 if (!m_decoder) | 191 if (!m_decoder) |
| 202 return 0; | 192 return 0; |
| 203 return m_decoder->frameBytesAtIndex(index); | 193 return m_decoder->frameBytesAtIndex(index); |
| 204 } | 194 } |
| 205 | 195 |
| 206 void ImageSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 196 void ImageSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
| 207 { | 197 { |
| 208 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image); | 198 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image); |
| 209 info.addMember(m_decoder, "decoder"); | 199 info.addMember(m_decoder, "decoder"); |
| 210 } | 200 } |
| 211 | 201 |
| 212 } | 202 } |
| OLD | NEW |