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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ImageFrame.h

Issue 2155973002: Save a bitmap copy when advancing to dependent GIF and WebP animation frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK m_status in ImageFrame. Shortened commit message. Thanks kbr@. Created 4 years, 2 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 14 matching lines...) Expand all
25 */ 25 */
26 26
27 #ifndef ImageFrame_h 27 #ifndef ImageFrame_h
28 #define ImageFrame_h 28 #define ImageFrame_h
29 29
30 #include "platform/PlatformExport.h" 30 #include "platform/PlatformExport.h"
31 #include "platform/geometry/IntRect.h" 31 #include "platform/geometry/IntRect.h"
32 #include "public/platform/WebVector.h" 32 #include "public/platform/WebVector.h"
33 #include "third_party/skia/include/core/SkBitmap.h" 33 #include "third_party/skia/include/core/SkBitmap.h"
34 #include "third_party/skia/include/core/SkColorPriv.h" 34 #include "third_party/skia/include/core/SkColorPriv.h"
35 #include "third_party/skia/include/core/SkImage.h"
35 #include "wtf/Allocator.h" 36 #include "wtf/Allocator.h"
36 #include "wtf/Assertions.h" 37 #include "wtf/Assertions.h"
37 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
41 // ImageFrame represents the decoded image data. This buffer is what all 42 // ImageFrame represents the decoded image data. This buffer is what all
42 // decoders write a single frame into. 43 // decoders write a single frame into.
43 class PLATFORM_EXPORT ImageFrame final { 44 class PLATFORM_EXPORT ImageFrame final {
44 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 45 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // These do not touch other metadata, only the raw pixel data. 91 // These do not touch other metadata, only the raw pixel data.
91 void clearPixelData(); 92 void clearPixelData();
92 void zeroFillPixelData(); 93 void zeroFillPixelData();
93 void zeroFillFrameRect(const IntRect&); 94 void zeroFillFrameRect(const IntRect&);
94 95
95 // Makes this frame have an independent copy of the provided image's 96 // Makes this frame have an independent copy of the provided image's
96 // pixel data, so that modifications in one frame are not reflected in 97 // pixel data, so that modifications in one frame are not reflected in
97 // the other. Returns whether the copy succeeded. 98 // the other. Returns whether the copy succeeded.
98 bool copyBitmapData(const ImageFrame&); 99 bool copyBitmapData(const ImageFrame&);
99 100
101 // Moves the bitmap data from the provided frame to this one, leaving the
102 // provided frame empty. Operation is successful only if bitmap data is not
103 // marked as done (immutable). Returns whether the move succeeded.
104 bool takeBitmapDataIfWritable(ImageFrame*);
105
100 // Copies the pixel data at [(startX, startY), (endX, startY)) to the 106 // Copies the pixel data at [(startX, startY), (endX, startY)) to the
101 // same X-coordinates on each subsequent row up to but not including 107 // same X-coordinates on each subsequent row up to but not including
102 // endY. 108 // endY.
103 void copyRowNTimes(int startX, int endX, int startY, int endY) 109 void copyRowNTimes(int startX, int endX, int startY, int endY)
104 { 110 {
105 ASSERT(startX < width()); 111 ASSERT(startX < width());
106 ASSERT(endX <= width()); 112 ASSERT(endX <= width());
107 ASSERT(startY < height()); 113 ASSERT(startY < height());
108 ASSERT(endY <= height()); 114 ASSERT(endY <= height());
109 const int rowBytes = (endX - startX) * sizeof(PixelData); 115 const int rowBytes = (endX - startX) * sizeof(PixelData);
110 const PixelData* const startAddr = getAddr(startX, startY); 116 const PixelData* const startAddr = getAddr(startX, startY);
111 for (int destY = startY + 1; destY < endY; ++destY) 117 for (int destY = startY + 1; destY < endY; ++destY)
112 memcpy(getAddr(startX, destY), startAddr, rowBytes); 118 memcpy(getAddr(startX, destY), startAddr, rowBytes);
113 } 119 }
114 120
115 // Allocates space for the pixel data. Must be called before any pixels 121 // Allocates space for the pixel data. Must be called before any pixels
116 // are written. Must only be called once. Returns whether allocation 122 // are written. Must only be called once. Returns whether allocation
117 // succeeded. 123 // succeeded.
118 bool setSizeAndColorProfile(int newWidth, int newHeight, const ICCProfile& n ewIccProfile); 124 bool setSizeAndColorProfile(int newWidth, int newHeight, const ICCProfile& n ewIccProfile);
119 125
120 bool hasAlpha() const; 126 bool hasAlpha() const;
121 const IntRect& originalFrameRect() const { return m_originalFrameRect; } 127 const IntRect& originalFrameRect() const { return m_originalFrameRect; }
122 Status getStatus() const { return m_status; } 128 Status getStatus() const { return m_status; }
123 unsigned duration() const { return m_duration; } 129 unsigned duration() const { return m_duration; }
124 DisposalMethod getDisposalMethod() const { return m_disposalMethod; } 130 DisposalMethod getDisposalMethod() const { return m_disposalMethod; }
125 AlphaBlendSource getAlphaBlendSource() const { return m_alphaBlendSource; } 131 AlphaBlendSource getAlphaBlendSource() const { return m_alphaBlendSource; }
126 bool premultiplyAlpha() const { return m_premultiplyAlpha; } 132 bool premultiplyAlpha() const { return m_premultiplyAlpha; }
127 SkBitmap::Allocator* allocator() const { return m_allocator; } 133 SkBitmap::Allocator* allocator() const { return m_allocator; }
134
135 // Returns the bitmap that is the output of decoding.
128 const SkBitmap& bitmap() const { return m_bitmap; } 136 const SkBitmap& bitmap() const { return m_bitmap; }
137
138 // Create SkImage from bitmap() and return it. This should be called only
139 // if frame is complete. The bitmap is set immutable before creating
140 // SkImage to avoid copying bitmap in SkImage::MakeFromBitmap(m_bitmap).
141 sk_sp<SkImage> finalizePixelsAndGetImage();
142
129 // Returns true if the pixels changed, but the bitmap has not yet been notif ied. 143 // Returns true if the pixels changed, but the bitmap has not yet been notif ied.
130 bool pixelsChanged() const { return m_pixelsChanged; } 144 bool pixelsChanged() const { return m_pixelsChanged; }
131 size_t requiredPreviousFrameIndex() const { return m_requiredPreviousFrameIn dex; } 145 size_t requiredPreviousFrameIndex() const { return m_requiredPreviousFrameIn dex; }
132 void setHasAlpha(bool alpha); 146 void setHasAlpha(bool alpha);
133 void setOriginalFrameRect(const IntRect& r) { m_originalFrameRect = r; } 147 void setOriginalFrameRect(const IntRect& r) { m_originalFrameRect = r; }
134 void setStatus(Status); 148 void setStatus(Status);
135 void setDuration(unsigned duration) { m_duration = duration; } 149 void setDuration(unsigned duration) { m_duration = duration; }
136 void setDisposalMethod(DisposalMethod disposalMethod) { m_disposalMethod = d isposalMethod; } 150 void setDisposalMethod(DisposalMethod disposalMethod) { m_disposalMethod = d isposalMethod; }
137 void setAlphaBlendSource(AlphaBlendSource alphaBlendSource) { m_alphaBlendSo urce = alphaBlendSource; } 151 void setAlphaBlendSource(AlphaBlendSource alphaBlendSource) { m_alphaBlendSo urce = alphaBlendSource; }
138 void setPremultiplyAlpha(bool premultiplyAlpha) { m_premultiplyAlpha = premu ltiplyAlpha; } 152 void setPremultiplyAlpha(bool premultiplyAlpha) { m_premultiplyAlpha = premu ltiplyAlpha; }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // The frame that must be decoded before this frame can be decoded. 231 // The frame that must be decoded before this frame can be decoded.
218 // WTF::kNotFound if this frame doesn't require any previous frame. 232 // WTF::kNotFound if this frame doesn't require any previous frame.
219 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never 233 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never
220 // be read for image formats that do not have multiple frames. 234 // be read for image formats that do not have multiple frames.
221 size_t m_requiredPreviousFrameIndex; 235 size_t m_requiredPreviousFrameIndex;
222 }; 236 };
223 237
224 } // namespace blink 238 } // namespace blink
225 239
226 #endif 240 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698