| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 */ | 241 */ |
| 242 typedef int S16CPU; | 242 typedef int S16CPU; |
| 243 | 243 |
| 244 /** | 244 /** |
| 245 * Fast type for unsigned 16 bits. Use for parameter passing and local | 245 * Fast type for unsigned 16 bits. Use for parameter passing and local |
| 246 * variables, not for storage | 246 * variables, not for storage |
| 247 */ | 247 */ |
| 248 typedef unsigned U16CPU; | 248 typedef unsigned U16CPU; |
| 249 | 249 |
| 250 /** | 250 /** |
| 251 * Meant to be faster than bool (doesn't promise to be 0 or 1, | |
| 252 * just 0 or non-zero | |
| 253 */ | |
| 254 typedef int SkBool; | |
| 255 | |
| 256 /** | |
| 257 * Meant to be a small version of bool, for storage purposes. Will be 0 or 1 | 251 * Meant to be a small version of bool, for storage purposes. Will be 0 or 1 |
| 258 */ | 252 */ |
| 259 typedef uint8_t SkBool8; | 253 typedef uint8_t SkBool8; |
| 260 | 254 |
| 261 #ifdef SK_DEBUG | 255 #ifdef SK_DEBUG |
| 262 SK_API int8_t SkToS8(intmax_t); | 256 SK_API int8_t SkToS8(intmax_t); |
| 263 SK_API uint8_t SkToU8(uintmax_t); | 257 SK_API uint8_t SkToU8(uintmax_t); |
| 264 SK_API int16_t SkToS16(intmax_t); | 258 SK_API int16_t SkToS16(intmax_t); |
| 265 SK_API uint16_t SkToU16(uintmax_t); | 259 SK_API uint16_t SkToU16(uintmax_t); |
| 266 SK_API int32_t SkToS32(intmax_t); | 260 SK_API int32_t SkToS32(intmax_t); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 value = max; | 428 value = max; |
| 435 } | 429 } |
| 436 return value; | 430 return value; |
| 437 } | 431 } |
| 438 | 432 |
| 439 /** Returns value pinned between min and max, inclusively. */ | 433 /** Returns value pinned between min and max, inclusively. */ |
| 440 template <typename T> static inline const T& SkTPin(const T& value, const T& min
, const T& max) { | 434 template <typename T> static inline const T& SkTPin(const T& value, const T& min
, const T& max) { |
| 441 return SkTMax(SkTMin(value, max), min); | 435 return SkTMax(SkTMin(value, max), min); |
| 442 } | 436 } |
| 443 | 437 |
| 444 static inline uint32_t SkSetClearShift(uint32_t bits, bool cond, | |
| 445 unsigned shift) { | |
| 446 SkASSERT((int)cond == 0 || (int)cond == 1); | |
| 447 return (bits & ~(1 << shift)) | ((int)cond << shift); | |
| 448 } | |
| 449 | |
| 450 static inline uint32_t SkSetClearMask(uint32_t bits, bool cond, | |
| 451 uint32_t mask) { | |
| 452 return cond ? bits | mask : bits & ~mask; | |
| 453 } | |
| 454 | |
| 455 /////////////////////////////////////////////////////////////////////////////// | 438 /////////////////////////////////////////////////////////////////////////////// |
| 456 | 439 |
| 457 /** Use to combine multiple bits in a bitmask in a type safe way. | 440 /** Use to combine multiple bits in a bitmask in a type safe way. |
| 458 */ | 441 */ |
| 459 template <typename T> | 442 template <typename T> |
| 460 T SkTBitOr(T a, T b) { | 443 T SkTBitOr(T a, T b) { |
| 461 return (T)(a | b); | 444 return (T)(a | b); |
| 462 } | 445 } |
| 463 | 446 |
| 464 /** | 447 /** |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 private: | 684 private: |
| 702 void* fPtr; | 685 void* fPtr; |
| 703 size_t fSize; // can be larger than the requested size (see kReuse) | 686 size_t fSize; // can be larger than the requested size (see kReuse) |
| 704 uint32_t fStorage[(kSize + 3) >> 2]; | 687 uint32_t fStorage[(kSize + 3) >> 2]; |
| 705 }; | 688 }; |
| 706 // Can't guard the constructor because it's a template class. | 689 // Can't guard the constructor because it's a template class. |
| 707 | 690 |
| 708 #endif /* C++ */ | 691 #endif /* C++ */ |
| 709 | 692 |
| 710 #endif | 693 #endif |
| OLD | NEW |