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

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

Issue 2398453002: Rewrap comments to 80 columns in Source/platform/graphics/. (Closed)
Patch Set: Review feedback 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 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Construct a BitmapImage with the given orientation. 94 // Construct a BitmapImage with the given orientation.
95 static PassRefPtr<BitmapImage> createWithOrientationForTesting( 95 static PassRefPtr<BitmapImage> createWithOrientationForTesting(
96 const SkBitmap&, 96 const SkBitmap&,
97 ImageOrientation); 97 ImageOrientation);
98 // Advance the image animation by one frame. 98 // Advance the image animation by one frame.
99 void advanceAnimationForTesting() override { internalAdvanceAnimation(); } 99 void advanceAnimationForTesting() override { internalAdvanceAnimation(); }
100 100
101 private: 101 private:
102 enum RepetitionCountStatus { 102 enum RepetitionCountStatus {
103 Unknown, // We haven't checked the source's repetition count. 103 Unknown, // We haven't checked the source's repetition count.
104 Uncertain, // We have a repetition count, but it might be wrong (some GIFs have a count after the image data, and will report "loop once" until all data ha s been decoded). 104 Uncertain, // We have a repetition count, but it might be wrong (some GIFs
105 // have a count after the image data, and will report "loop
106 // once" until all data has been decoded).
105 Certain // The repetition count is known to be correct. 107 Certain // The repetition count is known to be correct.
106 }; 108 };
107 109
108 BitmapImage(const SkBitmap&, ImageObserver* = 0); 110 BitmapImage(const SkBitmap&, ImageObserver* = 0);
109 BitmapImage(ImageObserver* = 0); 111 BitmapImage(ImageObserver* = 0);
110 112
111 void draw(SkCanvas*, 113 void draw(SkCanvas*,
112 const SkPaint&, 114 const SkPaint&,
113 const FloatRect& dstRect, 115 const FloatRect& dstRect,
114 const FloatRect& srcRect, 116 const FloatRect& srcRect,
(...skipping 27 matching lines...) Expand all
142 // Notifies observers that the memory footprint has changed. 144 // Notifies observers that the memory footprint has changed.
143 void notifyMemoryChanged(); 145 void notifyMemoryChanged();
144 146
145 // Whether or not size is available yet. 147 // Whether or not size is available yet.
146 bool isSizeAvailable(); 148 bool isSizeAvailable();
147 149
148 // Animation. 150 // Animation.
149 // We start and stop animating lazily. Animation starts when the image is 151 // We start and stop animating lazily. Animation starts when the image is
150 // rendered, and automatically stops once no observer wants to render the 152 // rendered, and automatically stops once no observer wants to render the
151 // image. 153 // image.
152 int repetitionCount( 154
153 bool 155 // |imageKnownToBeComplete| should be set if the caller knows the entire image
154 imageKnownToBeComplete); // |imageKnownToBeComplete| should be set if the caller knows the entire image has been decoded. 156 // has been decoded.
157 int repetitionCount(bool imageKnownToBeComplete);
158
155 bool shouldAnimate(); 159 bool shouldAnimate();
156 void startAnimation(CatchUpAnimation = CatchUp) override; 160 void startAnimation(CatchUpAnimation = CatchUp) override;
157 void stopAnimation(); 161 void stopAnimation();
158 void advanceAnimation(TimerBase*); 162 void advanceAnimation(TimerBase*);
163
159 // Advance the animation and let the next frame get scheduled without 164 // Advance the animation and let the next frame get scheduled without
160 // catch-up logic. For large images with slow or heavily-loaded systems, 165 // catch-up logic. For large images with slow or heavily-loaded systems,
161 // throwing away data as we go (see destroyDecodedData()) means we can spend 166 // throwing away data as we go (see destroyDecodedData()) means we can spend
162 // so much time re-decoding data that we are always behind. To prevent this, 167 // so much time re-decoding data that we are always behind. To prevent this,
163 // we force the next animation to skip the catch up logic. 168 // we force the next animation to skip the catch up logic.
164 void advanceAnimationWithoutCatchUp(TimerBase*); 169 void advanceAnimationWithoutCatchUp(TimerBase*);
165 170
166 // This function does the real work of advancing the animation. When 171 // This function does the real work of advancing the animation. When
167 // skipping frames to catch up, we're in the middle of a loop trying to skip 172 // skipping frames to catch up, we're in the middle of a loop trying to skip
168 // over a bunch of animation frames, so we should not do things like decode 173 // over a bunch of animation frames, so we should not do things like decode
169 // each one or notify our observers. 174 // each one or notify our observers.
170 // Returns whether the animation was advanced. 175 // Returns whether the animation was advanced.
171 enum AnimationAdvancement { Normal, SkipFramesToCatchUp }; 176 enum AnimationAdvancement { Normal, SkipFramesToCatchUp };
172 bool internalAdvanceAnimation(AnimationAdvancement = Normal); 177 bool internalAdvanceAnimation(AnimationAdvancement = Normal);
173 178
174 void notifyObserversOfAnimationAdvance(TimerBase*); 179 void notifyObserversOfAnimationAdvance(TimerBase*);
175 180
176 ImageSource m_source; 181 ImageSource m_source;
177 mutable IntSize 182 mutable IntSize m_size; // The size to use for the overall image (will just
178 m_size; // The size to use for the overall image (will just be the size o f the first image). 183 // be the size of the first image).
179 mutable IntSize m_sizeRespectingOrientation; 184 mutable IntSize m_sizeRespectingOrientation;
180 185
181 size_t m_currentFrame; // The index of the current frame of animation. 186 size_t m_currentFrame; // The index of the current frame of animation.
182 Vector<FrameData, 1> 187 Vector<FrameData, 1> m_frames; // An array of the cached frames of the
183 m_frames; // An array of the cached frames of the animation. We have to r ef frames to pin them in the cache. 188 // animation. We have to ref frames to pin
189 // them in the cache.
184 190
185 sk_sp<SkImage> 191 sk_sp<SkImage>
186 m_cachedFrame; // A cached copy of the most recently-accessed frame. 192 m_cachedFrame; // A cached copy of the most recently-accessed frame.
187 size_t m_cachedFrameIndex; // Index of the frame that is cached. 193 size_t m_cachedFrameIndex; // Index of the frame that is cached.
188 194
189 std::unique_ptr<Timer<BitmapImage>> m_frameTimer; 195 std::unique_ptr<Timer<BitmapImage>> m_frameTimer;
190 int m_repetitionCount; // How many total animation loops we should do. This will be cAnimationNone if this image type is incapable of animation. 196 int m_repetitionCount; // How many total animation loops we should do. This
197 // will be cAnimationNone if this image type is
198 // incapable of animation.
191 RepetitionCountStatus m_repetitionCountStatus; 199 RepetitionCountStatus m_repetitionCountStatus;
192 int m_repetitionsComplete; // How many repetitions we've finished. 200 int m_repetitionsComplete; // How many repetitions we've finished.
193 double 201 double m_desiredFrameStartTime; // The system time at which we hope to see
194 m_desiredFrameStartTime; // The system time at which we hope to see the n ext call to startAnimation(). 202 // the next call to startAnimation().
195 203
196 size_t m_frameCount; 204 size_t m_frameCount;
197 205
198 ImageAnimationPolicy 206 ImageAnimationPolicy
199 m_animationPolicy; // Whether or not we can play animation. 207 m_animationPolicy; // Whether or not we can play animation.
200 208
201 bool 209 bool m_animationFinished : 1; // Whether we've completed the entire
202 m_animationFinished : 1; // Whether or not we've completed the entire ani mation. 210 // animation.
203 211
204 bool m_allDataReceived : 1; // Whether or not we've received all our data. 212 bool m_allDataReceived : 1; // Whether we've received all our data.
205 mutable bool 213 mutable bool m_haveSize : 1; // Whether our |m_size| member variable has the
206 m_haveSize : 1; // Whether or not our |m_size| member variable has the fi nal overall image size yet. 214 // final overall image size yet.
207 bool 215 bool m_sizeAvailable : 1; // Whether we can obtain the size of the first
208 m_sizeAvailable : 1; // Whether or not we can obtain the size of the firs t image frame yet from ImageIO. 216 // image frame from ImageIO yet.
209 mutable bool m_haveFrameCount : 1; 217 mutable bool m_haveFrameCount : 1;
210 }; 218 };
211 219
212 DEFINE_IMAGE_TYPE_CASTS(BitmapImage); 220 DEFINE_IMAGE_TYPE_CASTS(BitmapImage);
213 221
214 } // namespace blink 222 } // namespace blink
215 223
216 #endif 224 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698