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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 static inline bool SkIsS16(long x) { | 299 static inline bool SkIsS16(long x) { |
300 return (int16_t)x == x; | 300 return (int16_t)x == x; |
301 } | 301 } |
302 | 302 |
303 /** Returns true if the value can be represented with unsigned 16bits | 303 /** Returns true if the value can be represented with unsigned 16bits |
304 */ | 304 */ |
305 static inline bool SkIsU16(long x) { | 305 static inline bool SkIsU16(long x) { |
306 return (uint16_t)x == x; | 306 return (uint16_t)x == x; |
307 } | 307 } |
308 | 308 |
| 309 static inline int32_t SkLeftShift(int32_t value, int32_t shift) { |
| 310 return (int32_t) ((uint32_t) value << shift); |
| 311 } |
| 312 |
| 313 static inline int64_t SkLeftShift(int64_t value, int32_t shift) { |
| 314 return (int64_t) ((uint64_t) value << shift); |
| 315 } |
| 316 |
309 ////////////////////////////////////////////////////////////////////////////// | 317 ////////////////////////////////////////////////////////////////////////////// |
310 | 318 |
311 /** Returns the number of entries in an array (not a pointer) */ | 319 /** Returns the number of entries in an array (not a pointer) */ |
312 template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N]; | 320 template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N]; |
313 #define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array))) | 321 #define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array))) |
314 | 322 |
315 // Can be used to bracket data types that must be dense, e.g. hash keys. | 323 // Can be used to bracket data types that must be dense, e.g. hash keys. |
316 #if defined(__clang__) // This should work on GCC too, but GCC diagnostic pop d
idn't seem to work! | 324 #if defined(__clang__) // This should work on GCC too, but GCC diagnostic pop d
idn't seem to work! |
317 #define SK_BEGIN_REQUIRE_DENSE _Pragma("GCC diagnostic push") \ | 325 #define SK_BEGIN_REQUIRE_DENSE _Pragma("GCC diagnostic push") \ |
318 _Pragma("GCC diagnostic error \"-Wpadded\"") | 326 _Pragma("GCC diagnostic error \"-Wpadded\"") |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 private: | 701 private: |
694 void* fPtr; | 702 void* fPtr; |
695 size_t fSize; // can be larger than the requested size (see kReuse) | 703 size_t fSize; // can be larger than the requested size (see kReuse) |
696 uint32_t fStorage[(kSize + 3) >> 2]; | 704 uint32_t fStorage[(kSize + 3) >> 2]; |
697 }; | 705 }; |
698 // Can't guard the constructor because it's a template class. | 706 // Can't guard the constructor because it's a template class. |
699 | 707 |
700 #endif /* C++ */ | 708 #endif /* C++ */ |
701 | 709 |
702 #endif | 710 #endif |
OLD | NEW |