Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: src/core/SkResourceCache.h

Issue 1683883002: Add request cache to SkFontHost_fontconfig. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make method 'const'. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkResourceCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkResourceCache_DEFINED 8 #ifndef SkResourceCache_DEFINED
9 #define SkResourceCache_DEFINED 9 #define SkResourceCache_DEFINED
10 10
(...skipping 11 matching lines...) Expand all
22 * Multiple caches can be instantiated, but each instance is not implicitly 22 * Multiple caches can be instantiated, but each instance is not implicitly
23 * thread-safe, so if a given instance is to be shared across threads, the 23 * thread-safe, so if a given instance is to be shared across threads, the
24 * caller must manage the access itself (e.g. via a mutex). 24 * caller must manage the access itself (e.g. via a mutex).
25 * 25 *
26 * As a convenience, a global instance is also defined, which can be safely 26 * As a convenience, a global instance is also defined, which can be safely
27 * access across threads via the static methods (e.g. FindAndLock, etc.). 27 * access across threads via the static methods (e.g. FindAndLock, etc.).
28 */ 28 */
29 class SkResourceCache { 29 class SkResourceCache {
30 public: 30 public:
31 struct Key { 31 struct Key {
32 // Call this to access your private contents. Must not use the address a fter calling init() 32 /** Key subclasses must call this after their own fields and data are in itialized.
33 void* writableContents() { return this + 1; } 33 * All fields and data must be tightly packed.
34 * @param nameSpace must be unique per Key subclass.
35 * @param sharedID == 0 means ignore this field, does not support group purging.
36 * @param dataSize is size of fields and data of the subclass, must be a multiple of 4.
37 */
38 void init(void* nameSpace, uint64_t sharedID, size_t dataSize);
34 39
35 // must call this after your private data has been written. 40 /** Returns the size of this key. */
36 // nameSpace must be unique per Key subclass. 41 size_t size() const {
37 // sharedID == 0 means ignore this field : does not support group purgin g. 42 return fCount32 << 2;
38 // length must be a multiple of 4 43 }
39 void init(void* nameSpace, uint64_t sharedID, size_t length);
40 44
41 void* getNamespace() const { return fNamespace; } 45 void* getNamespace() const { return fNamespace; }
42 uint64_t getSharedID() const { return ((uint64_t)fSharedID_hi << 32) | f SharedID_lo; } 46 uint64_t getSharedID() const { return ((uint64_t)fSharedID_hi << 32) | f SharedID_lo; }
43 47
44 // This is only valid after having called init(). 48 // This is only valid after having called init().
45 uint32_t hash() const { return fHash; } 49 uint32_t hash() const { return fHash; }
46 50
47 bool operator==(const Key& other) const { 51 bool operator==(const Key& other) const {
48 const uint32_t* a = this->as32(); 52 const uint32_t* a = this->as32();
49 const uint32_t* b = other.as32(); 53 const uint32_t* b = other.as32();
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 281
278 void init(); // called by constructors 282 void init(); // called by constructors
279 283
280 #ifdef SK_DEBUG 284 #ifdef SK_DEBUG
281 void validate() const; 285 void validate() const;
282 #else 286 #else
283 void validate() const {} 287 void validate() const {}
284 #endif 288 #endif
285 }; 289 };
286 #endif 290 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698