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

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

Issue 305753002: Spin off just SkLazyFnPtr from 305513002. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkThreadPriv again Created 6 years, 6 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/SkThreadPriv.h ('k') | src/ports/SkAtomics_sync.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"
11 #include "SkOnce.h" 11 #include "SkLazyFnPtr.h"
12 12
13 #if 0 13 #if 0
14 #define assign_16_longs(dst, value) \ 14 #define assign_16_longs(dst, value) \
15 do { \ 15 do { \
16 (dst)[0] = value; (dst)[1] = value; \ 16 (dst)[0] = value; (dst)[1] = value; \
17 (dst)[2] = value; (dst)[3] = value; \ 17 (dst)[2] = value; (dst)[3] = value; \
18 (dst)[4] = value; (dst)[5] = value; \ 18 (dst)[4] = value; (dst)[5] = value; \
19 (dst)[6] = value; (dst)[7] = value; \ 19 (dst)[6] = value; (dst)[7] = value; \
20 (dst)[8] = value; (dst)[9] = value; \ 20 (dst)[8] = value; (dst)[9] = value; \
21 (dst)[10] = value; (dst)[11] = value; \ 21 (dst)[10] = value; (dst)[11] = value; \
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ) { 112 static void sk_memcpy32_portable(uint32_t dst[], const uint32_t src[], int count ) {
113 memcpy(dst, src, count * sizeof(uint32_t)); 113 memcpy(dst, src, count * sizeof(uint32_t));
114 } 114 }
115 115
116 static void choose_memset16(SkMemset16Proc* proc) { 116 static SkMemset16Proc choose_memset16() {
117 *proc = SkMemset16GetPlatformProc(); 117 SkMemset16Proc proc = SkMemset16GetPlatformProc();
118 if (NULL == *proc) { 118 return proc ? proc : sk_memset16_portable;
119 *proc = &sk_memset16_portable;
120 }
121 } 119 }
122 120
123 void sk_memset16(uint16_t dst[], uint16_t value, int count) { 121 void sk_memset16(uint16_t dst[], uint16_t value, int count) {
124 SK_DECLARE_STATIC_ONCE(once); 122 SK_DECLARE_STATIC_LAZY_FN_PTR(SkMemset16Proc, choice);
125 static SkMemset16Proc proc = NULL; 123 return choice.get(choose_memset16)(dst, value, count);
126 SkOnce(&once, choose_memset16, &proc);
127 SkASSERT(proc != NULL);
128
129 return proc(dst, value, count);
130 } 124 }
131 125
132 static void choose_memset32(SkMemset32Proc* proc) { 126 static SkMemset32Proc choose_memset32() {
133 *proc = SkMemset32GetPlatformProc(); 127 SkMemset32Proc proc = SkMemset32GetPlatformProc();
134 if (NULL == *proc) { 128 return proc ? proc : sk_memset32_portable;
135 *proc = &sk_memset32_portable;
136 }
137 } 129 }
138 130
139 void sk_memset32(uint32_t dst[], uint32_t value, int count) { 131 void sk_memset32(uint32_t dst[], uint32_t value, int count) {
140 SK_DECLARE_STATIC_ONCE(once); 132 SK_DECLARE_STATIC_LAZY_FN_PTR(SkMemset32Proc, choice);
141 static SkMemset32Proc proc = NULL; 133 return choice.get(choose_memset32)(dst, value, count);
142 SkOnce(&once, choose_memset32, &proc);
143 SkASSERT(proc != NULL);
144
145 return proc(dst, value, count);
146 } 134 }
147 135
148 static void choose_memcpy32(SkMemcpy32Proc* proc) { 136 static SkMemcpy32Proc choose_memcpy32() {
149 *proc = SkMemcpy32GetPlatformProc(); 137 SkMemcpy32Proc proc = SkMemcpy32GetPlatformProc();
150 if (NULL == *proc) { 138 return proc ? proc : sk_memcpy32_portable;
151 *proc = &sk_memcpy32_portable;
152 }
153 } 139 }
154 140
155 void sk_memcpy32(uint32_t dst[], const uint32_t src[], int count) { 141 void sk_memcpy32(uint32_t dst[], const uint32_t src[], int count) {
156 SK_DECLARE_STATIC_ONCE(once); 142 SK_DECLARE_STATIC_LAZY_FN_PTR(SkMemcpy32Proc, choice);
157 static SkMemcpy32Proc proc = NULL; 143 return choice.get(choose_memcpy32)(dst, src, count);
158 SkOnce(&once, choose_memcpy32, &proc);
159 SkASSERT(proc != NULL);
160
161 return proc(dst, src, count);
162 } 144 }
163 145
164 /////////////////////////////////////////////////////////////////////////////// 146 ///////////////////////////////////////////////////////////////////////////////
165 147
166 /* 0xxxxxxx 1 total 148 /* 0xxxxxxx 1 total
167 10xxxxxx // never a leading byte 149 10xxxxxx // never a leading byte
168 110xxxxx 2 total 150 110xxxxx 2 total
169 1110xxxx 3 total 151 1110xxxx 3 total
170 11110xxx 4 total 152 11110xxx 4 total
171 153
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 407 }
426 } else { 408 } else {
427 char* start = utf8; 409 char* start = utf8;
428 while (utf16 < stop) { 410 while (utf16 < stop) {
429 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8); 411 utf8 += SkUTF8_FromUnichar(SkUTF16_NextUnichar(&utf16), utf8);
430 } 412 }
431 size = utf8 - start; 413 size = utf8 - start;
432 } 414 }
433 return size; 415 return size;
434 } 416 }
OLDNEW
« no previous file with comments | « src/core/SkThreadPriv.h ('k') | src/ports/SkAtomics_sync.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698