Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: src/core/SkUtils.cpp

Issue 285313002: SSE2 implementation of memcpy32 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase and fix comments Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkBlitRow_D32.cpp ('k') | src/opts/SkUtils_opts_SSE2.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)
37 #endif 49 #endif
38 50
39 /////////////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////////////
40 52
41 static void sk_memset16_portable(uint16_t dst[], uint16_t value, int count) { 53 static void sk_memset16_portable(uint16_t dst[], uint16_t value, int count) {
42 SkASSERT(dst != NULL && count >= 0); 54 SkASSERT(dst != NULL && count >= 0);
43 55
44 if (count <= 0) { 56 if (count <= 0) {
45 return; 57 return;
46 } 58 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 count &= 15; 114 count &= 15;
103 } 115 }
104 116
105 if (count) { 117 if (count) {
106 do { 118 do {
107 *dst++ = value; 119 *dst++ = value;
108 } while (--count != 0); 120 } while (--count != 0);
109 } 121 }
110 } 122 }
111 123
124 static void sk_memcpy32_portable(uint32_t dst[], const uint32_t src[], int count ) {
125 SkASSERT(dst != NULL && count >= 0);
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 }
141
112 static void choose_memset16(SkMemset16Proc* proc) { 142 static void choose_memset16(SkMemset16Proc* proc) {
113 *proc = SkMemset16GetPlatformProc(); 143 *proc = SkMemset16GetPlatformProc();
114 if (NULL == *proc) { 144 if (NULL == *proc) {
115 *proc = &sk_memset16_portable; 145 *proc = &sk_memset16_portable;
116 } 146 }
117 } 147 }
118 148
119 void sk_memset16(uint16_t dst[], uint16_t value, int count) { 149 void sk_memset16(uint16_t dst[], uint16_t value, int count) {
120 SK_DECLARE_STATIC_ONCE(once); 150 SK_DECLARE_STATIC_ONCE(once);
121 static SkMemset16Proc proc = NULL; 151 static SkMemset16Proc proc = NULL;
(...skipping 12 matching lines...) Expand all
134 164
135 void sk_memset32(uint32_t dst[], uint32_t value, int count) { 165 void sk_memset32(uint32_t dst[], uint32_t value, int count) {
136 SK_DECLARE_STATIC_ONCE(once); 166 SK_DECLARE_STATIC_ONCE(once);
137 static SkMemset32Proc proc = NULL; 167 static SkMemset32Proc proc = NULL;
138 SkOnce(&once, choose_memset32, &proc); 168 SkOnce(&once, choose_memset32, &proc);
139 SkASSERT(proc != NULL); 169 SkASSERT(proc != NULL);
140 170
141 return proc(dst, value, count); 171 return proc(dst, value, count);
142 } 172 }
143 173
174 static void choose_memcpy32(SkMemcpy32Proc* proc) {
175 *proc = SkMemcpy32GetPlatformProc();
176 if (NULL == *proc) {
177 *proc = &sk_memcpy32_portable;
178 }
179 }
180
181 void sk_memcpy32(uint32_t dst[], const uint32_t src[], int count) {
182 SK_DECLARE_STATIC_ONCE(once);
183 static SkMemcpy32Proc proc = NULL;
184 SkOnce(&once, choose_memcpy32, &proc);
185 SkASSERT(proc != NULL);
186
187 return proc(dst, src, count);
188 }
189
144 /////////////////////////////////////////////////////////////////////////////// 190 ///////////////////////////////////////////////////////////////////////////////
145 191
146 /* 0xxxxxxx 1 total 192 /* 0xxxxxxx 1 total
147 10xxxxxx // never a leading byte 193 10xxxxxx // never a leading byte
148 110xxxxx 2 total 194 110xxxxx 2 total
149 1110xxxx 3 total 195 1110xxxx 3 total
150 11110xxx 4 total 196 11110xxx 4 total
151 197
152 11 10 01 01 xx xx xx xx 0... 198 11 10 01 01 xx xx xx xx 0...
153 0xE5XX0000 199 0xE5XX0000
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 451 }
406 } else { 452 } else {
407 char* start = utf8; 453 char* start = utf8;
408 while (utf16 < stop) { 454 while (utf16 < stop) {
409 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8); 455 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8);
410 } 456 }
411 size = utf8 - start; 457 size = utf8 - start;
412 } 458 }
413 return size; 459 return size;
414 } 460 }
OLDNEW
« no previous file with comments | « src/core/SkBlitRow_D32.cpp ('k') | src/opts/SkUtils_opts_SSE2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698