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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 friend class GradientGeneratedImage; | 48 friend class GradientGeneratedImage; |
49 friend class GraphicsContext; | 49 friend class GraphicsContext; |
50 public: | 50 public: |
51 static PassRefPtr<BitmapImage> create(PassRefPtr<NativeImageSkia>, ImageObse
rver* = 0); | 51 static PassRefPtr<BitmapImage> create(PassRefPtr<NativeImageSkia>, ImageObse
rver* = 0); |
52 | 52 |
53 static PassRefPtr<BitmapImage> create(ImageObserver* observer = 0) | 53 static PassRefPtr<BitmapImage> create(ImageObserver* observer = 0) |
54 { | 54 { |
55 return adoptRef(new BitmapImage(observer)); | 55 return adoptRef(new BitmapImage(observer)); |
56 } | 56 } |
57 | 57 |
| 58 // This allows constructing a BitmapImage with a forced non-default orientat
ion. |
| 59 static PassRefPtr<BitmapImage> createWithOrientationForTesting(PassRefPtr<Na
tiveImageSkia>, ImageOrientation); |
| 60 |
58 virtual ~BitmapImage(); | 61 virtual ~BitmapImage(); |
59 | 62 |
60 virtual bool isBitmapImage() const override; | 63 virtual bool isBitmapImage() const override; |
61 | 64 |
62 virtual bool currentFrameHasSingleSecurityOrigin() const override; | 65 virtual bool currentFrameHasSingleSecurityOrigin() const override; |
63 | 66 |
64 virtual IntSize size() const override; | 67 virtual IntSize size() const override; |
65 IntSize sizeRespectingOrientation() const; | 68 IntSize sizeRespectingOrientation() const; |
66 virtual bool getHotSpot(IntPoint&) const override; | 69 virtual bool getHotSpot(IntPoint&) const override; |
67 virtual String filenameExtension() const override; | 70 virtual String filenameExtension() const override; |
(...skipping 21 matching lines...) Expand all Loading... |
89 | 92 |
90 #if ENABLE(ASSERT) | 93 #if ENABLE(ASSERT) |
91 virtual bool notSolidColor() override; | 94 virtual bool notSolidColor() override; |
92 #endif | 95 #endif |
93 | 96 |
94 private: | 97 private: |
95 friend class BitmapImageTest; | 98 friend class BitmapImageTest; |
96 | 99 |
97 void updateSize() const; | 100 void updateSize() const; |
98 | 101 |
99 protected: | 102 private: |
100 enum RepetitionCountStatus { | 103 enum RepetitionCountStatus { |
101 Unknown, // We haven't checked the source's repetition count. | 104 Unknown, // We haven't checked the source's repetition count. |
102 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). | 105 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). |
103 Certain // The repetition count is known to be correct. | 106 Certain // The repetition count is known to be correct. |
104 }; | 107 }; |
105 | 108 |
106 BitmapImage(PassRefPtr<NativeImageSkia>, ImageObserver* = 0); | 109 BitmapImage(PassRefPtr<NativeImageSkia>, ImageObserver* = 0); |
107 BitmapImage(ImageObserver* = 0); | 110 BitmapImage(ImageObserver* = 0); |
108 | 111 |
109 void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRe
ct, SkXfermode::Mode, RespectImageOrientationEnum) override; | 112 void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRe
ct, SkXfermode::Mode, RespectImageOrientationEnum) override; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 bool internalAdvanceAnimation(bool skippingFrames); | 161 bool internalAdvanceAnimation(bool skippingFrames); |
159 | 162 |
160 // Checks to see if the image is a 1x1 solid color. We optimize these image
s and just do a fill rect instead. | 163 // Checks to see if the image is a 1x1 solid color. We optimize these image
s and just do a fill rect instead. |
161 // This check should happen regardless whether m_checkedForSolidColor is alr
eady set, as the frame may have | 164 // This check should happen regardless whether m_checkedForSolidColor is alr
eady set, as the frame may have |
162 // changed. | 165 // changed. |
163 void checkForSolidColor(); | 166 void checkForSolidColor(); |
164 | 167 |
165 virtual bool mayFillWithSolidColor() override; | 168 virtual bool mayFillWithSolidColor() override; |
166 virtual Color solidColor() const override; | 169 virtual Color solidColor() const override; |
167 | 170 |
168 private: | |
169 ImageSource m_source; | 171 ImageSource m_source; |
170 mutable IntSize m_size; // The size to use for the overall image (will just
be the size of the first image). | 172 mutable IntSize m_size; // The size to use for the overall image (will just
be the size of the first image). |
171 mutable IntSize m_sizeRespectingOrientation; | 173 mutable IntSize m_sizeRespectingOrientation; |
172 | 174 |
173 size_t m_currentFrame; // The index of the current frame of animation. | 175 size_t m_currentFrame; // The index of the current frame of animation. |
174 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. | 176 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. |
175 | 177 |
176 Timer<BitmapImage>* m_frameTimer; | 178 Timer<BitmapImage>* m_frameTimer; |
177 int m_repetitionCount; // How many total animation loops we should do. This
will be cAnimationNone if this image type is incapable of animation. | 179 int m_repetitionCount; // How many total animation loops we should do. This
will be cAnimationNone if this image type is incapable of animation. |
178 RepetitionCountStatus m_repetitionCountStatus; | 180 RepetitionCountStatus m_repetitionCountStatus; |
(...skipping 16 matching lines...) Expand all Loading... |
195 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. |
196 mutable bool m_hasUniformFrameSize : 1; | 198 mutable bool m_hasUniformFrameSize : 1; |
197 mutable bool m_haveFrameCount : 1; | 199 mutable bool m_haveFrameCount : 1; |
198 }; | 200 }; |
199 | 201 |
200 DEFINE_IMAGE_TYPE_CASTS(BitmapImage); | 202 DEFINE_IMAGE_TYPE_CASTS(BitmapImage); |
201 | 203 |
202 } // namespace blink | 204 } // namespace blink |
203 | 205 |
204 #endif | 206 #endif |
OLD | NEW |