| Index: src/core/SkData.cpp
|
| diff --git a/src/core/SkData.cpp b/src/core/SkData.cpp
|
| index 2f079140677759b85a746d8c66e0a726a53b6368..c65328720a789051e49be9d41d4a0a6866a022fc 100644
|
| --- a/src/core/SkData.cpp
|
| +++ b/src/core/SkData.cpp
|
| @@ -6,10 +6,10 @@
|
| */
|
|
|
| #include "SkData.h"
|
| +#include "SkLazyPtr.h"
|
| +#include "SkOSFile.h"
|
| #include "SkReadBuffer.h"
|
| #include "SkWriteBuffer.h"
|
| -#include "SkOSFile.h"
|
| -#include "SkOnce.h"
|
|
|
| SkData::SkData(const void* ptr, size_t size, ReleaseProc proc, void* context) {
|
| fPtr = ptr;
|
| @@ -49,18 +49,14 @@ size_t SkData::copyRange(size_t offset, size_t length, void* buffer) const {
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -static SkData* gEmptyDataRef = NULL;
|
| -static void cleanup_gEmptyDataRef() { gEmptyDataRef->unref(); }
|
| -
|
| -void SkData::NewEmptyImpl(int) {
|
| - gEmptyDataRef = new SkData(NULL, 0, NULL, NULL);
|
| +SkData* SkData::NewEmptyImpl() {
|
| + return new SkData(NULL, 0, NULL, NULL);
|
| }
|
| +void SkData::DeleteEmpty(SkData* ptr) { SkDELETE(ptr); }
|
|
|
| SkData* SkData::NewEmpty() {
|
| - SK_DECLARE_STATIC_ONCE(once);
|
| - SkOnce(&once, SkData::NewEmptyImpl, 0, cleanup_gEmptyDataRef);
|
| - gEmptyDataRef->ref();
|
| - return gEmptyDataRef;
|
| + SK_DECLARE_STATIC_LAZY_PTR(SkData, empty, NewEmptyImpl, DeleteEmpty);
|
| + return SkRef(empty.get());
|
| }
|
|
|
| // assumes fPtr was allocated via sk_malloc
|
|
|