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

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: No longer need 'memory' include. 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/ports/SkFontHost_fontconfig.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()
33 void* writableContents() { return this + 1; }
34
35 // must call this after your private data has been written. 32 // must call this after your private data has been written.
36 // nameSpace must be unique per Key subclass. 33 // nameSpace must be unique per Key subclass.
37 // sharedID == 0 means ignore this field : does not support group purgin g. 34 // sharedID == 0 means ignore this field : does not support group purgin g.
38 // length must be a multiple of 4 35 // length must be a multiple of 4
39 void init(void* nameSpace, uint64_t sharedID, size_t length); 36 void init(void* nameSpace, uint64_t sharedID, size_t length);
40 37
38 /** Returns the size of this key. */
39 size_t length() {
reed1 2016/02/17 14:12:52 size_t size() const { ...
bungeman-skia 2016/02/17 16:55:36 Heh, yes, http://stackoverflow.com/questions/30052
40 return fCount32 << 2;
41 }
42
41 void* getNamespace() const { return fNamespace; } 43 void* getNamespace() const { return fNamespace; }
42 uint64_t getSharedID() const { return ((uint64_t)fSharedID_hi << 32) | f SharedID_lo; } 44 uint64_t getSharedID() const { return ((uint64_t)fSharedID_hi << 32) | f SharedID_lo; }
43 45
44 // This is only valid after having called init(). 46 // This is only valid after having called init().
45 uint32_t hash() const { return fHash; } 47 uint32_t hash() const { return fHash; }
46 48
47 bool operator==(const Key& other) const { 49 bool operator==(const Key& other) const {
48 const uint32_t* a = this->as32(); 50 const uint32_t* a = this->as32();
49 const uint32_t* b = other.as32(); 51 const uint32_t* b = other.as32();
50 for (int i = 0; i < fCount32; ++i) { // (This checks fCount == othe r.fCount first.) 52 for (int i = 0; i < fCount32; ++i) { // (This checks fCount == othe r.fCount first.)
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 279
278 void init(); // called by constructors 280 void init(); // called by constructors
279 281
280 #ifdef SK_DEBUG 282 #ifdef SK_DEBUG
281 void validate() const; 283 void validate() const;
282 #else 284 #else
283 void validate() const {} 285 void validate() const {}
284 #endif 286 #endif
285 }; 287 };
286 #endif 288 #endif
OLDNEW
« no previous file with comments | « no previous file | src/ports/SkFontHost_fontconfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698