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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 count &= 15; | 102 count &= 15; |
103 } | 103 } |
104 | 104 |
105 if (count) { | 105 if (count) { |
106 do { | 106 do { |
107 *dst++ = value; | 107 *dst++ = value; |
108 } while (--count != 0); | 108 } while (--count != 0); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 static void sk_memcpy32_portable(uint32_t dst[], const uint32_t src[], int count
) { | |
113 memcpy(dst, src, count * sizeof(uint32_t)); | |
114 } | |
115 | |
116 namespace { | 112 namespace { |
117 // These three methods technically need external linkage to be passed as templat
e parameters. | 113 // These three methods technically need external linkage to be passed as templat
e parameters. |
118 // Since they can't be static, we hide them in an anonymous namespace instead. | 114 // Since they can't be static, we hide them in an anonymous namespace instead. |
119 | 115 |
120 SkMemset16Proc choose_memset16() { | 116 SkMemset16Proc choose_memset16() { |
121 SkMemset16Proc proc = SkMemset16GetPlatformProc(); | 117 SkMemset16Proc proc = SkMemset16GetPlatformProc(); |
122 return proc ? proc : sk_memset16_portable; | 118 return proc ? proc : sk_memset16_portable; |
123 } | 119 } |
124 | 120 |
125 SkMemset32Proc choose_memset32() { | 121 SkMemset32Proc choose_memset32() { |
126 SkMemset32Proc proc = SkMemset32GetPlatformProc(); | 122 SkMemset32Proc proc = SkMemset32GetPlatformProc(); |
127 return proc ? proc : sk_memset32_portable; | 123 return proc ? proc : sk_memset32_portable; |
128 } | 124 } |
129 | 125 |
130 SkMemcpy32Proc choose_memcpy32() { | |
131 SkMemcpy32Proc proc = SkMemcpy32GetPlatformProc(); | |
132 return proc ? proc : sk_memcpy32_portable; | |
133 } | |
134 | |
135 } // namespace | 126 } // namespace |
136 | 127 |
137 void sk_memset16_large(uint16_t dst[], uint16_t value, int count) { | 128 void sk_memset16_large(uint16_t dst[], uint16_t value, int count) { |
138 SK_DECLARE_STATIC_LAZY_FN_PTR(SkMemset16Proc, proc, choose_memset16); | 129 SK_DECLARE_STATIC_LAZY_FN_PTR(SkMemset16Proc, proc, choose_memset16); |
139 proc.get()(dst, value, count); | 130 proc.get()(dst, value, count); |
140 } | 131 } |
141 | 132 |
142 void sk_memset32_large(uint32_t dst[], uint32_t value, int count) { | 133 void sk_memset32_large(uint32_t dst[], uint32_t value, int count) { |
143 SK_DECLARE_STATIC_LAZY_FN_PTR(SkMemset32Proc, proc, choose_memset32); | 134 SK_DECLARE_STATIC_LAZY_FN_PTR(SkMemset32Proc, proc, choose_memset32); |
144 proc.get()(dst, value, count); | 135 proc.get()(dst, value, count); |
145 } | 136 } |
146 | 137 |
147 void sk_memcpy32(uint32_t dst[], const uint32_t src[], int count) { | |
148 SK_DECLARE_STATIC_LAZY_FN_PTR(SkMemcpy32Proc, proc, choose_memcpy32); | |
149 proc.get()(dst, src, count); | |
150 } | |
151 | |
152 /////////////////////////////////////////////////////////////////////////////// | 138 /////////////////////////////////////////////////////////////////////////////// |
153 | 139 |
154 /* 0xxxxxxx 1 total | 140 /* 0xxxxxxx 1 total |
155 10xxxxxx // never a leading byte | 141 10xxxxxx // never a leading byte |
156 110xxxxx 2 total | 142 110xxxxx 2 total |
157 1110xxxx 3 total | 143 1110xxxx 3 total |
158 11110xxx 4 total | 144 11110xxx 4 total |
159 | 145 |
160 11 10 01 01 xx xx xx xx 0... | 146 11 10 01 01 xx xx xx xx 0... |
161 0xE5XX0000 | 147 0xE5XX0000 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 } | 399 } |
414 } else { | 400 } else { |
415 char* start = utf8; | 401 char* start = utf8; |
416 while (utf16 < stop) { | 402 while (utf16 < stop) { |
417 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8); | 403 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8); |
418 } | 404 } |
419 size = utf8 - start; | 405 size = utf8 - start; |
420 } | 406 } |
421 return size; | 407 return size; |
422 } | 408 } |
OLD | NEW |