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 11 matching lines...) Expand all Loading... |
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/geometry/IntSize.h" | 31 #include "platform/geometry/IntSize.h" |
32 #include "platform/graphics/Color.h" | |
33 #include "platform/graphics/FrameData.h" | 32 #include "platform/graphics/FrameData.h" |
34 #include "platform/graphics/Image.h" | 33 #include "platform/graphics/Image.h" |
35 #include "platform/graphics/ImageAnimationPolicy.h" | 34 #include "platform/graphics/ImageAnimationPolicy.h" |
36 #include "platform/graphics/ImageOrientation.h" | 35 #include "platform/graphics/ImageOrientation.h" |
37 #include "platform/graphics/ImageSource.h" | 36 #include "platform/graphics/ImageSource.h" |
38 #include "platform/image-decoders/ImageAnimation.h" | 37 #include "platform/image-decoders/ImageAnimation.h" |
39 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
40 #include "wtf/OwnPtr.h" | 39 #include "wtf/OwnPtr.h" |
41 | 40 |
42 namespace blink { | 41 namespace blink { |
43 | 42 |
44 template <typename T> class Timer; | 43 template <typename T> class Timer; |
45 | 44 |
46 class PLATFORM_EXPORT BitmapImage final : public Image { | 45 class PLATFORM_EXPORT BitmapImage final : public Image { |
47 friend class GeneratedImage; | 46 friend class GeneratedImage; |
48 friend class CrossfadeGeneratedImage; | 47 friend class CrossfadeGeneratedImage; |
49 friend class GradientGeneratedImage; | 48 friend class GradientGeneratedImage; |
50 friend class GraphicsContext; | 49 friend class GraphicsContext; |
51 public: | 50 public: |
52 static PassRefPtr<BitmapImage> create(ImageObserver* observer = 0) | 51 static PassRefPtr<BitmapImage> create(ImageObserver* observer = 0) |
53 { | 52 { |
54 return adoptRef(new BitmapImage(observer)); | 53 return adoptRef(new BitmapImage(observer)); |
55 } | 54 } |
56 | 55 |
57 // This allows constructing a BitmapImage with a forced non-default orientat
ion. | |
58 static PassRefPtr<BitmapImage> createWithOrientationForTesting(const SkBitma
p&, ImageOrientation); | |
59 | |
60 ~BitmapImage() override; | 56 ~BitmapImage() override; |
61 | 57 |
62 bool isBitmapImage() const override; | 58 bool isBitmapImage() const override { return true; } |
63 | 59 |
64 bool currentFrameHasSingleSecurityOrigin() const override; | 60 bool currentFrameHasSingleSecurityOrigin() const override; |
65 | 61 |
66 IntSize size() const override; | 62 IntSize size() const override; |
67 IntSize sizeRespectingOrientation() const; | 63 IntSize sizeRespectingOrientation() const; |
68 bool getHotSpot(IntPoint&) const override; | 64 bool getHotSpot(IntPoint&) const override; |
69 String filenameExtension() const override; | 65 String filenameExtension() const override; |
70 bool dataChanged(bool allDataReceived) override; | 66 bool dataChanged(bool allDataReceived) override; |
71 | 67 |
72 bool isAllDataReceived() const { return m_allDataReceived; } | 68 bool isAllDataReceived() const { return m_allDataReceived; } |
| 69 |
73 bool hasColorProfile() const; | 70 bool hasColorProfile() const; |
| 71 PassRefPtr<ColorSpaceProfile> colorProfile() const { return m_source.colorPr
ofile(); } |
| 72 PassRefPtr<SkColorFilter> imageColorTransform(); |
74 | 73 |
75 // It may look unusual that there's no start animation call as public API. | 74 // It may look unusual that there's no start animation call as public API. |
76 // This because we start and stop animating lazily. Animation starts when | 75 // This because we start and stop animating lazily. Animation starts when |
77 // the image is rendered, and automatically pauses once all observers no | 76 // the image is rendered, and automatically pauses once all observers no |
78 // longer want to render the image. | 77 // longer want to render the image. |
79 void stopAnimation() override; | 78 void stopAnimation() override; |
80 void resetAnimation() override; | 79 void resetAnimation() override; |
81 bool maybeAnimated() override; | 80 bool maybeAnimated() override; |
82 | 81 |
83 void setAnimationPolicy(ImageAnimationPolicy policy) override { m_animationP
olicy = policy; } | 82 void setAnimationPolicy(ImageAnimationPolicy policy) override { m_animationP
olicy = policy; } |
84 ImageAnimationPolicy animationPolicy() override { return m_animationPolicy;
} | 83 ImageAnimationPolicy animationPolicy() override { return m_animationPolicy;
} |
85 void advanceTime(double deltaTimeInSeconds) override; | 84 void advanceTime(double deltaTimeInSeconds) override; |
86 | 85 |
87 // Advance the image animation by one frame. | |
88 void advanceAnimationForTesting() override { internalAdvanceAnimation(false)
; } | |
89 | |
90 PassRefPtr<SkImage> imageForCurrentFrame() override; | 86 PassRefPtr<SkImage> imageForCurrentFrame() override; |
91 PassRefPtr<Image> imageForDefaultFrame() override; | 87 PassRefPtr<Image> imageForDefaultFrame() override; |
| 88 |
92 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override
; | 89 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override
; |
93 bool currentFrameIsComplete() override; | 90 bool currentFrameIsComplete() override; |
94 bool currentFrameIsLazyDecoded() override; | 91 bool currentFrameIsLazyDecoded() override; |
95 | 92 |
| 93 PassRefPtr<SkImage> pictureForCurrentFrame(); |
| 94 |
| 95 // FIXME: consider renaming this to orientationForCurrentFrame(), or perhaps |
| 96 // imageOrientation, since orientation is the same for all image frames. |
96 ImageOrientation currentFrameOrientation(); | 97 ImageOrientation currentFrameOrientation(); |
97 | 98 |
| 99 // Construct a BitmapImage with the given orientation. |
| 100 static PassRefPtr<BitmapImage> createWithOrientationForTesting(const SkBitma
p&, ImageOrientation); |
| 101 // Advance an animated image by one frame. |
| 102 void advanceAnimationForTesting() override { internalAdvanceAnimation(false)
; } |
| 103 |
98 private: | 104 private: |
99 friend class BitmapImageTest; | 105 friend class BitmapImageTest; |
100 | 106 |
101 void updateSize() const; | 107 void updateSize() const; |
102 | 108 |
103 private: | 109 private: |
104 enum RepetitionCountStatus { | 110 enum RepetitionCountStatus { |
105 Unknown, // We haven't checked the source's repetition count. | 111 Unknown, // We haven't checked the source's repetition count. |
106 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). | 112 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). |
107 Certain // The repetition count is known to be correct. | 113 Certain // The repetition count is known to be correct. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the fi
rst image frame yet from ImageIO. | 197 bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the fi
rst image frame yet from ImageIO. |
192 mutable bool m_hasUniformFrameSize : 1; | 198 mutable bool m_hasUniformFrameSize : 1; |
193 mutable bool m_haveFrameCount : 1; | 199 mutable bool m_haveFrameCount : 1; |
194 }; | 200 }; |
195 | 201 |
196 DEFINE_IMAGE_TYPE_CASTS(BitmapImage); | 202 DEFINE_IMAGE_TYPE_CASTS(BitmapImage); |
197 | 203 |
198 } // namespace blink | 204 } // namespace blink |
199 | 205 |
200 #endif | 206 #endif |
OLD | NEW |