Chromium Code Reviews| Index: Source/core/platform/image-decoders/ImageDecoder.h |
| diff --git a/Source/core/platform/image-decoders/ImageDecoder.h b/Source/core/platform/image-decoders/ImageDecoder.h |
| index 3c4cc2dc31ae1c33b46c6102351b02b868203354..4dc00bd11811a7f61339fdc0d7cfc358e0c14c81 100644 |
| --- a/Source/core/platform/image-decoders/ImageDecoder.h |
| +++ b/Source/core/platform/image-decoders/ImageDecoder.h |
| @@ -53,8 +53,8 @@ namespace WebCore { |
| // decoders write a single frame into. |
| class ImageFrame { |
| public: |
| - enum FrameStatus { FrameEmpty, FramePartial, FrameComplete }; |
| - enum FrameDisposalMethod { |
| + enum Status { FrameEmpty, FramePartial, FrameComplete }; |
| + enum DisposalMethod { |
| // If you change the numeric values of these, make sure you audit |
| // all users, as some users may cast raw values to/from these |
| // constants. |
| @@ -64,6 +64,23 @@ namespace WebCore { |
| DisposeOverwritePrevious // Clear frame to previous framebuffer |
| // contents |
| }; |
| + // Indicates how transparent pixels of the current frame rectangle are |
| + // blended with those of the previous frame buffer. |
|
Peter Kasting
2013/08/23 01:14:02
Nit: How about:
Indicates how non-opaque pixels i
urvang (Google)
2013/08/23 02:34:31
Done. But I'm retaining the term 'frame rectangle'
|
| + // Notes: |
| + // * GIF always uses 'BlendAtopPreviousFrame'. |
| + // * WebP also gives 'BlendAtopBgcolor' option. This is useful for cases |
|
Peter Kasting
2013/08/23 01:14:02
Nit: gives -> uses the
urvang (Google)
2013/08/23 02:34:31
Done.
|
| + // where one wants to transform a few opaque pixels of previous frame |
|
Peter Kasting
2013/08/23 01:14:02
Nit: previous -> the previous
urvang (Google)
2013/08/23 02:34:31
Done.
|
| + // into non-opaque pixels in the current frame. |
| + enum AlphaBlendSource { |
| + // Compose the rectangle of current frame by blending it with |
|
Peter Kasting
2013/08/23 01:14:02
Nit: Change this first line to "Blend non-opaque p
urvang (Google)
2013/08/23 02:34:31
Done.
|
| + // corresponding pixels in the initial buffer state (i.e. any |
| + // previous frame buffer after having been properly disposed). |
| + BlendAtopPreviousFrame, |
| + |
| + // Compose the rectangle of current frame by blending it against |
| + // transparent, i.e. simply overwriting the corresponding pixels. |
|
Peter Kasting
2013/08/23 01:14:02
Nit: How about:
Blend non-opaque pixels against f
urvang (Google)
2013/08/23 02:34:31
Done.
|
| + BlendAtopBgcolor, |
| + }; |
| typedef uint32_t PixelData; |
| ImageFrame(); |
| @@ -111,9 +128,10 @@ namespace WebCore { |
| bool hasAlpha() const; |
| const IntRect& originalFrameRect() const { return m_originalFrameRect; } |
| - FrameStatus status() const { return m_status; } |
| + Status status() const { return m_status; } |
| unsigned duration() const { return m_duration; } |
| - FrameDisposalMethod disposalMethod() const { return m_disposalMethod; } |
| + DisposalMethod disposalMethod() const { return m_disposalMethod; } |
| + AlphaBlendSource alphaBlendSource() const { return m_alphaBlendSource; } |
| bool premultiplyAlpha() const { return m_premultiplyAlpha; } |
| SkBitmap::Allocator* allocator() const { return m_allocator; } |
| const SkBitmap& getSkBitmap() const { return m_bitmap->bitmap(); } |
| @@ -128,9 +146,10 @@ namespace WebCore { |
| #endif |
| void setHasAlpha(bool alpha); |
| void setOriginalFrameRect(const IntRect& r) { m_originalFrameRect = r; } |
| - void setStatus(FrameStatus status); |
| + void setStatus(Status); |
| void setDuration(unsigned duration) { m_duration = duration; } |
| - void setDisposalMethod(FrameDisposalMethod method) { m_disposalMethod = method; } |
| + void setDisposalMethod(DisposalMethod method) { m_disposalMethod = method; } |
| + void setAlphaBlendSource(AlphaBlendSource source) { m_alphaBlendSource = source; } |
| void setPremultiplyAlpha(bool premultiplyAlpha) { m_premultiplyAlpha = premultiplyAlpha; } |
| void setMemoryAllocator(SkBitmap::Allocator* allocator) { m_allocator = allocator; } |
| void setSkBitmap(const SkBitmap& bitmap) { m_bitmap = NativeImageSkia::create(bitmap); } |
| @@ -196,9 +215,10 @@ namespace WebCore { |
| // This will always just be the entire buffer except for GIF or WebP |
| // frames whose original rect was smaller than the overall image size. |
| IntRect m_originalFrameRect; |
| - FrameStatus m_status; |
| + Status m_status; |
| unsigned m_duration; |
| - FrameDisposalMethod m_disposalMethod; |
| + DisposalMethod m_disposalMethod; |
| + AlphaBlendSource m_alphaBlendSource; |
| bool m_premultiplyAlpha; |
| // The frame that must be decoded before this frame can be decoded. |
| @@ -383,14 +403,16 @@ namespace WebCore { |
| if (m_frameBufferCache.isEmpty()) { |
| m_frameBufferCache.resize(1); |
| m_frameBufferCache[0].setRequiredPreviousFrameIndex( |
| - findRequiredPreviousFrame(0)); |
| + findRequiredPreviousFrame(0, false)); |
| } |
| m_frameBufferCache[0].setMemoryAllocator(allocator); |
| } |
| protected: |
| // Calculates the most recent frame whose image data may be needed in |
| - // order to decode frame |frameIndex|, based on frame disposal methods. |
| + // order to decode frame |frameIndex|, based on frame disposal methods |
| + // and |frameRectIsOpaque|, where |frameRectIsOpaque| signifies whether |
| + // the rectangle of frame at |frameIndex| is known to be opaque. |
| // If no previous frame's data is required, returns WTF::notFound. |
| // |
| // This function requires that the previous frame's |
| @@ -404,7 +426,7 @@ namespace WebCore { |
| // Image formats which do not use more than one frame do not need to |
| // worry about this; see comments on |
| // ImageFrame::m_requiredPreviousFrameIndex. |
| - size_t findRequiredPreviousFrame(size_t frameIndex); |
| + size_t findRequiredPreviousFrame(size_t frameIndex, bool frameRectIsOpaque); |
| virtual void clearFrameBuffer(size_t frameIndex); |