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

Unified Diff: src/core/SkXfermode.cpp

Issue 1949313003: Reland 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 1cfe8647511088cea117a28b9438691e6abd4eb3..b6d23888a741d7611eb4c7a72c7937680b045d96 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 "SkOncePtr.h"
+#include "SkOnce.h"
#include "SkOpts.h"
#include "SkReadBuffer.h"
#include "SkString.h"
@@ -1303,11 +1303,7 @@
#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;
@@ -1319,13 +1315,20 @@
return nullptr;
}
- return sk_ref_sp(cached[mode].get([=]{
+ SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount);
+
+ static SkOnce once[SkXfermode::kLastMode+1];
+ static SkXfermode* cached[SkXfermode::kLastMode+1];
+
+ once[mode]([mode] {
ProcCoeff rec = gProcCoeffs[mode];
if (auto xfermode = SkOpts::create_xfermode(rec, mode)) {
- return xfermode;
+ cached[mode] = xfermode;
+ } else {
+ cached[mode] = new SkProcCoeffXfermode(rec, mode);
}
- return (SkXfermode*) new SkProcCoeffXfermode(rec, mode);
- }));
+ });
+ return sk_ref_sp(cached[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