diff options
author | mtklein <mtklein@chromium.org> | 2016-04-18 08:09:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-18 08:09:11 -0700 |
commit | d9dd4282118fc14eac735e6fa0b3ec53047b457f (patch) | |
tree | b88bce11cbcec3100e428b713df49e1fcd83f8d2 /include/ports | |
parent | f7142e71d7c0a7d8406679e207ff766085499d2e (diff) |
Modernize and trim down SkOnce.
The API and implementation are very much simplified.
You may not want to bother reading the diff.
As is our trend, SkOnce now uses <atomic> directly.
Member initialization means we don't need SK_DECLARE_STATIC_ONCE.
SkSpinlock already works this same way.
All uses of the old API taking an external bool* and Lock* were pessimal,
so I have not carried this sort of API forward. It's simpler, faster,
and more space-efficient to always use this single SkOnce class interface.
SkOnce weighs 2 bytes: a done bool and an SkSpinlock, also a bool internally.
This API refactoring opens up the opportunity to fuse those into a single
three-state byte if we'd like.
No public API changes.
TBR=reed@google.com
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1894893002
Review URL: https://codereview.chromium.org/1894893002
Diffstat (limited to 'include/ports')
-rw-r--r-- | include/ports/SkFontMgr_indirect.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/ports/SkFontMgr_indirect.h b/include/ports/SkFontMgr_indirect.h index 5e8f1ede70..d3f47cb82b 100644 --- a/include/ports/SkFontMgr_indirect.h +++ b/include/ports/SkFontMgr_indirect.h @@ -9,6 +9,7 @@ #define SkFontMgr_indirect_DEFINED #include "../private/SkMutex.h" +#include "../private/SkOnce.h" #include "../private/SkTArray.h" #include "SkDataTable.h" #include "SkFontMgr.h" @@ -28,7 +29,7 @@ public: // In the future these calls should be broken out into their own interface // with a name like SkFontRenderer. SkFontMgr_Indirect(SkFontMgr* impl, SkRemotableFontMgr* proxy) - : fImpl(SkRef(impl)), fProxy(SkRef(proxy)), fFamilyNamesInited(false) + : fImpl(SkRef(impl)), fProxy(SkRef(proxy)) { } protected: @@ -95,8 +96,7 @@ private: mutable SkMutex fDataCacheMutex; mutable SkAutoTUnref<SkDataTable> fFamilyNames; - mutable bool fFamilyNamesInited; - mutable SkMutex fFamilyNamesMutex; + mutable SkOnce fFamilyNamesInitOnce; static void set_up_family_names(const SkFontMgr_Indirect* self); friend class SkStyleSet_Indirect; |