aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkMiniRecorder.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/SkMiniRecorder.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/SkMiniRecorder.cpp')
-rw-r--r--src/core/SkMiniRecorder.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/core/SkMiniRecorder.cpp b/src/core/SkMiniRecorder.cpp
index 2d5b0943e5..378f4304b3 100644
--- a/src/core/SkMiniRecorder.cpp
+++ b/src/core/SkMiniRecorder.cpp
@@ -8,7 +8,7 @@
#include "SkCanvas.h"
#include "SkTLazy.h"
#include "SkMiniRecorder.h"
-#include "SkOncePtr.h"
+#include "SkOnce.h"
#include "SkPicture.h"
#include "SkPictureCommon.h"
#include "SkRecordDraw.h"
@@ -27,7 +27,6 @@ public:
int numSlowPaths() const override { return 0; }
bool willPlayBackBitmaps() const override { return false; }
};
-SK_DECLARE_STATIC_ONCE_PTR(SkEmptyPicture, gEmptyPicture);
template <typename T>
class SkMiniPicture final : public SkPicture {
@@ -107,8 +106,13 @@ sk_sp<SkPicture> SkMiniRecorder::detachAsPicture(const SkRect& cull) {
fState = State::kEmpty; \
return sk_make_sp<SkMiniPicture<Type>>(cull, reinterpret_cast<Type*>(fBuffer.get()))
+ static SkOnce once;
+ static SkPicture* empty;
+
switch (fState) {
- case State::kEmpty: return sk_ref_sp(gEmptyPicture.get([]{ return new SkEmptyPicture; }));
+ case State::kEmpty:
+ once([]{ empty = new SkEmptyPicture; });
+ return sk_ref_sp(empty);
CASE(DrawBitmapRectFixedSize);
CASE(DrawPath);
CASE(DrawRect);