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

Unified Diff: include/core/SkMath.h

Issue 14418004: use intrinsics on more platforms for SkCLZ (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkMath.h
===================================================================
--- include/core/SkMath.h (revision 8891)
+++ include/core/SkMath.h (working copy)
@@ -40,12 +40,24 @@
//! Returns the number of leading zero bits (0...32)
int SkCLZ_portable(uint32_t);
-#if defined(SK_CPU_ARM)
- #define SkCLZ(x) __builtin_clz(x)
-#endif
+#ifndef SkCLZ
+ #if defined(_MSC_VER) && _MSC_VER >= 1400
+ #include <intrin.h>
-#ifndef SkCLZ
- #define SkCLZ(x) SkCLZ_portable(x)
+ static inline int SkCLZ(uint32_t mask) {
+ if (mask) {
+ DWORD index;
+ _BitScanReverse(&index, mask);
+ return index ^ 0x1F;
+ } else {
+ return 32;
+ }
+ }
+ #elif defined(SK_CPU_ARM) || defined(__GNUC__)
+ #define SkCLZ(x) __builtin_clz(x)
+ #else
+ #define SkCLZ(x) SkCLZ_portable(x)
+ #endif
#endif
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698