diff options
author | Herb Derby <herb@google.com> | 2018-04-17 15:00:40 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-17 20:15:11 +0000 |
commit | f155f81b8dacc2a779bce57b7f056c2831c7267d (patch) | |
tree | bd73477c433a60a88adaa035c57a0d0d06f16461 /src/core/SkStrikeCache.h | |
parent | eed61283770799292615aede81934f4e794621b7 (diff) |
Move node information to SkStrikeCache
Move all the information for handling nodes into
SkStrikeCache. Having all the cache organization
in SkStrikeCache will localize all the Chrome
pinning machinery to this class.
BUG=skia:7515
Change-Id: I5bc5488ddfe1806d62927d13148af36dac08eae9
Reviewed-on: https://skia-review.googlesource.com/121888
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkStrikeCache.h')
-rw-r--r-- | src/core/SkStrikeCache.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/core/SkStrikeCache.h b/src/core/SkStrikeCache.h index eaf360b361..6d5dd3b7bd 100644 --- a/src/core/SkStrikeCache.h +++ b/src/core/SkStrikeCache.h @@ -11,6 +11,7 @@ #include "SkDescriptor.h" #include "SkSpinlock.h" #include "SkTemplates.h" +#include "SkArenaAlloc.h" class SkGlyphCache; class SkTraceMemoryDump; @@ -38,12 +39,21 @@ public: static void AttachCache(SkGlyphCache* cache); - using ExclusiveStrikePtr = std::unique_ptr< + using ExclusiveStrikePtr = + std::unique_ptr< SkGlyphCache, SkFunctionWrapper<void, SkGlyphCache, SkStrikeCache::AttachCache>>; static ExclusiveStrikePtr FindStrikeExclusive(const SkDescriptor&); + static std::unique_ptr<SkScalerContext> CreateScalerContext( + const SkDescriptor&, const SkScalerContextEffects&, const SkTypeface&); + + static ExclusiveStrikePtr CreateStrikeExclusive( + const SkDescriptor& desc, + std::unique_ptr<SkScalerContext> scaler, + SkPaint::FontMetrics* maybeMetrics = nullptr); + static void PurgeAll(); static void Dump(); @@ -69,7 +79,6 @@ public: int getCachePointSizeLimit() const; int setCachePointSizeLimit(int limit); - #ifdef SK_DEBUG void validate() const; #else @@ -77,6 +86,16 @@ public: #endif private: + friend class SkGlyphCache; + template <typename T> + struct Node { + Node(const SkDescriptor& desc) : fDesc{desc} {} + const SkDescriptor& getDescriptor() const {return *fDesc.getDesc(); } + T* fNext{nullptr}; + T* fPrev{nullptr}; + SkAutoDescriptor fDesc; + }; + // The following methods can only be called when mutex is already held. SkGlyphCache* internalGetHead() const { return fHead; } SkGlyphCache* internalGetTail() const; |