OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 Google Inc. All Rights Reserved. | 2 * Copyright 2006 Google Inc. All Rights Reserved. |
3 * | 3 * |
4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 4 * Portions Copyright (C) 2006 Apple Computer, 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if (!m_decoder) | 165 if (!m_decoder) |
166 return 0; | 166 return 0; |
167 | 167 |
168 // Note that the buffer can have NULL bytes even when it is marked as | 168 // Note that the buffer can have NULL bytes even when it is marked as |
169 // non-empty. It seems "FrameEmpty" is only set before the frame has been | 169 // non-empty. It seems "FrameEmpty" is only set before the frame has been |
170 // initialized. If it is decoded and it happens to be empty, it will be | 170 // initialized. If it is decoded and it happens to be empty, it will be |
171 // marked as "FrameComplete" but will still have NULL bytes. | 171 // marked as "FrameComplete" but will still have NULL bytes. |
172 RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index); | 172 RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index); |
173 if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty) | 173 if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty) |
174 return 0; | 174 return 0; |
175 return reinterpret_cast<NativeImagePtr>(&buffer->bitmap()); | 175 |
| 176 // Copy the bitmap. The pixel data is refcounted internally by SkBitmap, so |
| 177 // this doesn't cost much. This pointer will be owned by the BitmapImage |
| 178 // and freed in FrameData::clear(). |
| 179 return new NativeImageSkia(buffer->bitmap()); |
176 } | 180 } |
177 | 181 |
178 bool ImageSource::frameIsCompleteAtIndex(size_t index) | 182 bool ImageSource::frameIsCompleteAtIndex(size_t index) |
179 { | 183 { |
180 if (!m_decoder) | 184 if (!m_decoder) |
181 return false; | 185 return false; |
182 | 186 |
183 RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index); | 187 RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index); |
184 return buffer && buffer->status() == RGBA32Buffer::FrameComplete; | 188 return buffer && buffer->status() == RGBA32Buffer::FrameComplete; |
185 } | 189 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 bool allDataReceived, | 223 bool allDataReceived, |
220 const IntSize& preferredIconSize) | 224 const IntSize& preferredIconSize) |
221 { | 225 { |
222 if (!m_decoder) | 226 if (!m_decoder) |
223 m_decoder = createDecoder(data->buffer(), preferredIconSize); | 227 m_decoder = createDecoder(data->buffer(), preferredIconSize); |
224 | 228 |
225 ImageSource::setData(data, allDataReceived); | 229 ImageSource::setData(data, allDataReceived); |
226 } | 230 } |
227 | 231 |
228 } | 232 } |
OLD | NEW |