| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 | 212 |
| 213 static inline void setRGBARaw(PixelData* dest, | 213 static inline void setRGBARaw(PixelData* dest, |
| 214 unsigned r, | 214 unsigned r, |
| 215 unsigned g, | 215 unsigned g, |
| 216 unsigned b, | 216 unsigned b, |
| 217 unsigned a) { | 217 unsigned a) { |
| 218 *dest = SkPackARGB32NoCheck(a, r, g, b); | 218 *dest = SkPackARGB32NoCheck(a, r, g, b); |
| 219 } | 219 } |
| 220 | 220 |
| 221 inline void overRGBAPremultiply(PixelData* dest, |
| 222 unsigned r, |
| 223 unsigned g, |
| 224 unsigned b, |
| 225 unsigned a) { |
| 226 enum FractionControl { RoundFractionControl = 257 * 128 }; |
| 227 |
| 228 if (!a) |
| 229 return; |
| 230 |
| 231 if (a < 255) { |
| 232 unsigned alpha = a * 257; |
| 233 r = (r * alpha + RoundFractionControl) >> 16; |
| 234 g = (g * alpha + RoundFractionControl) >> 16; |
| 235 b = (b * alpha + RoundFractionControl) >> 16; |
| 236 *dest = SkPMSrcOver(SkPackARGB32NoCheck(a, r, g, b), *dest); |
| 237 } else { |
| 238 *dest = SkPackARGB32NoCheck(a, r, g, b); |
| 239 } |
| 240 } |
| 241 |
| 242 inline void overRGBARaw(PixelData* dest, |
| 243 unsigned r, |
| 244 unsigned g, |
| 245 unsigned b, |
| 246 unsigned a) { |
| 247 if (!a) |
| 248 return; |
| 249 |
| 250 unsigned aDest = SkGetPackedA32(*dest); |
| 251 if (aDest && a < 255) { |
| 252 unsigned u = a * 255; |
| 253 unsigned v = (255 - a) * aDest; |
| 254 unsigned alpha = u + v; |
| 255 unsigned rDest = SkGetPackedR32(*dest); |
| 256 unsigned gDest = SkGetPackedG32(*dest); |
| 257 unsigned bDest = SkGetPackedB32(*dest); |
| 258 a = (alpha + (alpha >> 8) + 1) >> 8; |
| 259 r = (r * u + rDest * v) / alpha; |
| 260 g = (g * u + gDest * v) / alpha; |
| 261 b = (b * u + bDest * v) / alpha; |
| 262 } |
| 263 *dest = SkPackARGB32NoCheck(a, r, g, b); |
| 264 } |
| 265 |
| 221 // Blend the RGBA pixel provided by |r|, |g|, |b|, |a| over the pixel in | 266 // Blend the RGBA pixel provided by |r|, |g|, |b|, |a| over the pixel in |
| 222 // |dest|, without premultiplication, and overwrite |dest| with the result. | 267 // |dest|, without premultiplication, and overwrite |dest| with the result. |
| 223 static inline void blendRGBARaw(PixelData* dest, | 268 static inline void blendRGBARaw(PixelData* dest, |
| 224 unsigned r, | 269 unsigned r, |
| 225 unsigned g, | 270 unsigned g, |
| 226 unsigned b, | 271 unsigned b, |
| 227 unsigned a) { | 272 unsigned a) { |
| 228 blendSrcOverDstRaw(dest, SkPackARGB32NoCheck(a, r, g, b)); | 273 blendSrcOverDstRaw(dest, SkPackARGB32NoCheck(a, r, g, b)); |
| 229 } | 274 } |
| 230 | 275 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // The frame that must be decoded before this frame can be decoded. | 328 // The frame that must be decoded before this frame can be decoded. |
| 284 // WTF::kNotFound if this frame doesn't require any previous frame. | 329 // WTF::kNotFound if this frame doesn't require any previous frame. |
| 285 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never | 330 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never |
| 286 // be read for image formats that do not have multiple frames. | 331 // be read for image formats that do not have multiple frames. |
| 287 size_t m_requiredPreviousFrameIndex; | 332 size_t m_requiredPreviousFrameIndex; |
| 288 }; | 333 }; |
| 289 | 334 |
| 290 } // namespace blink | 335 } // namespace blink |
| 291 | 336 |
| 292 #endif | 337 #endif |
| OLD | NEW |