OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 PassRefPtr<NativeImageSkia> asNewNativeImage() const; | 112 PassRefPtr<NativeImageSkia> asNewNativeImage() const; |
113 | 113 |
114 bool hasAlpha() const; | 114 bool hasAlpha() const; |
115 const IntRect& originalFrameRect() const { return m_originalFrameRect; } | 115 const IntRect& originalFrameRect() const { return m_originalFrameRect; } |
116 Status status() const { return m_status; } | 116 Status status() const { return m_status; } |
117 unsigned duration() const { return m_duration; } | 117 unsigned duration() const { return m_duration; } |
118 DisposalMethod disposalMethod() const { return m_disposalMethod; } | 118 DisposalMethod disposalMethod() const { return m_disposalMethod; } |
119 AlphaBlendSource alphaBlendSource() const { return m_alphaBlendSource; } | 119 AlphaBlendSource alphaBlendSource() const { return m_alphaBlendSource; } |
120 bool premultiplyAlpha() const { return m_premultiplyAlpha; } | 120 bool premultiplyAlpha() const { return m_premultiplyAlpha; } |
121 SkBitmap::Allocator* allocator() const { return m_allocator; } | 121 SkBitmap::Allocator* allocator() const { return m_allocator; } |
122 const SkBitmap& getSkBitmap() const { return m_bitmap->bitmap(); } | 122 const SkBitmap& getSkBitmap() const { return m_bitmap; } |
123 // Returns true if the pixels changed, but the bitmap has not yet been notif
ied. | 123 // Returns true if the pixels changed, but the bitmap has not yet been notif
ied. |
124 bool pixelsChanged() const { return m_pixelsChanged; } | 124 bool pixelsChanged() const { return m_pixelsChanged; } |
125 | 125 |
126 size_t requiredPreviousFrameIndex() const | 126 size_t requiredPreviousFrameIndex() const |
127 { | 127 { |
128 ASSERT(m_requiredPreviousFrameIndexValid); | 128 ASSERT(m_requiredPreviousFrameIndexValid); |
129 return m_requiredPreviousFrameIndex; | 129 return m_requiredPreviousFrameIndex; |
130 } | 130 } |
131 #if !ASSERT_DISABLED | 131 #if !ASSERT_DISABLED |
132 bool requiredPreviousFrameIndexValid() const { return m_requiredPreviousFram
eIndexValid; } | 132 bool requiredPreviousFrameIndexValid() const { return m_requiredPreviousFram
eIndexValid; } |
133 #endif | 133 #endif |
134 void setHasAlpha(bool alpha); | 134 void setHasAlpha(bool alpha); |
135 void setOriginalFrameRect(const IntRect& r) { m_originalFrameRect = r; } | 135 void setOriginalFrameRect(const IntRect& r) { m_originalFrameRect = r; } |
136 void setStatus(Status); | 136 void setStatus(Status); |
137 void setDuration(unsigned duration) { m_duration = duration; } | 137 void setDuration(unsigned duration) { m_duration = duration; } |
138 void setDisposalMethod(DisposalMethod disposalMethod) { m_disposalMethod = d
isposalMethod; } | 138 void setDisposalMethod(DisposalMethod disposalMethod) { m_disposalMethod = d
isposalMethod; } |
139 void setAlphaBlendSource(AlphaBlendSource alphaBlendSource) { m_alphaBlendSo
urce = alphaBlendSource; } | 139 void setAlphaBlendSource(AlphaBlendSource alphaBlendSource) { m_alphaBlendSo
urce = alphaBlendSource; } |
140 void setPremultiplyAlpha(bool premultiplyAlpha) { m_premultiplyAlpha = premu
ltiplyAlpha; } | 140 void setPremultiplyAlpha(bool premultiplyAlpha) { m_premultiplyAlpha = premu
ltiplyAlpha; } |
141 void setMemoryAllocator(SkBitmap::Allocator* allocator) { m_allocator = allo
cator; } | 141 void setMemoryAllocator(SkBitmap::Allocator* allocator) { m_allocator = allo
cator; } |
142 void setSkBitmap(const SkBitmap& bitmap) { m_bitmap = NativeImageSkia::creat
e(bitmap); } | 142 void setSkBitmap(const SkBitmap& bitmap) { m_bitmap = bitmap; } |
143 // The pixelsChanged flag needs to be set when the raw pixel data was direct
ly modified | 143 // The pixelsChanged flag needs to be set when the raw pixel data was direct
ly modified |
144 // (e.g. through a pointer or setRGBA). The flag is usually set after a batc
h of changes was made. | 144 // (e.g. through a pointer or setRGBA). The flag is usually set after a batc
h of changes was made. |
145 void setPixelsChanged(bool pixelsChanged) { m_pixelsChanged = pixelsChanged;
} | 145 void setPixelsChanged(bool pixelsChanged) { m_pixelsChanged = pixelsChanged;
} |
146 | 146 |
147 void setRequiredPreviousFrameIndex(size_t previousFrameIndex) | 147 void setRequiredPreviousFrameIndex(size_t previousFrameIndex) |
148 { | 148 { |
149 m_requiredPreviousFrameIndex = previousFrameIndex; | 149 m_requiredPreviousFrameIndex = previousFrameIndex; |
150 #if !ASSERT_DISABLED | 150 #if !ASSERT_DISABLED |
151 m_requiredPreviousFrameIndexValid = true; | 151 m_requiredPreviousFrameIndexValid = true; |
152 #endif | 152 #endif |
153 } | 153 } |
154 | 154 |
155 inline PixelData* getAddr(int x, int y) | 155 inline PixelData* getAddr(int x, int y) |
156 { | 156 { |
157 return m_bitmap->bitmap().getAddr32(x, y); | 157 return m_bitmap.getAddr32(x, y); |
158 } | 158 } |
159 | 159 |
160 inline void setRGBA(int x, int y, unsigned r, unsigned g, unsigned b, unsign
ed a) | 160 inline void setRGBA(int x, int y, unsigned r, unsigned g, unsigned b, unsign
ed a) |
161 { | 161 { |
162 setRGBA(getAddr(x, y), r, g, b, a); | 162 setRGBA(getAddr(x, y), r, g, b, a); |
163 } | 163 } |
164 | 164 |
165 static const unsigned div255 = static_cast<unsigned>(1.0 / 255 * (1 << 24))
+ 1; | 165 static const unsigned div255 = static_cast<unsigned>(1.0 / 255 * (1 << 24))
+ 1; |
166 | 166 |
167 inline void setRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b, uns
igned a) | 167 inline void setRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b, uns
igned a) |
(...skipping 17 matching lines...) Expand all Loading... |
185 | 185 |
186 inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsigned b,
unsigned a) | 186 inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsigned b,
unsigned a) |
187 { | 187 { |
188 *dest = SkPackARGB32NoCheck(a, r, g, b); | 188 *dest = SkPackARGB32NoCheck(a, r, g, b); |
189 } | 189 } |
190 | 190 |
191 // Notifies the SkBitmap if any pixels changed and resets the flag. | 191 // Notifies the SkBitmap if any pixels changed and resets the flag. |
192 inline void notifyBitmapIfPixelsChanged() | 192 inline void notifyBitmapIfPixelsChanged() |
193 { | 193 { |
194 if (m_pixelsChanged) | 194 if (m_pixelsChanged) |
195 m_bitmap->bitmap().notifyPixelsChanged(); | 195 m_bitmap.notifyPixelsChanged(); |
196 m_pixelsChanged = false; | 196 m_pixelsChanged = false; |
197 } | 197 } |
198 | 198 |
199 private: | 199 private: |
200 int width() const | 200 int width() const |
201 { | 201 { |
202 return m_bitmap->bitmap().width(); | 202 return m_bitmap.width(); |
203 } | 203 } |
204 | 204 |
205 int height() const | 205 int height() const |
206 { | 206 { |
207 return m_bitmap->bitmap().height(); | 207 return m_bitmap.height(); |
208 } | 208 } |
209 | 209 |
210 RefPtr<NativeImageSkia> m_bitmap; | 210 SkBitmap m_bitmap; |
211 SkBitmap::Allocator* m_allocator; | 211 SkBitmap::Allocator* m_allocator; |
212 bool m_hasAlpha; | 212 bool m_hasAlpha; |
213 // This will always just be the entire buffer except for GIF or WebP | 213 // This will always just be the entire buffer except for GIF or WebP |
214 // frames whose original rect was smaller than the overall image size. | 214 // frames whose original rect was smaller than the overall image size. |
215 IntRect m_originalFrameRect; | 215 IntRect m_originalFrameRect; |
216 Status m_status; | 216 Status m_status; |
217 unsigned m_duration; | 217 unsigned m_duration; |
218 DisposalMethod m_disposalMethod; | 218 DisposalMethod m_disposalMethod; |
219 AlphaBlendSource m_alphaBlendSource; | 219 AlphaBlendSource m_alphaBlendSource; |
220 bool m_premultiplyAlpha; | 220 bool m_premultiplyAlpha; |
221 // True if the pixels changed, but the bitmap has not yet been notified. | 221 // True if the pixels changed, but the bitmap has not yet been notified. |
222 bool m_pixelsChanged; | 222 bool m_pixelsChanged; |
223 | 223 |
224 // The frame that must be decoded before this frame can be decoded. | 224 // The frame that must be decoded before this frame can be decoded. |
225 // WTF::kNotFound if this frame doesn't require any previous frame. | 225 // WTF::kNotFound if this frame doesn't require any previous frame. |
226 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never | 226 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never |
227 // be read for image formats that do not have multiple frames. | 227 // be read for image formats that do not have multiple frames. |
228 size_t m_requiredPreviousFrameIndex; | 228 size_t m_requiredPreviousFrameIndex; |
229 #if !ASSERT_DISABLED | 229 #if !ASSERT_DISABLED |
230 bool m_requiredPreviousFrameIndexValid; | 230 bool m_requiredPreviousFrameIndexValid; |
231 #endif | 231 #endif |
232 }; | 232 }; |
233 | 233 |
234 } // namespace WebCore | 234 } // namespace WebCore |
235 | 235 |
236 #endif | 236 #endif |
OLD | NEW |