diff options
author | Robert Phillips <robertphillips@google.com> | 2017-10-05 11:28:20 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-05 11:28:35 +0000 |
commit | 01f8e41c1368bfd60d3f011cb5aa9cc478799e63 (patch) | |
tree | a6188765164358d4eb742c6ef7c05ae1d57c653c /include/core/SkString.h | |
parent | 1ea81e766e1a12d5498c481ff8cc5225da0b4860 (diff) |
Revert "Clean up SkString reference counting a bit."
This reverts commit a910c847e9d04e183e9e610902cbd363c8488196.
Reason for revert: Compilation failure on Ubuntu14 bots
../../../../../work/skia/src/core/SkString.cpp:200:55: error: could not convert ‘{0, {0}, 0}’ from ‘<brace-enclosed initializer list>’ to ‘const SkString::Rec’
const SkString::Rec SkString::gEmptyRec = { 0, {0}, 0 };
Original change's description:
> Clean up SkString reference counting a bit.
>
> BUG=skia:7107
>
> Change-Id: I47072bf31b902c79dbb850179ff6d35940de3e63
> Reviewed-on: https://skia-review.googlesource.com/54720
> Reviewed-by: Ben Wagner <bungeman@google.com>
> Commit-Queue: Ben Wagner <bungeman@google.com>
TBR=mtklein@google.com,bungeman@google.com,reed@google.com
Change-Id: I6ec327511e8e1c1fd7e4c1bd5839c0547d4ab609
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:7107
Reviewed-on: https://skia-review.googlesource.com/55640
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include/core/SkString.h')
-rw-r--r-- | include/core/SkString.h | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/include/core/SkString.h b/include/core/SkString.h index 04eb02afc0..d9a922c0c3 100644 --- a/include/core/SkString.h +++ b/include/core/SkString.h @@ -12,7 +12,6 @@ #include "../private/SkTArray.h" #include "SkScalar.h" -#include "SkRefCnt.h" #include <atomic> #include <stdarg.h> @@ -241,20 +240,16 @@ public: private: struct Rec { public: - Rec() = delete; - static sk_sp<Rec> Make(const char text[], size_t len); uint32_t fLength; // logically size_t, but we want it to stay 32bits - mutable std::atomic<int32_t> fRefCnt; + std::atomic<int32_t> fRefCnt; char fBeginningOfData; char* data() { return &fBeginningOfData; } const char* data() const { return &fBeginningOfData; } - void ref() const; - void unref() const; - bool unique() const; + bool unique() { return fRefCnt.load(std::memory_order_acquire) == 1; } }; - sk_sp<Rec> fRec; + Rec* fRec; #ifdef SK_DEBUG void validate() const; @@ -263,6 +258,8 @@ private: #endif static const Rec gEmptyRec; + static Rec* AllocRec(const char text[], size_t len); + static Rec* RefRec(Rec*); }; /// Creates a new string and writes into it using a printf()-style format. |