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

Unified Diff: src/core/SkXfermode.cpp

Issue 1948313002: Revert of SkOncePtr -> SkOnce (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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/SkTypeface.cpp ('k') | src/fonts/SkRemotableFontMgr.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkXfermode.cpp
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index b6d23888a741d7611eb4c7a72c7937680b045d96..1cfe8647511088cea117a28b9438691e6abd4eb3 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -9,7 +9,7 @@
#include "SkXfermode_proccoeff.h"
#include "SkColorPriv.h"
#include "SkMathPriv.h"
-#include "SkOnce.h"
+#include "SkOncePtr.h"
#include "SkOpts.h"
#include "SkReadBuffer.h"
#include "SkString.h"
@@ -1303,7 +1303,11 @@
#endif
+SK_DECLARE_STATIC_ONCE_PTR(SkXfermode, cached[SkXfermode::kLastMode + 1]);
+
sk_sp<SkXfermode> SkXfermode::Make(Mode mode) {
+ SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount);
+
if ((unsigned)mode >= kModeCount) {
// report error
return nullptr;
@@ -1315,20 +1319,13 @@
return nullptr;
}
- SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount);
-
- static SkOnce once[SkXfermode::kLastMode+1];
- static SkXfermode* cached[SkXfermode::kLastMode+1];
-
- once[mode]([mode] {
+ return sk_ref_sp(cached[mode].get([=]{
ProcCoeff rec = gProcCoeffs[mode];
if (auto xfermode = SkOpts::create_xfermode(rec, mode)) {
- cached[mode] = xfermode;
- } else {
- cached[mode] = new SkProcCoeffXfermode(rec, mode);
+ return xfermode;
}
- });
- return sk_ref_sp(cached[mode]);
+ return (SkXfermode*) new SkProcCoeffXfermode(rec, mode);
+ }));
}
SkXfermodeProc SkXfermode::GetProc(Mode mode) {
« no previous file with comments | « src/core/SkTypeface.cpp ('k') | src/fonts/SkRemotableFontMgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698