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 #include "SkUtils.h" | 10 #include "SkUtils.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 do { \ | 27 do { \ |
28 *(dst)++ = value; *(dst)++ = value; \ | 28 *(dst)++ = value; *(dst)++ = value; \ |
29 *(dst)++ = value; *(dst)++ = value; \ | 29 *(dst)++ = value; *(dst)++ = value; \ |
30 *(dst)++ = value; *(dst)++ = value; \ | 30 *(dst)++ = value; *(dst)++ = value; \ |
31 *(dst)++ = value; *(dst)++ = value; \ | 31 *(dst)++ = value; *(dst)++ = value; \ |
32 *(dst)++ = value; *(dst)++ = value; \ | 32 *(dst)++ = value; *(dst)++ = value; \ |
33 *(dst)++ = value; *(dst)++ = value; \ | 33 *(dst)++ = value; *(dst)++ = value; \ |
34 *(dst)++ = value; *(dst)++ = value; \ | 34 *(dst)++ = value; *(dst)++ = value; \ |
35 *(dst)++ = value; *(dst)++ = value; \ | 35 *(dst)++ = value; *(dst)++ = value; \ |
36 } while (0) | 36 } while (0) |
37 | |
38 #define copy_16_longs(dst, src) \ | |
39 do { \ | |
40 *(dst)++ = *(src)++; *(dst)++ = *(src)++; \ | |
41 *(dst)++ = *(src)++; *(dst)++ = *(src)++; \ | |
42 *(dst)++ = *(src)++; *(dst)++ = *(src)++; \ | |
43 *(dst)++ = *(src)++; *(dst)++ = *(src)++; \ | |
44 *(dst)++ = *(src)++; *(dst)++ = *(src)++; \ | |
45 *(dst)++ = *(src)++; *(dst)++ = *(src)++; \ | |
46 *(dst)++ = *(src)++; *(dst)++ = *(src)++; \ | |
47 *(dst)++ = *(src)++; *(dst)++ = *(src)++; \ | |
48 } while (0) | |
49 #endif | 37 #endif |
50 | 38 |
51 /////////////////////////////////////////////////////////////////////////////// | 39 /////////////////////////////////////////////////////////////////////////////// |
52 | 40 |
53 static void sk_memset16_portable(uint16_t dst[], uint16_t value, int count) { | 41 static void sk_memset16_portable(uint16_t dst[], uint16_t value, int count) { |
54 SkASSERT(dst != NULL && count >= 0); | 42 SkASSERT(dst != NULL && count >= 0); |
55 | 43 |
56 if (count <= 0) { | 44 if (count <= 0) { |
57 return; | 45 return; |
58 } | 46 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 103 } |
116 | 104 |
117 if (count) { | 105 if (count) { |
118 do { | 106 do { |
119 *dst++ = value; | 107 *dst++ = value; |
120 } while (--count != 0); | 108 } while (--count != 0); |
121 } | 109 } |
122 } | 110 } |
123 | 111 |
124 static void sk_memcpy32_portable(uint32_t dst[], const uint32_t src[], int count
) { | 112 static void sk_memcpy32_portable(uint32_t dst[], const uint32_t src[], int count
) { |
125 SkASSERT(dst != NULL && count >= 0); | 113 memcpy(dst, src, count * sizeof(uint32_t)); |
126 | |
127 int sixteenlongs = count >> 4; | |
128 if (sixteenlongs) { | |
129 do { | |
130 copy_16_longs(dst, src); | |
131 } while (--sixteenlongs != 0); | |
132 count &= 15; | |
133 } | |
134 | |
135 if (count) { | |
136 do { | |
137 *dst++ = *src++; | |
138 } while (--count != 0); | |
139 } | |
140 } | 114 } |
141 | 115 |
142 static void choose_memset16(SkMemset16Proc* proc) { | 116 static void choose_memset16(SkMemset16Proc* proc) { |
143 *proc = SkMemset16GetPlatformProc(); | 117 *proc = SkMemset16GetPlatformProc(); |
144 if (NULL == *proc) { | 118 if (NULL == *proc) { |
145 *proc = &sk_memset16_portable; | 119 *proc = &sk_memset16_portable; |
146 } | 120 } |
147 } | 121 } |
148 | 122 |
149 void sk_memset16(uint16_t dst[], uint16_t value, int count) { | 123 void sk_memset16(uint16_t dst[], uint16_t value, int count) { |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 } | 425 } |
452 } else { | 426 } else { |
453 char* start = utf8; | 427 char* start = utf8; |
454 while (utf16 < stop) { | 428 while (utf16 < stop) { |
455 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8); | 429 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8); |
456 } | 430 } |
457 size = utf8 - start; | 431 size = utf8 - start; |
458 } | 432 } |
459 return size; | 433 return size; |
460 } | 434 } |
OLD | NEW |