aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPathRef.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-05-05 16:05:56 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-05 16:05:56 -0700
commitffa4a9213b4e754adc210fa02a3c4b1ae8d3b6d0 (patch)
treee6f20243b4ed7c36e36302d914e255dfa6799217 /src/core/SkPathRef.cpp
parent4017007b288087c07c596baa9fe8ecf485bca1c3 (diff)
SkOncePtr -> SkOnce
It's always nice to kill off a synchronization primitive. And while less terse, I think this new code reads more clearly. ... and, SkOncePtr's tests were the only thing now using sk_num_cores() outside of SkTaskGroup, so I've hidden it as static inside SkTaskGroup.cpp. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1953533002 CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Committed: https://skia.googlesource.com/skia/+/9bd3fc7fa9bb7cad050bd619aa93d4c48ebb5c02 Review-Url: https://codereview.chromium.org/1953533002
Diffstat (limited to 'src/core/SkPathRef.cpp')
-rw-r--r--src/core/SkPathRef.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
index b18055136f..2fc2de935c 100644
--- a/src/core/SkPathRef.cpp
+++ b/src/core/SkPathRef.cpp
@@ -6,7 +6,7 @@
*/
#include "SkBuffer.h"
-#include "SkOncePtr.h"
+#include "SkOnce.h"
#include "SkPath.h"
#include "SkPathRef.h"
#include <limits>
@@ -45,13 +45,15 @@ SkPathRef::~SkPathRef() {
SkDEBUGCODE(fEditorsAttached = 0x7777777;)
}
-SK_DECLARE_STATIC_ONCE_PTR(SkPathRef, empty);
+static SkPathRef* gEmpty = nullptr;
+
SkPathRef* SkPathRef::CreateEmpty() {
- return SkRef(empty.get([]{
- SkPathRef* pr = new SkPathRef;
- pr->computeBounds(); // Avoids races later to be the first to do this.
- return pr;
- }));
+ static SkOnce once;
+ once([]{
+ gEmpty = new SkPathRef;
+ gEmpty->computeBounds(); // Avoids races later to be the first to do this.
+ });
+ return SkRef(gEmpty);
}
void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst,
@@ -469,7 +471,7 @@ uint32_t SkPathRef::genID() const {
}
void SkPathRef::addGenIDChangeListener(GenIDChangeListener* listener) {
- if (nullptr == listener || this == (SkPathRef*)empty) {
+ if (nullptr == listener || this == gEmpty) {
delete listener;
return;
}