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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 inline void setRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b,
unsigned a) | 183 inline void setRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b,
unsigned a) |
184 { | 184 { |
185 if (m_premultiplyAlpha) | 185 if (m_premultiplyAlpha) |
186 setRGBAPremultiply(dest, r, g, b, a); | 186 setRGBAPremultiply(dest, r, g, b, a); |
187 else | 187 else |
188 setRGBARaw(dest, r, g, b, a); | 188 setRGBARaw(dest, r, g, b, a); |
189 } | 189 } |
190 | 190 |
191 inline void setRGBAPremultiply(PixelData* dest, unsigned r, unsigned g,
unsigned b, unsigned a) | 191 inline void setRGBAPremultiply(PixelData* dest, unsigned r, unsigned g,
unsigned b, unsigned a) |
192 { | 192 { |
193 ASSERT(m_premultiplyAlpha); | |
194 | |
195 if (!a) { | |
196 *dest = 0; | |
197 return; | |
198 } | |
199 if (a < 255) { | 193 if (a < 255) { |
| 194 if (!a) { |
| 195 *dest = 0; |
| 196 return; |
| 197 } |
200 unsigned alphaMult = a * fixPointMult; | 198 unsigned alphaMult = a * fixPointMult; |
201 r = fixPointUnsignedMultiply(r, alphaMult); | 199 r = fixPointUnsignedMultiply(r, alphaMult); |
202 g = fixPointUnsignedMultiply(g, alphaMult); | 200 g = fixPointUnsignedMultiply(g, alphaMult); |
203 b = fixPointUnsignedMultiply(b, alphaMult); | 201 b = fixPointUnsignedMultiply(b, alphaMult); |
204 } | 202 } |
205 | 203 |
206 // Call the "NoCheck" version since we may deliberately pass non-pre
multiplied | 204 // Call the "NoCheck" version since we may deliberately pass non-pre
multiplied |
207 // values, and we don't want an assert. | 205 // values, and we don't want an assert. |
208 *dest = SkPackARGB32NoCheck(a, r, g, b); | 206 *dest = SkPackARGB32NoCheck(a, r, g, b); |
209 } | 207 } |
210 | 208 |
211 inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsigned
b, unsigned a) | 209 inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsigned
b, unsigned a) |
212 { | 210 { |
213 ASSERT(!m_premultiplyAlpha); | |
214 | |
215 *dest = SkPackARGB32NoCheck(a, r, g, b); | 211 *dest = SkPackARGB32NoCheck(a, r, g, b); |
216 } | 212 } |
217 | 213 |
218 private: | 214 private: |
219 int width() const | 215 int width() const |
220 { | 216 { |
221 return m_bitmap->bitmap().width(); | 217 return m_bitmap->bitmap().width(); |
222 } | 218 } |
223 | 219 |
224 int height() const | 220 int height() const |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 460 |
465 IntSize m_size; | 461 IntSize m_size; |
466 bool m_sizeAvailable; | 462 bool m_sizeAvailable; |
467 bool m_isAllDataReceived; | 463 bool m_isAllDataReceived; |
468 bool m_failed; | 464 bool m_failed; |
469 }; | 465 }; |
470 | 466 |
471 } // namespace WebCore | 467 } // namespace WebCore |
472 | 468 |
473 #endif | 469 #endif |
OLD | NEW |