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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 345 |
346 /** Generic swap function. Classes with efficient swaps should specialize this f
unction to take | 346 /** Generic swap function. Classes with efficient swaps should specialize this f
unction to take |
347 their fast path. This function is used by SkTSort. */ | 347 their fast path. This function is used by SkTSort. */ |
348 template <typename T> inline void SkTSwap(T& a, T& b) { | 348 template <typename T> inline void SkTSwap(T& a, T& b) { |
349 T c(a); | 349 T c(a); |
350 a = b; | 350 a = b; |
351 b = c; | 351 b = c; |
352 } | 352 } |
353 | 353 |
354 static inline int32_t SkAbs32(int32_t value) { | 354 static inline int32_t SkAbs32(int32_t value) { |
| 355 SkASSERT(value != SK_NaN32); // The most negative int32_t can't be negated. |
355 if (value < 0) { | 356 if (value < 0) { |
356 value = -value; | 357 value = -value; |
357 } | 358 } |
358 return value; | 359 return value; |
359 } | 360 } |
360 | 361 |
361 template <typename T> inline T SkTAbs(T value) { | 362 template <typename T> inline T SkTAbs(T value) { |
362 if (value < 0) { | 363 if (value < 0) { |
363 value = -value; | 364 value = -value; |
364 } | 365 } |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 private: | 669 private: |
669 void* fPtr; | 670 void* fPtr; |
670 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) |
671 uint32_t fStorage[(kSize + 3) >> 2]; | 672 uint32_t fStorage[(kSize + 3) >> 2]; |
672 }; | 673 }; |
673 // Can't guard the constructor because it's a template class. | 674 // Can't guard the constructor because it's a template class. |
674 | 675 |
675 #endif /* C++ */ | 676 #endif /* C++ */ |
676 | 677 |
677 #endif | 678 #endif |
OLD | NEW |