Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: Source/core/platform/image-decoders/ImageDecoder.h

Issue 13980003: Add animation support for WebP images (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase + Handle transparent frame background Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 200 }
201 201
202 int height() const 202 int height() const
203 { 203 {
204 return m_bitmap->bitmap().height(); 204 return m_bitmap->bitmap().height();
205 } 205 }
206 206
207 RefPtr<NativeImageSkia> m_bitmap; 207 RefPtr<NativeImageSkia> m_bitmap;
208 SkBitmap::Allocator* m_allocator; 208 SkBitmap::Allocator* m_allocator;
209 bool m_hasAlpha; 209 bool m_hasAlpha;
210 IntRect m_originalFrameRect; // This will always just be the entire 210 // This will always just be the entire buffer except for GIF or WebP
211 // buffer except for GIF frames whose 211 // frames whose original rect was smaller than the overall image size.
212 // original rect was smaller than the 212 IntRect m_originalFrameRect;
213 // overall image size.
214 FrameStatus m_status; 213 FrameStatus m_status;
215 unsigned m_duration; 214 unsigned m_duration;
216 FrameDisposalMethod m_disposalMethod; 215 FrameDisposalMethod m_disposalMethod;
217 bool m_premultiplyAlpha; 216 bool m_premultiplyAlpha;
218 217
219 // The frame that must be decoded before this frame can be decoded. 218 // The frame that must be decoded before this frame can be decoded.
220 // WTF::notFound if this frame doesn't require any previous frame. 219 // WTF::notFound if this frame doesn't require any previous frame.
221 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never 220 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never
222 // be read for image formats that do not have multiple frames. 221 // be read for image formats that do not have multiple frames.
223 size_t m_requiredPreviousFrameIndex; 222 size_t m_requiredPreviousFrameIndex;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // decode call out and use it here. 261 // decode call out and use it here.
263 virtual bool isSizeAvailable() 262 virtual bool isSizeAvailable()
264 { 263 {
265 return !m_failed && m_sizeAvailable; 264 return !m_failed && m_sizeAvailable;
266 } 265 }
267 266
268 virtual IntSize size() const { return m_size; } 267 virtual IntSize size() const { return m_size; }
269 268
270 // This will only differ from size() for ICO (where each frame is a 269 // This will only differ from size() for ICO (where each frame is a
271 // different icon) or other formats where different frames are different 270 // different icon) or other formats where different frames are different
272 // sizes. This does NOT differ from size() for GIF, since decoding GIFs 271 // sizes. This does NOT differ from size() for GIF or WebP, since
273 // composites any smaller frames against previous frames to create full- 272 // decoding GIF or WebP composites any smaller frames against previous
274 // size frames. 273 // frames to create full-size frames.
275 virtual IntSize frameSizeAtIndex(size_t) const 274 virtual IntSize frameSizeAtIndex(size_t) const
276 { 275 {
277 return size(); 276 return size();
278 } 277 }
279 278
280 // Returns whether the size is legal (i.e. not going to result in 279 // Returns whether the size is legal (i.e. not going to result in
281 // overflow elsewhere). If not, marks decoding as failed. 280 // overflow elsewhere). If not, marks decoding as failed.
282 virtual bool setSize(unsigned width, unsigned height) 281 virtual bool setSize(unsigned width, unsigned height)
283 { 282 {
284 if (isOverSize(width, height)) 283 if (isOverSize(width, height))
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 380 }
382 381
383 bool failed() const { return m_failed; } 382 bool failed() const { return m_failed; }
384 383
385 // Clears decoded pixel data from all frames except the provided frame, 384 // Clears decoded pixel data from all frames except the provided frame,
386 // unless that frame has status FrameEmpty, in which case we instead 385 // unless that frame has status FrameEmpty, in which case we instead
387 // preserve the most recent frame whose data is required in order to 386 // preserve the most recent frame whose data is required in order to
388 // decode this frame. Callers may pass WTF::notFound to clear all frames . 387 // decode this frame. Callers may pass WTF::notFound to clear all frames .
389 // 388 //
390 // Returns the number of bytes of frame data actually cleared. 389 // Returns the number of bytes of frame data actually cleared.
391 size_t clearCacheExceptFrame(size_t); 390 virtual size_t clearCacheExceptFrame(size_t);
392 391
393 // If the image has a cursor hot-spot, stores it in the argument 392 // If the image has a cursor hot-spot, stores it in the argument
394 // and returns true. Otherwise returns false. 393 // and returns true. Otherwise returns false.
395 virtual bool hotSpot(IntPoint&) const { return false; } 394 virtual bool hotSpot(IntPoint&) const { return false; }
396 395
397 virtual void reportMemoryUsage(MemoryObjectInfo*) const; 396 virtual void reportMemoryUsage(MemoryObjectInfo*) const;
398 397
399 virtual void setMemoryAllocator(SkBitmap::Allocator* allocator) 398 virtual void setMemoryAllocator(SkBitmap::Allocator* allocator)
400 { 399 {
401 // FIXME: this doesn't work for images with multiple frames. 400 // FIXME: this doesn't work for images with multiple frames.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 441
443 IntSize m_size; 442 IntSize m_size;
444 bool m_sizeAvailable; 443 bool m_sizeAvailable;
445 bool m_isAllDataReceived; 444 bool m_isAllDataReceived;
446 bool m_failed; 445 bool m_failed;
447 }; 446 };
448 447
449 } // namespace WebCore 448 } // namespace WebCore
450 449
451 #endif 450 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698