| 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 SkTypes_DEFINED | 8 #ifndef SkTypes_DEFINED |
| 9 #define SkTypes_DEFINED | 9 #define SkTypes_DEFINED |
| 10 | 10 |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 return (a >> 31) | ((unsigned) -a >> 31); | 393 return (a >> 31) | ((unsigned) -a >> 31); |
| 394 } | 394 } |
| 395 | 395 |
| 396 static inline int32_t SkFastMin32(int32_t value, int32_t max) { | 396 static inline int32_t SkFastMin32(int32_t value, int32_t max) { |
| 397 if (value > max) { | 397 if (value > max) { |
| 398 value = max; | 398 value = max; |
| 399 } | 399 } |
| 400 return value; | 400 return value; |
| 401 } | 401 } |
| 402 | 402 |
| 403 /** Returns signed 32 bit value pinned between min and max, inclusively | 403 template <typename T> static inline const T& SkTPin(const T& x, const T& min, co
nst T& max) { |
| 404 */ | 404 return SkTMax(SkTMin(x, max), min); |
| 405 } |
| 406 |
| 407 /** Returns signed 32 bit value pinned between min and max, inclusively. */ |
| 405 static inline int32_t SkPin32(int32_t value, int32_t min, int32_t max) { | 408 static inline int32_t SkPin32(int32_t value, int32_t min, int32_t max) { |
| 406 if (value < min) { | 409 return SkTPin(value, min, max); |
| 407 value = min; | |
| 408 } | |
| 409 if (value > max) { | |
| 410 value = max; | |
| 411 } | |
| 412 return value; | |
| 413 } | 410 } |
| 414 | 411 |
| 415 static inline uint32_t SkSetClearShift(uint32_t bits, bool cond, | 412 static inline uint32_t SkSetClearShift(uint32_t bits, bool cond, |
| 416 unsigned shift) { | 413 unsigned shift) { |
| 417 SkASSERT((int)cond == 0 || (int)cond == 1); | 414 SkASSERT((int)cond == 0 || (int)cond == 1); |
| 418 return (bits & ~(1 << shift)) | ((int)cond << shift); | 415 return (bits & ~(1 << shift)) | ((int)cond << shift); |
| 419 } | 416 } |
| 420 | 417 |
| 421 static inline uint32_t SkSetClearMask(uint32_t bits, bool cond, | 418 static inline uint32_t SkSetClearMask(uint32_t bits, bool cond, |
| 422 uint32_t mask) { | 419 uint32_t mask) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 private: | 669 private: |
| 673 void* fPtr; | 670 void* fPtr; |
| 674 size_t fSize; // can be larger than the requested size (see kReuse) | 671 size_t fSize; // can be larger than the requested size (see kReuse) |
| 675 uint32_t fStorage[(kSize + 3) >> 2]; | 672 uint32_t fStorage[(kSize + 3) >> 2]; |
| 676 }; | 673 }; |
| 677 // Can't guard the constructor because it's a template class. | 674 // Can't guard the constructor because it's a template class. |
| 678 | 675 |
| 679 #endif /* C++ */ | 676 #endif /* C++ */ |
| 680 | 677 |
| 681 #endif | 678 #endif |
| OLD | NEW |