OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkEndian_DEFINED | 10 #ifndef SkEndian_DEFINED |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #error "can't have both LENDIAN and BENDIAN defined" | 22 #error "can't have both LENDIAN and BENDIAN defined" |
23 #endif | 23 #endif |
24 | 24 |
25 #if !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN) | 25 #if !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN) |
26 #error "need either LENDIAN or BENDIAN defined" | 26 #error "need either LENDIAN or BENDIAN defined" |
27 #endif | 27 #endif |
28 | 28 |
29 /** Swap the two bytes in the low 16bits of the parameters. | 29 /** Swap the two bytes in the low 16bits of the parameters. |
30 e.g. 0x1234 -> 0x3412 | 30 e.g. 0x1234 -> 0x3412 |
31 */ | 31 */ |
32 static inline uint16_t SkEndianSwap16(U16CPU value) { | 32 static inline uint16_t SkEndianSwap16(uint16_t value) { |
33 SkASSERT(value == (uint16_t)value); | |
34 return static_cast<uint16_t>((value >> 8) | (value << 8)); | 33 return static_cast<uint16_t>((value >> 8) | (value << 8)); |
35 } | 34 } |
36 template<uint16_t N> struct SkTEndianSwap16 { | 35 template<uint16_t N> struct SkTEndianSwap16 { |
37 static const uint16_t value = static_cast<uint16_t>((N >> 8) | ((N & 0xFF) < < 8)); | 36 static const uint16_t value = static_cast<uint16_t>((N >> 8) | ((N & 0xFF) < < 8)); |
38 }; | 37 }; |
39 | 38 |
40 /** Vector version of SkEndianSwap16(), which swaps the | 39 /** Vector version of SkEndianSwap16(), which swaps the |
41 low two bytes of each value in the array. | 40 low two bytes of each value in the array. |
42 */ | 41 */ |
43 static inline void SkEndianSwap16s(uint16_t array[], int count) { | 42 static inline void SkEndianSwap16s(uint16_t array[], int count) { |
44 SkASSERT(count == 0 || array != NULL); | 43 SkASSERT(count == 0 || array != NULL); |
45 | 44 |
46 while (--count >= 0) { | 45 while (--count >= 0) { |
47 *array = SkEndianSwap16(*array); | 46 *array = SkEndianSwap16(*array); |
48 array += 1; | 47 array += 1; |
49 } | 48 } |
50 } | 49 } |
51 | 50 |
52 /** Reverse all 4 bytes in a 32bit value. | 51 /** Reverse all 4 bytes in a 32bit value. |
53 e.g. 0x12345678 -> 0x78563412 | 52 e.g. 0x12345678 -> 0x78563412 |
54 */ | 53 */ |
55 static inline uint32_t SkEndianSwap32(uint32_t value) { | 54 static inline uint32_t SkEndianSwap32(uint32_t v) { |
bungeman-skia
2014/04/23 14:15:13
Any reason to change this from 'value'?
reed1
2014/04/23 14:27:37
historical from previous patches. will revert.
| |
56 return ((value & 0xFF) << 24) | | 55 return ((v & 0xFF) << 24) | |
57 ((value & 0xFF00) << 8) | | 56 ((v & 0xFF00) << 8) | |
58 ((value & 0xFF0000) >> 8) | | 57 ((v & 0xFF0000) >> 8) | |
59 (value >> 24); | 58 (v >> 24); |
60 } | 59 } |
61 template<uint32_t N> struct SkTEndianSwap32 { | 60 template<uint32_t N> struct SkTEndianSwap32 { |
62 static const uint32_t value = ((N & 0xFF) << 24) | | 61 static const uint32_t value = ((N & 0xFF) << 24) | |
63 ((N & 0xFF00) << 8) | | 62 ((N & 0xFF00) << 8) | |
64 ((N & 0xFF0000) >> 8) | | 63 ((N & 0xFF0000) >> 8) | |
65 (N >> 24); | 64 (N >> 24); |
66 }; | 65 }; |
67 | 66 |
68 /** Vector version of SkEndianSwap32(), which swaps the | 67 /** Vector version of SkEndianSwap32(), which swaps the |
69 bytes of each value in the array. | 68 bytes of each value in the array. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 SK_OT_BYTE f6 : 1; \ | 185 SK_OT_BYTE f6 : 1; \ |
187 SK_OT_BYTE f5 : 1; \ | 186 SK_OT_BYTE f5 : 1; \ |
188 SK_OT_BYTE f4 : 1; \ | 187 SK_OT_BYTE f4 : 1; \ |
189 SK_OT_BYTE f3 : 1; \ | 188 SK_OT_BYTE f3 : 1; \ |
190 SK_OT_BYTE f2 : 1; \ | 189 SK_OT_BYTE f2 : 1; \ |
191 SK_OT_BYTE f1 : 1; \ | 190 SK_OT_BYTE f1 : 1; \ |
192 SK_OT_BYTE f0 : 1; | 191 SK_OT_BYTE f0 : 1; |
193 #endif | 192 #endif |
194 | 193 |
195 #endif | 194 #endif |
OLD | NEW |