OLD | NEW |
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 10 matching lines...) Expand all Loading... |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #ifndef BitmapImage_h | 28 #ifndef BitmapImage_h |
29 #define BitmapImage_h | 29 #define BitmapImage_h |
30 | 30 |
| 31 #include "platform/Timer.h" |
31 #include "platform/geometry/IntSize.h" | 32 #include "platform/geometry/IntSize.h" |
32 #include "platform/graphics/Color.h" | 33 #include "platform/graphics/Color.h" |
33 #include "platform/graphics/FrameData.h" | 34 #include "platform/graphics/FrameData.h" |
34 #include "platform/graphics/Image.h" | 35 #include "platform/graphics/Image.h" |
35 #include "platform/graphics/ImageAnimationPolicy.h" | 36 #include "platform/graphics/ImageAnimationPolicy.h" |
36 #include "platform/graphics/ImageOrientation.h" | 37 #include "platform/graphics/ImageOrientation.h" |
37 #include "platform/graphics/ImageSource.h" | 38 #include "platform/graphics/ImageSource.h" |
38 #include "platform/image-decoders/ImageAnimation.h" | 39 #include "platform/image-decoders/ImageAnimation.h" |
39 #include "wtf/Forward.h" | 40 #include "wtf/Forward.h" |
40 #include <memory> | 41 #include <memory> |
41 | 42 |
42 namespace blink { | 43 namespace blink { |
43 | 44 |
44 template <typename T> class Timer; | |
45 | |
46 class PLATFORM_EXPORT BitmapImage final : public Image { | 45 class PLATFORM_EXPORT BitmapImage final : public Image { |
47 friend class BitmapImageTest; | 46 friend class BitmapImageTest; |
48 friend class CrossfadeGeneratedImage; | 47 friend class CrossfadeGeneratedImage; |
49 friend class GeneratedImage; | 48 friend class GeneratedImage; |
50 friend class GradientGeneratedImage; | 49 friend class GradientGeneratedImage; |
51 friend class GraphicsContext; | 50 friend class GraphicsContext; |
52 public: | 51 public: |
53 static PassRefPtr<BitmapImage> create(ImageObserver* observer = 0) | 52 static PassRefPtr<BitmapImage> create(ImageObserver* observer = 0) |
54 { | 53 { |
55 return adoptRef(new BitmapImage(observer)); | 54 return adoptRef(new BitmapImage(observer)); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 bool isSizeAvailable(); | 135 bool isSizeAvailable(); |
137 | 136 |
138 // Animation. | 137 // Animation. |
139 // We start and stop animating lazily. Animation starts when the image is | 138 // We start and stop animating lazily. Animation starts when the image is |
140 // rendered, and automatically stops once no observer wants to render the | 139 // rendered, and automatically stops once no observer wants to render the |
141 // image. | 140 // image. |
142 int repetitionCount(bool imageKnownToBeComplete); // |imageKnownToBeComplet
e| should be set if the caller knows the entire image has been decoded. | 141 int repetitionCount(bool imageKnownToBeComplete); // |imageKnownToBeComplet
e| should be set if the caller knows the entire image has been decoded. |
143 bool shouldAnimate(); | 142 bool shouldAnimate(); |
144 void startAnimation(CatchUpAnimation = CatchUp) override; | 143 void startAnimation(CatchUpAnimation = CatchUp) override; |
145 void stopAnimation(); | 144 void stopAnimation(); |
146 void advanceAnimation(Timer<BitmapImage>*); | 145 void advanceAnimation(TimerBase*); |
147 // Advance the animation and let the next frame get scheduled without | 146 // Advance the animation and let the next frame get scheduled without |
148 // 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, |
149 // 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 |
150 // 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, |
151 // we force the next animation to skip the catch up logic. | 150 // we force the next animation to skip the catch up logic. |
152 void advanceAnimationWithoutCatchUp(Timer<BitmapImage>*); | 151 void advanceAnimationWithoutCatchUp(TimerBase*); |
153 | 152 |
154 // Function that does the real work of advancing the animation. When | 153 // Function that does the real work of advancing the animation. When |
155 // skippingFrames is true, we're in the middle of a loop trying to skip over | 154 // skippingFrames is true, we're in the middle of a loop trying to skip over |
156 // a bunch of animation frames, so we should not do things like decode each | 155 // a bunch of animation frames, so we should not do things like decode each |
157 // one or notify our observers. | 156 // one or notify our observers. |
158 // Returns whether the animation was advanced. | 157 // Returns whether the animation was advanced. |
159 bool internalAdvanceAnimation(bool skippingFrames); | 158 bool internalAdvanceAnimation(bool skippingFrames); |
160 | 159 |
161 ImageSource m_source; | 160 ImageSource m_source; |
162 mutable IntSize m_size; // The size to use for the overall image (will just
be the size of the first image). | 161 mutable IntSize m_size; // The size to use for the overall image (will just
be the size of the first image). |
(...skipping 21 matching lines...) Expand all Loading... |
184 mutable bool m_haveSize : 1; // Whether or not our |m_size| member variable
has the final overall image size yet. | 183 mutable bool m_haveSize : 1; // Whether or not our |m_size| member variable
has the final overall image size yet. |
185 bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the fi
rst image frame yet from ImageIO. | 184 bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the fi
rst image frame yet from ImageIO. |
186 mutable bool m_haveFrameCount : 1; | 185 mutable bool m_haveFrameCount : 1; |
187 }; | 186 }; |
188 | 187 |
189 DEFINE_IMAGE_TYPE_CASTS(BitmapImage); | 188 DEFINE_IMAGE_TYPE_CASTS(BitmapImage); |
190 | 189 |
191 } // namespace blink | 190 } // namespace blink |
192 | 191 |
193 #endif | 192 #endif |
OLD | NEW |