| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkColor.h" | 10 #include "SkColor.h" |
| 11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
| 12 | 12 |
| 13 SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { | 13 SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { |
| 14 return SkPremultiplyARGBInline(a, r, g, b); | 14 return SkPremultiplyARGBInline(a, r, g, b); |
| 15 } | 15 } |
| 16 | 16 |
| 17 SkPMColor SkPreMultiplyColor(SkColor c) { | 17 SkPMColor SkPreMultiplyColor(SkColor c) { |
| 18 return SkPremultiplyARGBInline(SkColorGetA(c), SkColorGetR(c), | 18 return SkPremultiplyARGBInline(SkColorGetA(c), SkColorGetR(c), |
| 19 SkColorGetG(c), SkColorGetB(c)); | 19 SkColorGetG(c), SkColorGetB(c)); |
| 20 } | 20 } |
| 21 | 21 |
| 22 SkPMColor SkPreMultiplyUnPMColor(SkUnPMColor c) { |
| 23 U8CPU a = SkGetPackedA32(c); |
| 24 U8CPU r = SkGetPackedR32(c); |
| 25 U8CPU g = SkGetPackedG32(c); |
| 26 U8CPU b = SkGetPackedB32(c); |
| 27 return SkPreMultiplyARGB(a, r, g, b); |
| 28 } |
| 29 |
| 22 /////////////////////////////////////////////////////////////////////////////// | 30 /////////////////////////////////////////////////////////////////////////////// |
| 23 | 31 |
| 24 static inline SkScalar ByteToScalar(U8CPU x) { | 32 static inline SkScalar ByteToScalar(U8CPU x) { |
| 25 SkASSERT(x <= 255); | 33 SkASSERT(x <= 255); |
| 26 return SkIntToScalar(x) / 255; | 34 return SkIntToScalar(x) / 255; |
| 27 } | 35 } |
| 28 | 36 |
| 29 static inline SkScalar ByteDivToScalar(int numer, U8CPU denom) { | 37 static inline SkScalar ByteDivToScalar(int numer, U8CPU denom) { |
| 30 // cast to keep the answer signed | 38 // cast to keep the answer signed |
| 31 return SkIntToScalar(numer) / (int)denom; | 39 return SkIntToScalar(numer) / (int)denom; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 switch (hx >> 16) { | 112 switch (hx >> 16) { |
| 105 case 0: r = v; g = t; b = p; break; | 113 case 0: r = v; g = t; b = p; break; |
| 106 case 1: r = q; g = v; b = p; break; | 114 case 1: r = q; g = v; b = p; break; |
| 107 case 2: r = p; g = v; b = t; break; | 115 case 2: r = p; g = v; b = t; break; |
| 108 case 3: r = p; g = q; b = v; break; | 116 case 3: r = p; g = q; b = v; break; |
| 109 case 4: r = t; g = p; b = v; break; | 117 case 4: r = t; g = p; b = v; break; |
| 110 default: r = v; g = p; b = q; break; | 118 default: r = v; g = p; b = q; break; |
| 111 } | 119 } |
| 112 return SkColorSetARGB(a, r, g, b); | 120 return SkColorSetARGB(a, r, g, b); |
| 113 } | 121 } |
| OLD | NEW |