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

Unified Diff: src/core/SkCpu.cpp

Issue 1905683003: SkCpu w/o static initializer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: back to static-initializer on Windows Created 4 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 | « src/core/SkCpu.h ('k') | src/core/SkGraphics.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCpu.cpp
diff --git a/src/core/SkCpu.cpp b/src/core/SkCpu.cpp
index 4030fce2e1fc6305e4fae37e8c90680e8dc6334d..b296f0c02a5710b137e9e1bdf72669af2d743cff 100644
--- a/src/core/SkCpu.cpp
+++ b/src/core/SkCpu.cpp
@@ -5,8 +5,9 @@
* found in the LICENSE file.
*/
+#define SkCpu_IMPL
#include "SkCpu.h"
-#include "SkOncePtr.h"
+#include "SkOnce.h"
#if defined(SK_CPU_X86)
#if defined(SK_BUILD_FOR_WIN32)
@@ -78,13 +79,17 @@
#endif
-#if defined(__GNUC__) || defined(__clang__)
- SK_DECLARE_STATIC_ONCE_PTR(uint32_t, gCachedCpuFeatures);
- uint32_t SkCpu::RuntimeCpuFeatures() {
- return *gCachedCpuFeatures.get([]{ return new uint32_t{read_cpu_features()}; });
- }
+#if defined(_MSC_VER)
+ const uint32_t SkCpu::gCachedFeatures = read_cpu_features();
+
+ void SkCpu::CacheRuntimeFeatures() {}
#else
- const uint32_t SkCpu::gCachedCpuFeatures = read_cpu_features();
+ uint32_t SkCpu::gCachedFeatures = 0;
+
+ void SkCpu::CacheRuntimeFeatures() {
+ static SkOnce once;
+ once([] { gCachedFeatures = read_cpu_features(); });
+ }
#endif
« no previous file with comments | « src/core/SkCpu.h ('k') | src/core/SkGraphics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698