aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkResourceCache.h
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-02-17 10:13:49 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-17 10:13:49 -0800
commit70bb80802198b7fedee58f79d0d68d5f8aba8b62 (patch)
tree3363569b449e26baef43a28fa2fed1ff33cabe0f /src/core/SkResourceCache.h
parent8715d47e247bf890ee78af0774ae7e8698146b67 (diff)
Add request cache to SkFontHost_fontconfig.
The current code deduplicates SkTypeface instances as all font lookups should for better use of the glyph cache. This adds a request cache as well, so that repeated recent requests will return the cached result instead of doing a full lookup. BUG=chromium:424082, chromium:444894 Review URL: https://codereview.chromium.org/1683883002
Diffstat (limited to 'src/core/SkResourceCache.h')
-rw-r--r--src/core/SkResourceCache.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/core/SkResourceCache.h b/src/core/SkResourceCache.h
index a748133c96..548f17fe87 100644
--- a/src/core/SkResourceCache.h
+++ b/src/core/SkResourceCache.h
@@ -29,14 +29,18 @@ class SkTraceMemoryDump;
class SkResourceCache {
public:
struct Key {
- // Call this to access your private contents. Must not use the address after calling init()
- void* writableContents() { return this + 1; }
-
- // must call this after your private data has been written.
- // nameSpace must be unique per Key subclass.
- // sharedID == 0 means ignore this field : does not support group purging.
- // length must be a multiple of 4
- void init(void* nameSpace, uint64_t sharedID, size_t length);
+ /** Key subclasses must call this after their own fields and data are initialized.
+ * All fields and data must be tightly packed.
+ * @param nameSpace must be unique per Key subclass.
+ * @param sharedID == 0 means ignore this field, does not support group purging.
+ * @param dataSize is size of fields and data of the subclass, must be a multiple of 4.
+ */
+ void init(void* nameSpace, uint64_t sharedID, size_t dataSize);
+
+ /** Returns the size of this key. */
+ size_t size() const {
+ return fCount32 << 2;
+ }
void* getNamespace() const { return fNamespace; }
uint64_t getSharedID() const { return ((uint64_t)fSharedID_hi << 32) | fSharedID_lo; }