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

Unified Diff: src/core/SkMiniRecorder.cpp

Issue 1147053002: Make SkEmptyPicture a singleton. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: rebase Created 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMiniRecorder.cpp
diff --git a/src/core/SkMiniRecorder.cpp b/src/core/SkMiniRecorder.cpp
index 6707e863ac488013b341110428e2a126370e24de..ff17edb2575cae68001b26e1ce0e3e202c24fd9d 100644
--- a/src/core/SkMiniRecorder.cpp
+++ b/src/core/SkMiniRecorder.cpp
@@ -6,6 +6,7 @@
*/
#include "SkCanvas.h"
+#include "SkLazyPtr.h"
#include "SkMiniRecorder.h"
#include "SkPicture.h"
#include "SkPictureCommon.h"
@@ -14,9 +15,6 @@
using namespace SkRecords;
-// SkEmptyPicture could logically be a singleton, but that plays badly with Blink's
-// Debug-only adopted() / requireAdoption() tracking in sk_ref_cnt_ext_debug.h.
-// TODO(mtklein): modify sk_ref_cnt_ext_debug.h to play better with non-new'd objects.
class SkEmptyPicture final : public SkPicture {
public:
void playback(SkCanvas*, AbortCallback*) const override { }
@@ -28,6 +26,7 @@ public:
int numSlowPaths() const override { return 0; }
bool willPlayBackBitmaps() const override { return false; }
};
+SK_DECLARE_STATIC_LAZY_PTR(SkEmptyPicture, gEmptyPicture);
template <typename T>
class SkMiniPicture final : public SkPicture {
@@ -94,7 +93,7 @@ SkPicture* SkMiniRecorder::detachAsPicture(const SkRect& cull) {
return SkNEW_ARGS(SkMiniPicture<Type>, (cull, reinterpret_cast<Type*>(fBuffer.get())))
switch (fState) {
- case State::kEmpty: return SkNEW(SkEmptyPicture);
+ case State::kEmpty: return SkRef(gEmptyPicture.get());
CASE(DrawPath);
CASE(DrawRect);
CASE(DrawTextBlob);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698