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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkThreadPriv.h ('k') | src/ports/SkAtomics_sync.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkUtils.cpp
diff --git a/src/core/SkUtils.cpp b/src/core/SkUtils.cpp
index ca18e0cb2d08138c64f16ff48d5e6d3e2fe32fb1..591a198c6510a52603b62546b10d977430afd5a4 100644
--- a/src/core/SkUtils.cpp
+++ b/src/core/SkUtils.cpp
@@ -8,7 +8,7 @@
#include "SkUtils.h"
-#include "SkOnce.h"
+#include "SkLazyFnPtr.h"
#if 0
#define assign_16_longs(dst, value) \
@@ -113,52 +113,34 @@ static void sk_memcpy32_portable(uint32_t dst[], const uint32_t src[], int count
memcpy(dst, src, count * sizeof(uint32_t));
}
-static void choose_memset16(SkMemset16Proc* proc) {
- *proc = SkMemset16GetPlatformProc();
- if (NULL == *proc) {
- *proc = &sk_memset16_portable;
- }
+static SkMemset16Proc choose_memset16() {
+ SkMemset16Proc proc = SkMemset16GetPlatformProc();
+ return proc ? proc : sk_memset16_portable;
}
void sk_memset16(uint16_t dst[], uint16_t value, int count) {
- SK_DECLARE_STATIC_ONCE(once);
- static SkMemset16Proc proc = NULL;
- SkOnce(&once, choose_memset16, &proc);
- SkASSERT(proc != NULL);
-
- return proc(dst, value, count);
+ SK_DECLARE_STATIC_LAZY_FN_PTR(SkMemset16Proc, choice);
+ return choice.get(choose_memset16)(dst, value, count);
}
-static void choose_memset32(SkMemset32Proc* proc) {
- *proc = SkMemset32GetPlatformProc();
- if (NULL == *proc) {
- *proc = &sk_memset32_portable;
- }
+static SkMemset32Proc choose_memset32() {
+ SkMemset32Proc proc = SkMemset32GetPlatformProc();
+ return proc ? proc : sk_memset32_portable;
}
void sk_memset32(uint32_t dst[], uint32_t value, int count) {
- SK_DECLARE_STATIC_ONCE(once);
- static SkMemset32Proc proc = NULL;
- SkOnce(&once, choose_memset32, &proc);
- SkASSERT(proc != NULL);
-
- return proc(dst, value, count);
+ SK_DECLARE_STATIC_LAZY_FN_PTR(SkMemset32Proc, choice);
+ return choice.get(choose_memset32)(dst, value, count);
}
-static void choose_memcpy32(SkMemcpy32Proc* proc) {
- *proc = SkMemcpy32GetPlatformProc();
- if (NULL == *proc) {
- *proc = &sk_memcpy32_portable;
- }
+static SkMemcpy32Proc choose_memcpy32() {
+ SkMemcpy32Proc proc = SkMemcpy32GetPlatformProc();
+ return proc ? proc : sk_memcpy32_portable;
}
void sk_memcpy32(uint32_t dst[], const uint32_t src[], int count) {
- SK_DECLARE_STATIC_ONCE(once);
- static SkMemcpy32Proc proc = NULL;
- SkOnce(&once, choose_memcpy32, &proc);
- SkASSERT(proc != NULL);
-
- return proc(dst, src, count);
+ SK_DECLARE_STATIC_LAZY_FN_PTR(SkMemcpy32Proc, choice);
+ return choice.get(choose_memcpy32)(dst, src, count);
}
///////////////////////////////////////////////////////////////////////////////
« 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