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 #ifndef SkScalar_DEFINED | 10 #ifndef SkScalar_DEFINED |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 */ | 125 */ |
126 #define SkScalarFraction(x) sk_float_mod(x, 1.0f) | 126 #define SkScalarFraction(x) sk_float_mod(x, 1.0f) |
127 | 127 |
128 #define SkScalarFloorToScalar(x) sk_float_floor(x) | 128 #define SkScalarFloorToScalar(x) sk_float_floor(x) |
129 #define SkScalarCeilToScalar(x) sk_float_ceil(x) | 129 #define SkScalarCeilToScalar(x) sk_float_ceil(x) |
130 #define SkScalarRoundToScalar(x) sk_float_floor((x) + 0.5f) | 130 #define SkScalarRoundToScalar(x) sk_float_floor((x) + 0.5f) |
131 | 131 |
132 #define SkScalarFloorToInt(x) sk_float_floor2int(x) | 132 #define SkScalarFloorToInt(x) sk_float_floor2int(x) |
133 #define SkScalarCeilToInt(x) sk_float_ceil2int(x) | 133 #define SkScalarCeilToInt(x) sk_float_ceil2int(x) |
134 #define SkScalarRoundToInt(x) sk_float_round2int(x) | 134 #define SkScalarRoundToInt(x) sk_float_round2int(x) |
| 135 #define SkScalarTruncToInt(x) static_cast<int>(x) |
135 | 136 |
136 /** Returns the absolute value of the specified SkScalar | 137 /** Returns the absolute value of the specified SkScalar |
137 */ | 138 */ |
138 #define SkScalarAbs(x) sk_float_abs(x) | 139 #define SkScalarAbs(x) sk_float_abs(x) |
139 /** Return x with the sign of y | 140 /** Return x with the sign of y |
140 */ | 141 */ |
141 #define SkScalarCopySign(x, y) sk_float_copysign(x, y) | 142 #define SkScalarCopySign(x, y) sk_float_copysign(x, y) |
142 /** Returns the value pinned between 0 and max inclusive | 143 /** Returns the value pinned between 0 and max inclusive |
143 */ | 144 */ |
144 inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) { | 145 inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 #define SkDoubleToScalar(n) SkDoubleToFixed(n) | 242 #define SkDoubleToScalar(n) SkDoubleToFixed(n) |
242 #define SkScalarFraction(x) SkFixedFraction(x) | 243 #define SkScalarFraction(x) SkFixedFraction(x) |
243 | 244 |
244 #define SkScalarFloorToScalar(x) SkFixedFloorToFixed(x) | 245 #define SkScalarFloorToScalar(x) SkFixedFloorToFixed(x) |
245 #define SkScalarCeilToScalar(x) SkFixedCeilToFixed(x) | 246 #define SkScalarCeilToScalar(x) SkFixedCeilToFixed(x) |
246 #define SkScalarRoundToScalar(x) SkFixedRoundToFixed(x) | 247 #define SkScalarRoundToScalar(x) SkFixedRoundToFixed(x) |
247 | 248 |
248 #define SkScalarFloorToInt(x) SkFixedFloorToInt(x) | 249 #define SkScalarFloorToInt(x) SkFixedFloorToInt(x) |
249 #define SkScalarCeilToInt(x) SkFixedCeilToInt(x) | 250 #define SkScalarCeilToInt(x) SkFixedCeilToInt(x) |
250 #define SkScalarRoundToInt(x) SkFixedRoundToInt(x) | 251 #define SkScalarRoundToInt(x) SkFixedRoundToInt(x) |
| 252 #define SkScalarTruncToInt(x) (((x) < 0) ? SkScalarCeilToInt(x) : SkSc
alarFloorToInt(x)) |
251 | 253 |
252 #define SkScalarAbs(x) SkFixedAbs(x) | 254 #define SkScalarAbs(x) SkFixedAbs(x) |
253 #define SkScalarCopySign(x, y) SkCopySign32(x, y) | 255 #define SkScalarCopySign(x, y) SkCopySign32(x, y) |
254 #define SkScalarClampMax(x, max) SkClampMax(x, max) | 256 #define SkScalarClampMax(x, max) SkClampMax(x, max) |
255 #define SkScalarPin(x, min, max) SkPin32(x, min, max) | 257 #define SkScalarPin(x, min, max) SkPin32(x, min, max) |
256 #define SkScalarSquare(x) SkFixedSquare(x) | 258 #define SkScalarSquare(x) SkFixedSquare(x) |
257 #define SkScalarMul(a, b) SkFixedMul(a, b) | 259 #define SkScalarMul(a, b) SkFixedMul(a, b) |
258 #define SkScalarMulAdd(a, b, c) SkFixedMulAdd(a, b, c) | 260 #define SkScalarMulAdd(a, b, c) SkFixedMulAdd(a, b, c) |
259 #define SkScalarMulRound(a, b) SkFixedMulCommon(a, b, SK_FixedHalf) | 261 #define SkScalarMulRound(a, b) SkFixedMulCommon(a, b, SK_FixedHalf) |
260 #define SkScalarMulCeil(a, b) SkFixedMulCommon(a, b, SK_Fixed1 - 1) | 262 #define SkScalarMulCeil(a, b) SkFixedMulCommon(a, b, SK_Fixed1 - 1) |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 return false; | 370 return false; |
369 } | 371 } |
370 } | 372 } |
371 return true; | 373 return true; |
372 #else | 374 #else |
373 return 0 == memcmp(a, b, n * sizeof(SkScalar)); | 375 return 0 == memcmp(a, b, n * sizeof(SkScalar)); |
374 #endif | 376 #endif |
375 } | 377 } |
376 | 378 |
377 #endif | 379 #endif |
OLD | NEW |