OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkMathPriv_DEFINED | 8 #ifndef SkMathPriv_DEFINED |
9 #define SkMathPriv_DEFINED | 9 #define SkMathPriv_DEFINED |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 return (prod + (prod >> 8)) >> 8; | 71 return (prod + (prod >> 8)) >> 8; |
72 } | 72 } |
73 | 73 |
74 /** Just the rounding step in SkDiv255Round: round(value / 255) | 74 /** Just the rounding step in SkDiv255Round: round(value / 255) |
75 */ | 75 */ |
76 static inline unsigned SkDiv255Round(unsigned prod) { | 76 static inline unsigned SkDiv255Round(unsigned prod) { |
77 prod += 128; | 77 prod += 128; |
78 return (prod + (prod >> 8)) >> 8; | 78 return (prod + (prod >> 8)) >> 8; |
79 } | 79 } |
80 | 80 |
81 static inline float SkPinToUnitFloat(float x) { | |
82 return SkTMin(SkTMax(x, 0.0f), 1.0f); | |
83 } | |
84 | |
85 #endif | 81 #endif |
OLD | NEW |