| OLD | NEW |
| 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" |
| 11 #include "SkMutex.h" | 11 #include "SkMutex.h" |
| 12 #include "SkPixelRef.h" | 12 #include "SkPixelRef.h" |
| 13 #include "SkResourceCache.h" | 13 #include "SkResourceCache.h" |
| 14 #include "SkTraceMemoryDump.h" | 14 #include "SkTraceMemoryDump.h" |
| 15 | 15 |
| 16 #include <stddef.h> | 16 #include <stddef.h> |
| 17 #include <stdlib.h> | 17 #include <stdlib.h> |
| 18 | 18 |
| 19 DECLARE_SKMESSAGEBUS_MESSAGE(SkResourceCache::PurgeSharedIDMessage) | 19 DECLARE_SKMESSAGEBUS_MESSAGE(SkResourceCache::PurgeSharedIDMessage) |
| 20 | 20 |
| 21 // This can be defined by the caller's build system | 21 // This can be defined by the caller's build system |
| 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 (2 * 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 lengt
h) { |
| 33 SkASSERT(SkAlign4(length) == length); | 33 SkASSERT(SkAlign4(length) == length); |
| 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; |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 dump->setDiscardableMemoryBacking(dump_name.c_str(), *discardable); | 681 dump->setDiscardableMemoryBacking(dump_name.c_str(), *discardable); |
| 682 } else { | 682 } else { |
| 683 dump->dumpNumericValue(dump_name.c_str(), "size", "bytes", rec.bytesUsed
()); | 683 dump->dumpNumericValue(dump_name.c_str(), "size", "bytes", rec.bytesUsed
()); |
| 684 dump->setMemoryBacking(dump_name.c_str(), "malloc", nullptr); | 684 dump->setMemoryBacking(dump_name.c_str(), "malloc", nullptr); |
| 685 } | 685 } |
| 686 } | 686 } |
| 687 | 687 |
| 688 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { | 688 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { |
| 689 VisitAll(sk_trace_dump_visitor, dump); | 689 VisitAll(sk_trace_dump_visitor, dump); |
| 690 } | 690 } |
| OLD | NEW |