| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return (int16_t)x == x; | 278 return (int16_t)x == x; |
| 279 } | 279 } |
| 280 | 280 |
| 281 /** Returns true if the value can be represented with unsigned 16bits | 281 /** Returns true if the value can be represented with unsigned 16bits |
| 282 */ | 282 */ |
| 283 static inline bool SkIsU16(long x) { | 283 static inline bool SkIsU16(long x) { |
| 284 return (uint16_t)x == x; | 284 return (uint16_t)x == x; |
| 285 } | 285 } |
| 286 | 286 |
| 287 ////////////////////////////////////////////////////////////////////////////// | 287 ////////////////////////////////////////////////////////////////////////////// |
| 288 #ifndef SK_OFFSETOF | |
| 289 #define SK_OFFSETOF(type, field) (size_t)((char*)&(((type*)1)->field) - (
char*)1) | |
| 290 #endif | |
| 291 | 288 |
| 292 /** Returns the number of entries in an array (not a pointer) */ | 289 /** Returns the number of entries in an array (not a pointer) */ |
| 293 template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N]; | 290 template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N]; |
| 294 #define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array))) | 291 #define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array))) |
| 295 | 292 |
| 296 #define SkAlign2(x) (((x) + 1) >> 1 << 1) | 293 #define SkAlign2(x) (((x) + 1) >> 1 << 1) |
| 297 #define SkIsAlign2(x) (0 == ((x) & 1)) | 294 #define SkIsAlign2(x) (0 == ((x) & 1)) |
| 298 | 295 |
| 299 #define SkAlign4(x) (((x) + 3) >> 2 << 2) | 296 #define SkAlign4(x) (((x) + 3) >> 2 << 2) |
| 300 #define SkIsAlign4(x) (0 == ((x) & 3)) | 297 #define SkIsAlign4(x) (0 == ((x) & 3)) |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 private: | 665 private: |
| 669 void* fPtr; | 666 void* fPtr; |
| 670 size_t fSize; // can be larger than the requested size (see kReuse) | 667 size_t fSize; // can be larger than the requested size (see kReuse) |
| 671 uint32_t fStorage[(kSize + 3) >> 2]; | 668 uint32_t fStorage[(kSize + 3) >> 2]; |
| 672 }; | 669 }; |
| 673 // Can't guard the constructor because it's a template class. | 670 // Can't guard the constructor because it's a template class. |
| 674 | 671 |
| 675 #endif /* C++ */ | 672 #endif /* C++ */ |
| 676 | 673 |
| 677 #endif | 674 #endif |
| OLD | NEW |