| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 171         } | 171         } | 
| 172 | 172 | 
| 173         *dest = SkPackARGB32NoCheck(a, r, g, b); | 173         *dest = SkPackARGB32NoCheck(a, r, g, b); | 
| 174     } | 174     } | 
| 175 | 175 | 
| 176     static inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsig
     ned b, unsigned a) | 176     static inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsig
     ned b, unsigned a) | 
| 177     { | 177     { | 
| 178         *dest = SkPackARGB32NoCheck(a, r, g, b); | 178         *dest = SkPackARGB32NoCheck(a, r, g, b); | 
| 179     } | 179     } | 
| 180 | 180 | 
|  | 181     inline void overRGBAPremultiply(PixelData* dest, unsigned r, unsigned g, uns
     igned b, unsigned a) | 
|  | 182     { | 
|  | 183         enum FractionControl { RoundFractionControl = 257 * 128 }; | 
|  | 184 | 
|  | 185         if (!a) | 
|  | 186             return; | 
|  | 187 | 
|  | 188         if (a < 255) { | 
|  | 189             unsigned alpha = a * 257; | 
|  | 190             r = (r * alpha + RoundFractionControl) >> 16; | 
|  | 191             g = (g * alpha + RoundFractionControl) >> 16; | 
|  | 192             b = (b * alpha + RoundFractionControl) >> 16; | 
|  | 193             *dest = SkPMSrcOver(SkPackARGB32NoCheck(a, r, g, b), *dest); | 
|  | 194         } else { | 
|  | 195             *dest = SkPackARGB32NoCheck(a, r, g, b); | 
|  | 196         } | 
|  | 197     } | 
|  | 198 | 
|  | 199     inline void overRGBARaw(PixelData* dest, unsigned r, unsigned g, unsigned b,
      unsigned a) | 
|  | 200     { | 
|  | 201         if (!a) | 
|  | 202             return; | 
|  | 203 | 
|  | 204         unsigned aDest = SkGetPackedA32(*dest); | 
|  | 205         if (aDest && a < 255) { | 
|  | 206             unsigned u = a * 255; | 
|  | 207             unsigned v = (255 - a) * aDest; | 
|  | 208             unsigned alpha = u + v; | 
|  | 209             unsigned rDest = SkGetPackedR32(*dest); | 
|  | 210             unsigned gDest = SkGetPackedG32(*dest); | 
|  | 211             unsigned bDest = SkGetPackedB32(*dest); | 
|  | 212             a = (alpha + (alpha >> 8) + 1) >> 8; | 
|  | 213             r = (r * u + rDest * v) / alpha; | 
|  | 214             g = (g * u + gDest * v) / alpha; | 
|  | 215             b = (b * u + bDest * v) / alpha; | 
|  | 216         } | 
|  | 217         *dest = SkPackARGB32NoCheck(a, r, g, b); | 
|  | 218     } | 
|  | 219 | 
| 181     // Notifies the SkBitmap if any pixels changed and resets the flag. | 220     // Notifies the SkBitmap if any pixels changed and resets the flag. | 
| 182     inline void notifyBitmapIfPixelsChanged() | 221     inline void notifyBitmapIfPixelsChanged() | 
| 183     { | 222     { | 
| 184         if (m_pixelsChanged) | 223         if (m_pixelsChanged) | 
| 185             m_bitmap.notifyPixelsChanged(); | 224             m_bitmap.notifyPixelsChanged(); | 
| 186         m_pixelsChanged = false; | 225         m_pixelsChanged = false; | 
| 187     } | 226     } | 
| 188 | 227 | 
| 189 private: | 228 private: | 
| 190     int width() const | 229     int width() const | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 214     // The frame that must be decoded before this frame can be decoded. | 253     // The frame that must be decoded before this frame can be decoded. | 
| 215     // WTF::kNotFound if this frame doesn't require any previous frame. | 254     // WTF::kNotFound if this frame doesn't require any previous frame. | 
| 216     // This is used by ImageDecoder::clearCacheExceptFrame(), and will never | 255     // This is used by ImageDecoder::clearCacheExceptFrame(), and will never | 
| 217     // be read for image formats that do not have multiple frames. | 256     // be read for image formats that do not have multiple frames. | 
| 218     size_t m_requiredPreviousFrameIndex; | 257     size_t m_requiredPreviousFrameIndex; | 
| 219 }; | 258 }; | 
| 220 | 259 | 
| 221 } // namespace blink | 260 } // namespace blink | 
| 222 | 261 | 
| 223 #endif | 262 #endif | 
| OLD | NEW | 
|---|