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) Research In Motion Limited 2009-2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 *dest = SkPackARGB32NoCheck(a, r, g, b); | 208 *dest = SkPackARGB32NoCheck(a, r, g, b); |
209 } | 209 } |
210 | 210 |
211 inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsigned
b, unsigned a) | 211 inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsigned
b, unsigned a) |
212 { | 212 { |
213 ASSERT(!m_premultiplyAlpha); | 213 ASSERT(!m_premultiplyAlpha); |
214 | 214 |
215 *dest = SkPackARGB32NoCheck(a, r, g, b); | 215 *dest = SkPackARGB32NoCheck(a, r, g, b); |
216 } | 216 } |
217 | 217 |
| 218 void zeroFillFrameRect(const IntRect&); |
| 219 |
218 private: | 220 private: |
219 int width() const | 221 int width() const |
220 { | 222 { |
221 return m_bitmap->bitmap().width(); | 223 return m_bitmap->bitmap().width(); |
222 } | 224 } |
223 | 225 |
224 int height() const | 226 int height() const |
225 { | 227 { |
226 return m_bitmap->bitmap().height(); | 228 return m_bitmap->bitmap().height(); |
227 } | 229 } |
228 | 230 |
229 RefPtr<NativeImageSkia> m_bitmap; | 231 RefPtr<NativeImageSkia> m_bitmap; |
230 SkBitmap::Allocator* m_allocator; | 232 SkBitmap::Allocator* m_allocator; |
231 bool m_hasAlpha; | 233 bool m_hasAlpha; |
232 IntRect m_originalFrameRect; // This will always just be the entire | 234 // This will always just be the entire buffer except for GIF or WebP |
233 // buffer except for GIF frames whose | 235 // frames whose original rect was smaller than the overall image size. |
234 // original rect was smaller than the | 236 IntRect m_originalFrameRect; |
235 // overall image size. | |
236 FrameStatus m_status; | 237 FrameStatus m_status; |
237 unsigned m_duration; | 238 unsigned m_duration; |
238 FrameDisposalMethod m_disposalMethod; | 239 FrameDisposalMethod m_disposalMethod; |
239 bool m_premultiplyAlpha; | 240 bool m_premultiplyAlpha; |
240 | 241 |
241 // The frame that must be decoded before this frame can be decoded. | 242 // The frame that must be decoded before this frame can be decoded. |
242 // WTF::notFound if this frame doesn't require any previous frame. | 243 // WTF::notFound if this frame doesn't require any previous frame. |
243 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never | 244 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never |
244 // be read for image formats that do not have multiple frames. | 245 // be read for image formats that do not have multiple frames. |
245 size_t m_requiredPreviousFrameIndex; | 246 size_t m_requiredPreviousFrameIndex; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // decode call out and use it here. | 285 // decode call out and use it here. |
285 virtual bool isSizeAvailable() | 286 virtual bool isSizeAvailable() |
286 { | 287 { |
287 return !m_failed && m_sizeAvailable; | 288 return !m_failed && m_sizeAvailable; |
288 } | 289 } |
289 | 290 |
290 virtual IntSize size() const { return m_size; } | 291 virtual IntSize size() const { return m_size; } |
291 | 292 |
292 // This will only differ from size() for ICO (where each frame is a | 293 // This will only differ from size() for ICO (where each frame is a |
293 // different icon) or other formats where different frames are different | 294 // different icon) or other formats where different frames are different |
294 // sizes. This does NOT differ from size() for GIF, since decoding GIFs | 295 // sizes. This does NOT differ from size() for GIF or WebP, since |
295 // composites any smaller frames against previous frames to create full- | 296 // decoding GIF or WebP composites any smaller frames against previous |
296 // size frames. | 297 // frames to create full-size frames. |
297 virtual IntSize frameSizeAtIndex(size_t) const | 298 virtual IntSize frameSizeAtIndex(size_t) const |
298 { | 299 { |
299 return size(); | 300 return size(); |
300 } | 301 } |
301 | 302 |
302 // Returns whether the size is legal (i.e. not going to result in | 303 // Returns whether the size is legal (i.e. not going to result in |
303 // overflow elsewhere). If not, marks decoding as failed. | 304 // overflow elsewhere). If not, marks decoding as failed. |
304 virtual bool setSize(unsigned width, unsigned height) | 305 virtual bool setSize(unsigned width, unsigned height) |
305 { | 306 { |
306 if (isOverSize(width, height)) | 307 if (isOverSize(width, height)) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 // to enable easy tailcalling. Subclasses may override this to also | 398 // to enable easy tailcalling. Subclasses may override this to also |
398 // clean up any local data. | 399 // clean up any local data. |
399 virtual bool setFailed() | 400 virtual bool setFailed() |
400 { | 401 { |
401 m_failed = true; | 402 m_failed = true; |
402 return false; | 403 return false; |
403 } | 404 } |
404 | 405 |
405 bool failed() const { return m_failed; } | 406 bool failed() const { return m_failed; } |
406 | 407 |
407 // Clears decoded pixel data from all frames except the provided frame, | 408 // Clears decoded pixel data from all frames except the provided frame. |
408 // unless that frame has status FrameEmpty, in which case we instead | 409 // Callers may pass WTF::notFound to clear all frames. |
409 // preserve the most recent frame whose data is required in order to | 410 // Note: If |m_frameBufferCache| contains only one frame, it won't be cl
eared. |
410 // decode this frame. Callers may pass WTF::notFound to clear all frames
. | |
411 // | |
412 // Returns the number of bytes of frame data actually cleared. | 411 // Returns the number of bytes of frame data actually cleared. |
413 size_t clearCacheExceptFrame(size_t); | 412 virtual size_t clearCacheExceptFrame(size_t); |
414 | 413 |
415 // If the image has a cursor hot-spot, stores it in the argument | 414 // If the image has a cursor hot-spot, stores it in the argument |
416 // and returns true. Otherwise returns false. | 415 // and returns true. Otherwise returns false. |
417 virtual bool hotSpot(IntPoint&) const { return false; } | 416 virtual bool hotSpot(IntPoint&) const { return false; } |
418 | 417 |
419 virtual void reportMemoryUsage(MemoryObjectInfo*) const; | 418 virtual void reportMemoryUsage(MemoryObjectInfo*) const; |
420 | 419 |
421 virtual void setMemoryAllocator(SkBitmap::Allocator* allocator) | 420 virtual void setMemoryAllocator(SkBitmap::Allocator* allocator) |
422 { | 421 { |
423 // FIXME: this doesn't work for images with multiple frames. | 422 // FIXME: this doesn't work for images with multiple frames. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 463 |
465 IntSize m_size; | 464 IntSize m_size; |
466 bool m_sizeAvailable; | 465 bool m_sizeAvailable; |
467 bool m_isAllDataReceived; | 466 bool m_isAllDataReceived; |
468 bool m_failed; | 467 bool m_failed; |
469 }; | 468 }; |
470 | 469 |
471 } // namespace WebCore | 470 } // namespace WebCore |
472 | 471 |
473 #endif | 472 #endif |
OLD | NEW |