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

Side by Side Diff: include/core/SkMath.h

Issue 314643004: SK_CPU_ARM --> SK_CPU_ARM32 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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 | « include/core/SkFixed.h ('k') | include/core/SkPostConfig.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 #ifndef SkMath_DEFINED 10 #ifndef SkMath_DEFINED
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 static inline int SkCLZ(uint32_t mask) { 78 static inline int SkCLZ(uint32_t mask) {
79 if (mask) { 79 if (mask) {
80 DWORD index; 80 DWORD index;
81 _BitScanReverse(&index, mask); 81 _BitScanReverse(&index, mask);
82 return index ^ 0x1F; 82 return index ^ 0x1F;
83 } else { 83 } else {
84 return 32; 84 return 32;
85 } 85 }
86 } 86 }
87 #elif defined(SK_CPU_ARM) || defined(__GNUC__) || defined(__clang__) 87 #elif defined(SK_CPU_ARM32) || defined(__GNUC__) || defined(__clang__)
88 static inline int SkCLZ(uint32_t mask) { 88 static inline int SkCLZ(uint32_t mask) {
89 // __builtin_clz(0) is undefined, so we have to detect that case. 89 // __builtin_clz(0) is undefined, so we have to detect that case.
90 return mask ? __builtin_clz(mask) : 32; 90 return mask ? __builtin_clz(mask) : 32;
91 } 91 }
92 #else 92 #else
93 #define SkCLZ(x) SkCLZ_portable(x) 93 #define SkCLZ(x) SkCLZ_portable(x)
94 #endif 94 #endif
95 #endif 95 #endif
96 96
97 /** 97 /**
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 SkASSERT(b <= 32767); 202 SkASSERT(b <= 32767);
203 unsigned prod = SkMulS16(a, b) + 128; 203 unsigned prod = SkMulS16(a, b) + 128;
204 return (prod + (prod >> 8)) >> 8; 204 return (prod + (prod >> 8)) >> 8;
205 } 205 }
206 206
207 /** 207 /**
208 * Stores numer/denom and numer%denom into div and mod respectively. 208 * Stores numer/denom and numer%denom into div and mod respectively.
209 */ 209 */
210 template <typename In, typename Out> 210 template <typename In, typename Out>
211 inline void SkTDivMod(In numer, In denom, Out* div, Out* mod) { 211 inline void SkTDivMod(In numer, In denom, Out* div, Out* mod) {
212 #ifdef SK_CPU_ARM 212 #ifdef SK_CPU_ARM32
213 // If we wrote this as in the else branch, GCC won't fuse the two into one 213 // If we wrote this as in the else branch, GCC won't fuse the two into one
214 // divmod call, but rather a div call followed by a divmod. Silly! This 214 // divmod call, but rather a div call followed by a divmod. Silly! This
215 // version is just as fast as calling __aeabi_[u]idivmod manually, but with 215 // version is just as fast as calling __aeabi_[u]idivmod manually, but with
216 // prettier code. 216 // prettier code.
217 // 217 //
218 // This benches as around 2x faster than the code in the else branch. 218 // This benches as around 2x faster than the code in the else branch.
219 const In d = numer/denom; 219 const In d = numer/denom;
220 *div = static_cast<Out>(d); 220 *div = static_cast<Out>(d);
221 *mod = static_cast<Out>(numer-d*denom); 221 *mod = static_cast<Out>(numer-d*denom);
222 #else 222 #else
223 // On x86 this will just be a single idiv. 223 // On x86 this will just be a single idiv.
224 *div = static_cast<Out>(numer/denom); 224 *div = static_cast<Out>(numer/denom);
225 *mod = static_cast<Out>(numer%denom); 225 *mod = static_cast<Out>(numer%denom);
226 #endif // SK_CPU_ARM 226 #endif
227 } 227 }
228 228
229 #endif 229 #endif
OLDNEW
« no previous file with comments | « include/core/SkFixed.h ('k') | include/core/SkPostConfig.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698