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

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

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 | « src/core/SkResourceCache.h ('k') | 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 #include "SkChecksum.h" 8 #include "SkChecksum.h"
9 #include "SkMessageBus.h" 9 #include "SkMessageBus.h"
10 #include "SkMipMap.h" 10 #include "SkMipMap.h"
(...skipping 11 matching lines...) Expand all
22 //#define SK_USE_DISCARDABLE_SCALEDIMAGECACHE 22 //#define SK_USE_DISCARDABLE_SCALEDIMAGECACHE
23 23
24 #ifndef SK_DISCARDABLEMEMORY_SCALEDIMAGECACHE_COUNT_LIMIT 24 #ifndef SK_DISCARDABLEMEMORY_SCALEDIMAGECACHE_COUNT_LIMIT
25 # define SK_DISCARDABLEMEMORY_SCALEDIMAGECACHE_COUNT_LIMIT 1024 25 # define SK_DISCARDABLEMEMORY_SCALEDIMAGECACHE_COUNT_LIMIT 1024
26 #endif 26 #endif
27 27
28 #ifndef SK_DEFAULT_IMAGE_CACHE_LIMIT 28 #ifndef SK_DEFAULT_IMAGE_CACHE_LIMIT
29 #define SK_DEFAULT_IMAGE_CACHE_LIMIT (32 * 1024 * 1024) 29 #define SK_DEFAULT_IMAGE_CACHE_LIMIT (32 * 1024 * 1024)
30 #endif 30 #endif
31 31
32 void SkResourceCache::Key::init(void* nameSpace, uint64_t sharedID, size_t lengt h) { 32 void SkResourceCache::Key::init(void* nameSpace, uint64_t sharedID, size_t dataS ize) {
33 SkASSERT(SkAlign4(length) == length); 33 SkASSERT(SkAlign4(dataSize) == dataSize);
34 34
35 // fCount32 and fHash are not hashed 35 // fCount32 and fHash are not hashed
36 static const int kUnhashedLocal32s = 2; // fCache32 + fHash 36 static const int kUnhashedLocal32s = 2; // fCache32 + fHash
37 static const int kSharedIDLocal32s = 2; // fSharedID_lo + fSharedID_hi 37 static const int kSharedIDLocal32s = 2; // fSharedID_lo + fSharedID_hi
38 static const int kHashedLocal32s = kSharedIDLocal32s + (sizeof(fNamespace) > > 2); 38 static const int kHashedLocal32s = kSharedIDLocal32s + (sizeof(fNamespace) > > 2);
39 static const int kLocal32s = kUnhashedLocal32s + kHashedLocal32s; 39 static const int kLocal32s = kUnhashedLocal32s + kHashedLocal32s;
40 40
41 static_assert(sizeof(Key) == (kLocal32s << 2), "unaccounted_key_locals"); 41 static_assert(sizeof(Key) == (kLocal32s << 2), "unaccounted_key_locals");
42 static_assert(sizeof(Key) == offsetof(Key, fNamespace) + sizeof(fNamespace), 42 static_assert(sizeof(Key) == offsetof(Key, fNamespace) + sizeof(fNamespace),
43 "namespace_field_must_be_last"); 43 "namespace_field_must_be_last");
44 44
45 fCount32 = SkToS32(kLocal32s + (length >> 2)); 45 fCount32 = SkToS32(kLocal32s + (dataSize >> 2));
46 fSharedID_lo = (uint32_t)sharedID; 46 fSharedID_lo = (uint32_t)sharedID;
47 fSharedID_hi = (uint32_t)(sharedID >> 32); 47 fSharedID_hi = (uint32_t)(sharedID >> 32);
48 fNamespace = nameSpace; 48 fNamespace = nameSpace;
49 // skip unhashed fields when computing the murmur 49 // skip unhashed fields when computing the murmur
50 fHash = SkChecksum::Murmur3(this->as32() + kUnhashedLocal32s, 50 fHash = SkChecksum::Murmur3(this->as32() + kUnhashedLocal32s,
51 (fCount32 - kUnhashedLocal32s) << 2); 51 (fCount32 - kUnhashedLocal32s) << 2);
52 } 52 }
53 53
54 #include "SkTDynamicHash.h" 54 #include "SkTDynamicHash.h"
55 55
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed( )); 700 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed( ));
701 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); 701 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr);
702 } 702 }
703 } 703 }
704 704
705 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { 705 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
706 // Since resource could be backed by malloc or discardable, the cache always dumps detailed 706 // Since resource could be backed by malloc or discardable, the cache always dumps detailed
707 // stats to be accurate. 707 // stats to be accurate.
708 VisitAll(sk_trace_dump_visitor, dump); 708 VisitAll(sk_trace_dump_visitor, dump);
709 } 709 }
OLDNEW
« no previous file with comments | « src/core/SkResourceCache.h ('k') | src/ports/SkFontHost_fontconfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698