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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 static inline bool SkIsU16(long x) { | 280 static inline bool SkIsU16(long x) { |
281 return (uint16_t)x == x; | 281 return (uint16_t)x == x; |
282 } | 282 } |
283 | 283 |
284 ////////////////////////////////////////////////////////////////////////////// | 284 ////////////////////////////////////////////////////////////////////////////// |
285 | 285 |
286 /** Returns the number of entries in an array (not a pointer) */ | 286 /** Returns the number of entries in an array (not a pointer) */ |
287 template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N]; | 287 template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N]; |
288 #define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array))) | 288 #define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array))) |
289 | 289 |
| 290 // Can be used to bracket data types that must be dense, e.g. hash keys. |
| 291 #if defined(__clang__) // This should work on GCC too, but GCC diagnostic pop d
idn't seem to work! |
| 292 #define SK_BEGIN_REQUIRE_DENSE _Pragma("GCC diagnostic push") \ |
| 293 _Pragma("GCC diagnostic error \"-Wpadded\"") |
| 294 #define SK_END_REQUIRE_DENSE _Pragma("GCC diagnostic pop") |
| 295 #else |
| 296 #define SK_BEGIN_REQUIRE_DENSE |
| 297 #define SK_END_REQUIRE_DENSE |
| 298 #endif |
| 299 |
290 #define SkAlign2(x) (((x) + 1) >> 1 << 1) | 300 #define SkAlign2(x) (((x) + 1) >> 1 << 1) |
291 #define SkIsAlign2(x) (0 == ((x) & 1)) | 301 #define SkIsAlign2(x) (0 == ((x) & 1)) |
292 | 302 |
293 #define SkAlign4(x) (((x) + 3) >> 2 << 2) | 303 #define SkAlign4(x) (((x) + 3) >> 2 << 2) |
294 #define SkIsAlign4(x) (0 == ((x) & 3)) | 304 #define SkIsAlign4(x) (0 == ((x) & 3)) |
295 | 305 |
296 #define SkAlign8(x) (((x) + 7) >> 3 << 3) | 306 #define SkAlign8(x) (((x) + 7) >> 3 << 3) |
297 #define SkIsAlign8(x) (0 == ((x) & 7)) | 307 #define SkIsAlign8(x) (0 == ((x) & 7)) |
298 | 308 |
299 #define SkAlignPtr(x) (sizeof(void*) == 8 ? SkAlign8(x) : SkAlign4(x)) | 309 #define SkAlignPtr(x) (sizeof(void*) == 8 ? SkAlign8(x) : SkAlign4(x)) |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 private: | 668 private: |
659 void* fPtr; | 669 void* fPtr; |
660 size_t fSize; // can be larger than the requested size (see kReuse) | 670 size_t fSize; // can be larger than the requested size (see kReuse) |
661 uint32_t fStorage[(kSize + 3) >> 2]; | 671 uint32_t fStorage[(kSize + 3) >> 2]; |
662 }; | 672 }; |
663 // Can't guard the constructor because it's a template class. | 673 // Can't guard the constructor because it's a template class. |
664 | 674 |
665 #endif /* C++ */ | 675 #endif /* C++ */ |
666 | 676 |
667 #endif | 677 #endif |
OLD | NEW |