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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 */ | 289 */ |
290 static inline bool SkIsU16(long x) { | 290 static inline bool SkIsU16(long x) { |
291 return (uint16_t)x == x; | 291 return (uint16_t)x == x; |
292 } | 292 } |
293 | 293 |
294 ////////////////////////////////////////////////////////////////////////////// | 294 ////////////////////////////////////////////////////////////////////////////// |
295 #ifndef SK_OFFSETOF | 295 #ifndef SK_OFFSETOF |
296 #define SK_OFFSETOF(type, field) (size_t)((char*)&(((type*)1)->field) - (
char*)1) | 296 #define SK_OFFSETOF(type, field) (size_t)((char*)&(((type*)1)->field) - (
char*)1) |
297 #endif | 297 #endif |
298 | 298 |
299 /** Returns the number of entries in an array (not a pointer) | 299 /** Returns the number of entries in an array (not a pointer) */ |
300 */ | 300 template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N]; |
301 #define SK_ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0])) | 301 #define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array))) |
302 | 302 |
303 #define SkAlign2(x) (((x) + 1) >> 1 << 1) | 303 #define SkAlign2(x) (((x) + 1) >> 1 << 1) |
304 #define SkIsAlign2(x) (0 == ((x) & 1)) | 304 #define SkIsAlign2(x) (0 == ((x) & 1)) |
305 | 305 |
306 #define SkAlign4(x) (((x) + 3) >> 2 << 2) | 306 #define SkAlign4(x) (((x) + 3) >> 2 << 2) |
307 #define SkIsAlign4(x) (0 == ((x) & 3)) | 307 #define SkIsAlign4(x) (0 == ((x) & 3)) |
308 | 308 |
309 #define SkAlign8(x) (((x) + 7) >> 3 << 3) | 309 #define SkAlign8(x) (((x) + 7) >> 3 << 3) |
310 #define SkIsAlign8(x) (0 == ((x) & 7)) | 310 #define SkIsAlign8(x) (0 == ((x) & 7)) |
311 | 311 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 private: | 675 private: |
676 void* fPtr; | 676 void* fPtr; |
677 size_t fSize; // can be larger than the requested size (see kReuse) | 677 size_t fSize; // can be larger than the requested size (see kReuse) |
678 uint32_t fStorage[(kSize + 3) >> 2]; | 678 uint32_t fStorage[(kSize + 3) >> 2]; |
679 }; | 679 }; |
680 // Can't guard the constructor because it's a template class. | 680 // Can't guard the constructor because it's a template class. |
681 | 681 |
682 #endif /* C++ */ | 682 #endif /* C++ */ |
683 | 683 |
684 #endif | 684 #endif |
OLD | NEW |