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 SkTypes_DEFINED | 10 #ifndef SkTypes_DEFINED |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 a = b; | 307 a = b; |
308 return a; | 308 return a; |
309 } | 309 } |
310 | 310 |
311 static inline int32_t SkMin32(int32_t a, int32_t b) { | 311 static inline int32_t SkMin32(int32_t a, int32_t b) { |
312 if (a > b) | 312 if (a > b) |
313 a = b; | 313 a = b; |
314 return a; | 314 return a; |
315 } | 315 } |
316 | 316 |
| 317 template <typename T> const T& SkTMin(const T& a, const T& b) { |
| 318 return (a < b) ? a : b; |
| 319 } |
| 320 |
| 321 template <typename T> const T& SkTMax(const T& a, const T& b) { |
| 322 return (b < a) ? a : b; |
| 323 } |
| 324 |
317 static inline int32_t SkSign32(int32_t a) { | 325 static inline int32_t SkSign32(int32_t a) { |
318 return (a >> 31) | ((unsigned) -a >> 31); | 326 return (a >> 31) | ((unsigned) -a >> 31); |
319 } | 327 } |
320 | 328 |
321 static inline int32_t SkFastMin32(int32_t value, int32_t max) { | 329 static inline int32_t SkFastMin32(int32_t value, int32_t max) { |
322 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR | 330 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR |
323 if (value > max) | 331 if (value > max) |
324 value = max; | 332 value = max; |
325 return value; | 333 return value; |
326 #else | 334 #else |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 599 |
592 private: | 600 private: |
593 void* fPtr; | 601 void* fPtr; |
594 size_t fSize; // can be larger than the requested size (see kReuse) | 602 size_t fSize; // can be larger than the requested size (see kReuse) |
595 uint32_t fStorage[(kSize + 3) >> 2]; | 603 uint32_t fStorage[(kSize + 3) >> 2]; |
596 }; | 604 }; |
597 | 605 |
598 #endif /* C++ */ | 606 #endif /* C++ */ |
599 | 607 |
600 #endif | 608 #endif |
OLD | NEW |