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 SkEndian_DEFINED | 8 #ifndef SkEndian_DEFINED |
9 #define SkEndian_DEFINED | 9 #define SkEndian_DEFINED |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 while (--count >= 0) { | 44 while (--count >= 0) { |
45 *array = SkEndianSwap16(*array); | 45 *array = SkEndianSwap16(*array); |
46 array += 1; | 46 array += 1; |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 /** Reverse all 4 bytes in a 32bit value. | 50 /** Reverse all 4 bytes in a 32bit value. |
51 e.g. 0x12345678 -> 0x78563412 | 51 e.g. 0x12345678 -> 0x78563412 |
52 */ | 52 */ |
53 static inline uint32_t SkEndianSwap32(uint32_t value) { | 53 static constexpr uint32_t SkEndianSwap32(uint32_t value) { |
54 return ((value & 0xFF) << 24) | | 54 return ((value & 0xFF) << 24) | |
55 ((value & 0xFF00) << 8) | | 55 ((value & 0xFF00) << 8) | |
56 ((value & 0xFF0000) >> 8) | | 56 ((value & 0xFF0000) >> 8) | |
57 (value >> 24); | 57 (value >> 24); |
58 } | 58 } |
59 | 59 |
60 template<uint32_t N> struct SkTEndianSwap32 { | 60 template<uint32_t N> struct SkTEndianSwap32 { |
61 static const uint32_t value = ((N & 0xFF) << 24) | | 61 static const uint32_t value = ((N & 0xFF) << 24) | |
62 ((N & 0xFF00) << 8) | | 62 ((N & 0xFF00) << 8) | |
63 ((N & 0xFF0000) >> 8) | | 63 ((N & 0xFF0000) >> 8) | |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 SK_OT_BYTE f6 : 1; \ | 185 SK_OT_BYTE f6 : 1; \ |
186 SK_OT_BYTE f5 : 1; \ | 186 SK_OT_BYTE f5 : 1; \ |
187 SK_OT_BYTE f4 : 1; \ | 187 SK_OT_BYTE f4 : 1; \ |
188 SK_OT_BYTE f3 : 1; \ | 188 SK_OT_BYTE f3 : 1; \ |
189 SK_OT_BYTE f2 : 1; \ | 189 SK_OT_BYTE f2 : 1; \ |
190 SK_OT_BYTE f1 : 1; \ | 190 SK_OT_BYTE f1 : 1; \ |
191 SK_OT_BYTE f0 : 1; | 191 SK_OT_BYTE f0 : 1; |
192 #endif | 192 #endif |
193 | 193 |
194 #endif | 194 #endif |
OLD | NEW |