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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/BitmapImage.h

Issue 2262493003: Prevent synchronous layout while painting the last frame of a gif (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor Created 4 years, 3 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 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
4 * Copyright (C) 2008-2009 Torch Mobile, Inc. 4 * Copyright (C) 2008-2009 Torch Mobile, Inc.
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override ; 84 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override ;
85 bool currentFrameIsComplete() override; 85 bool currentFrameIsComplete() override;
86 bool currentFrameIsLazyDecoded() override; 86 bool currentFrameIsLazyDecoded() override;
87 87
88 ImageOrientation currentFrameOrientation(); 88 ImageOrientation currentFrameOrientation();
89 89
90 // Construct a BitmapImage with the given orientation. 90 // Construct a BitmapImage with the given orientation.
91 static PassRefPtr<BitmapImage> createWithOrientationForTesting(const SkBitma p&, ImageOrientation); 91 static PassRefPtr<BitmapImage> createWithOrientationForTesting(const SkBitma p&, ImageOrientation);
92 // Advance the image animation by one frame. 92 // Advance the image animation by one frame.
93 void advanceAnimationForTesting() override { internalAdvanceAnimation(false) ; } 93 void advanceAnimationForTesting() override { internalAdvanceAnimation(); }
94 94
95 private: 95 private:
96 enum RepetitionCountStatus { 96 enum RepetitionCountStatus {
97 Unknown, // We haven't checked the source's repetition count. 97 Unknown, // We haven't checked the source's repetition count.
98 Uncertain, // We have a repetition count, but it might be wrong (some GIF s have a count after the image data, and will report "loop once" until all data has been decoded). 98 Uncertain, // We have a repetition count, but it might be wrong (some GIF s have a count after the image data, and will report "loop once" until all data has been decoded).
99 Certain // The repetition count is known to be correct. 99 Certain // The repetition count is known to be correct.
100 }; 100 };
101 101
102 BitmapImage(const SkBitmap &, ImageObserver* = 0); 102 BitmapImage(const SkBitmap &, ImageObserver* = 0);
103 BitmapImage(ImageObserver* = 0); 103 BitmapImage(ImageObserver* = 0);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 void startAnimation(CatchUpAnimation = CatchUp) override; 143 void startAnimation(CatchUpAnimation = CatchUp) override;
144 void stopAnimation(); 144 void stopAnimation();
145 void advanceAnimation(TimerBase*); 145 void advanceAnimation(TimerBase*);
146 // Advance the animation and let the next frame get scheduled without 146 // Advance the animation and let the next frame get scheduled without
147 // catch-up logic. For large images with slow or heavily-loaded systems, 147 // catch-up logic. For large images with slow or heavily-loaded systems,
148 // throwing away data as we go (see destroyDecodedData()) means we can spend 148 // throwing away data as we go (see destroyDecodedData()) means we can spend
149 // so much time re-decoding data that we are always behind. To prevent this, 149 // so much time re-decoding data that we are always behind. To prevent this,
150 // we force the next animation to skip the catch up logic. 150 // we force the next animation to skip the catch up logic.
151 void advanceAnimationWithoutCatchUp(TimerBase*); 151 void advanceAnimationWithoutCatchUp(TimerBase*);
152 152
153 // Function that does the real work of advancing the animation. When 153 // This function does the real work of advancing the animation. When
154 // skippingFrames is true, we're in the middle of a loop trying to skip over 154 // skipping frames to catch up, we're in the middle of a loop trying to skip
155 // a bunch of animation frames, so we should not do things like decode each 155 // over a bunch of animation frames, so we should not do things like decode
156 // one or notify our observers. 156 // each one or notify our observers.
157 // Returns whether the animation was advanced. 157 // Returns whether the animation was advanced.
158 bool internalAdvanceAnimation(bool skippingFrames); 158 enum AnimationAdvancement {
159 Normal,
160 SkipFramesToCatchUp
161 };
162 bool internalAdvanceAnimation(AnimationAdvancement = Normal);
163
164 void notifyObserversOfAnimationAdvance(TimerBase*);
159 165
160 ImageSource m_source; 166 ImageSource m_source;
161 mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image). 167 mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image).
162 mutable IntSize m_sizeRespectingOrientation; 168 mutable IntSize m_sizeRespectingOrientation;
163 169
164 size_t m_currentFrame; // The index of the current frame of animation. 170 size_t m_currentFrame; // The index of the current frame of animation.
165 Vector<FrameData, 1> m_frames; // An array of the cached frames of the anima tion. We have to ref frames to pin them in the cache. 171 Vector<FrameData, 1> m_frames; // An array of the cached frames of the anima tion. We have to ref frames to pin them in the cache.
166 172
167 RefPtr<SkImage> m_cachedFrame; // A cached copy of the most recently-accesse d frame. 173 RefPtr<SkImage> m_cachedFrame; // A cached copy of the most recently-accesse d frame.
168 size_t m_cachedFrameIndex; // Index of the frame that is cached. 174 size_t m_cachedFrameIndex; // Index of the frame that is cached.
(...skipping 14 matching lines...) Expand all
183 mutable bool m_haveSize : 1; // Whether or not our |m_size| member variable has the final overall image size yet. 189 mutable bool m_haveSize : 1; // Whether or not our |m_size| member variable has the final overall image size yet.
184 bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the fi rst image frame yet from ImageIO. 190 bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the fi rst image frame yet from ImageIO.
185 mutable bool m_haveFrameCount : 1; 191 mutable bool m_haveFrameCount : 1;
186 }; 192 };
187 193
188 DEFINE_IMAGE_TYPE_CASTS(BitmapImage); 194 DEFINE_IMAGE_TYPE_CASTS(BitmapImage);
189 195
190 } // namespace blink 196 } // namespace blink
191 197
192 #endif 198 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698