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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 inline PixelData* getAddr(int x, int y) | 155 inline PixelData* getAddr(int x, int y) |
156 { | 156 { |
157 return m_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 inline void setRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b, uns
igned a) |
| 166 { |
| 167 if (m_premultiplyAlpha) |
| 168 setRGBAPremultiply(dest, r, g, b, a); |
| 169 else |
| 170 *dest = SkPackARGB32NoCheck(a, r, g, b); |
| 171 } |
| 172 |
165 static const unsigned div255 = static_cast<unsigned>(1.0 / 255 * (1 << 24))
+ 1; | 173 static const unsigned div255 = static_cast<unsigned>(1.0 / 255 * (1 << 24))
+ 1; |
166 | 174 |
167 inline void setRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b, uns
igned a) | 175 static inline void setRGBAPremultiply(PixelData* dest, unsigned r, unsigned
g, unsigned b, unsigned a) |
168 { | 176 { |
169 if (m_premultiplyAlpha && a < 255) { | 177 if (a < 255) { |
170 if (!a) { | 178 if (!a) { |
171 *dest = 0; | 179 *dest = 0; |
172 return; | 180 return; |
173 } | 181 } |
174 | 182 |
175 unsigned alpha = a * div255; | 183 unsigned alpha = a * div255; |
176 r = (r * alpha) >> 24; | 184 r = (r * alpha) >> 24; |
177 g = (g * alpha) >> 24; | 185 g = (g * alpha) >> 24; |
178 b = (b * alpha) >> 24; | 186 b = (b * alpha) >> 24; |
179 } | 187 } |
180 | 188 |
181 // Call the "NoCheck" version since we may deliberately pass non-premult
iplied | 189 // Call the "NoCheck" version since we may deliberately pass non-premult
iplied |
182 // values, and we don't want an assert. | 190 // values, and we don't want an assert. |
183 *dest = SkPackARGB32NoCheck(a, r, g, b); | 191 *dest = SkPackARGB32NoCheck(a, r, g, b); |
184 } | 192 } |
185 | 193 |
186 inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsigned b,
unsigned a) | 194 static inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsig
ned b, unsigned a) |
187 { | 195 { |
188 *dest = SkPackARGB32NoCheck(a, r, g, b); | 196 *dest = SkPackARGB32NoCheck(a, r, g, b); |
189 } | 197 } |
190 | 198 |
191 // Notifies the SkBitmap if any pixels changed and resets the flag. | 199 // Notifies the SkBitmap if any pixels changed and resets the flag. |
192 inline void notifyBitmapIfPixelsChanged() | 200 inline void notifyBitmapIfPixelsChanged() |
193 { | 201 { |
194 if (m_pixelsChanged) | 202 if (m_pixelsChanged) |
195 m_bitmap.notifyPixelsChanged(); | 203 m_bitmap.notifyPixelsChanged(); |
196 m_pixelsChanged = false; | 204 m_pixelsChanged = false; |
(...skipping 30 matching lines...) Expand all Loading... |
227 // be read for image formats that do not have multiple frames. | 235 // be read for image formats that do not have multiple frames. |
228 size_t m_requiredPreviousFrameIndex; | 236 size_t m_requiredPreviousFrameIndex; |
229 #if !ASSERT_DISABLED | 237 #if !ASSERT_DISABLED |
230 bool m_requiredPreviousFrameIndexValid; | 238 bool m_requiredPreviousFrameIndexValid; |
231 #endif | 239 #endif |
232 }; | 240 }; |
233 | 241 |
234 } // namespace WebCore | 242 } // namespace WebCore |
235 | 243 |
236 #endif | 244 #endif |
OLD | NEW |