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

Unified Diff: src/core/SkXfermode.cpp

Issue 1334523002: Revert of Port uses of SkLazyPtr to SkOncePtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 8548fe8aaca251fcac622864270496a92516039d..18ab9b6a0a6347a45771673fddd32121a19ca0c6 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -9,8 +9,8 @@
#include "SkXfermode.h"
#include "SkXfermode_proccoeff.h"
#include "SkColorPriv.h"
+#include "SkLazyPtr.h"
#include "SkMathPriv.h"
-#include "SkOncePtr.h"
#include "SkOpts.h"
#include "SkReadBuffer.h"
#include "SkString.h"
@@ -996,7 +996,20 @@
#endif
-SK_DECLARE_STATIC_ONCE_PTR(SkXfermode, cached[SkXfermode::kLastMode + 1]);
+// Technically, can't be static and passed as a template parameter. So we use anonymous namespace.
+namespace {
+SkXfermode* create_mode(int iMode) {
+ SkXfermode::Mode mode = (SkXfermode::Mode)iMode;
+
+ ProcCoeff rec = gProcCoeffs[mode];
+ if (auto xfermode = SkOpts::create_xfermode(rec, mode)) {
+ return xfermode;
+ }
+ return new SkProcCoeffXfermode(rec, mode);
+}
+} // namespace
+
+SK_DECLARE_STATIC_LAZY_PTR_ARRAY(SkXfermode, cached, SkXfermode::kLastMode + 1, create_mode);
SkXfermode* SkXfermode::Create(Mode mode) {
SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount);
@@ -1012,13 +1025,7 @@
return nullptr;
}
- return SkSafeRef(cached[mode].get([=]{
- ProcCoeff rec = gProcCoeffs[mode];
- if (auto xfermode = SkOpts::create_xfermode(rec, mode)) {
- return xfermode;
- }
- return (SkXfermode*) new SkProcCoeffXfermode(rec, mode);
- }));
+ return SkSafeRef(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