| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 SkScalar_DEFINED | 8 #ifndef SkScalar_DEFINED |
| 9 #define SkScalar_DEFINED | 9 #define SkScalar_DEFINED |
| 10 | 10 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 * SkASSERT(0 == ix); // <--- fails | 161 * SkASSERT(0 == ix); // <--- fails |
| 162 * ix = SkDScalarRoundToInt(x); | 162 * ix = SkDScalarRoundToInt(x); |
| 163 * SkASSERT(0 == ix); // <--- succeeds | 163 * SkASSERT(0 == ix); // <--- succeeds |
| 164 */ | 164 */ |
| 165 static inline int SkDScalarRoundToInt(SkScalar x) { | 165 static inline int SkDScalarRoundToInt(SkScalar x) { |
| 166 double xx = x; | 166 double xx = x; |
| 167 xx += 0.5; | 167 xx += 0.5; |
| 168 return (int)floor(xx); | 168 return (int)floor(xx); |
| 169 } | 169 } |
| 170 | 170 |
| 171 /** |
| 172 * Variant of SkScalarRoundToInt, identical to SkDScalarRoundToInt except when
the input fraction |
| 173 * is 0.5. In this case only, round the value down. This is used to round the t
op and left |
| 174 * of a rectangle, and corresponds to the way the scan converter treats the top
and left edges. |
| 175 */ |
| 176 static inline int SkDScalarRoundDownToInt(SkScalar x) { |
| 177 double xx = x; |
| 178 xx += 0.5; |
| 179 double floorXX = floor(xx); |
| 180 return (int)floorXX - (xx == floorXX); |
| 181 } |
| 182 |
| 171 static inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) { | 183 static inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) { |
| 172 x = SkTMin(x, max); | 184 x = SkTMin(x, max); |
| 173 x = SkTMax<SkScalar>(x, 0); | 185 x = SkTMax<SkScalar>(x, 0); |
| 174 return x; | 186 return x; |
| 175 } | 187 } |
| 176 | 188 |
| 177 static inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) { | 189 static inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) { |
| 178 return SkTPin(x, min, max); | 190 return SkTPin(x, min, max); |
| 179 } | 191 } |
| 180 | 192 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 SkASSERT(n >= 0); | 272 SkASSERT(n >= 0); |
| 261 for (int i = 0; i < n; ++i) { | 273 for (int i = 0; i < n; ++i) { |
| 262 if (a[i] != b[i]) { | 274 if (a[i] != b[i]) { |
| 263 return false; | 275 return false; |
| 264 } | 276 } |
| 265 } | 277 } |
| 266 return true; | 278 return true; |
| 267 } | 279 } |
| 268 | 280 |
| 269 #endif | 281 #endif |
| OLD | NEW |