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 "SkDiscardableMemory.h" | 8 #include "SkDiscardableMemory.h" |
9 #include "SkDiscardableMemoryPool.h" | 9 #include "SkDiscardableMemoryPool.h" |
10 #include "SkImageGenerator.h" | 10 #include "SkImageGenerator.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 * pool works. | 25 * pool works. |
26 */ | 26 */ |
27 class DiscardableMemoryPool : public SkDiscardableMemoryPool { | 27 class DiscardableMemoryPool : public SkDiscardableMemoryPool { |
28 public: | 28 public: |
29 /** | 29 /** |
30 * Without mutex, will be not be thread safe. | 30 * Without mutex, will be not be thread safe. |
31 */ | 31 */ |
32 DiscardableMemoryPool(size_t budget, SkBaseMutex* mutex = NULL); | 32 DiscardableMemoryPool(size_t budget, SkBaseMutex* mutex = NULL); |
33 virtual ~DiscardableMemoryPool(); | 33 virtual ~DiscardableMemoryPool(); |
34 | 34 |
35 SkDiscardableMemory* create(size_t bytes) SK_OVERRIDE; | 35 SkDiscardableMemory* create(size_t bytes) override; |
36 | 36 |
37 size_t getRAMUsed() SK_OVERRIDE; | 37 size_t getRAMUsed() override; |
38 void setRAMBudget(size_t budget) SK_OVERRIDE; | 38 void setRAMBudget(size_t budget) override; |
39 size_t getRAMBudget() SK_OVERRIDE { return fBudget; } | 39 size_t getRAMBudget() override { return fBudget; } |
40 | 40 |
41 /** purges all unlocked DMs */ | 41 /** purges all unlocked DMs */ |
42 void dumpPool() SK_OVERRIDE; | 42 void dumpPool() override; |
43 | 43 |
44 #if SK_LAZY_CACHE_STATS // Defined in SkDiscardableMemoryPool.h | 44 #if SK_LAZY_CACHE_STATS // Defined in SkDiscardableMemoryPool.h |
45 int getCacheHits() SK_OVERRIDE { return fCacheHits; } | 45 int getCacheHits() override { return fCacheHits; } |
46 int getCacheMisses() SK_OVERRIDE { return fCacheMisses; } | 46 int getCacheMisses() override { return fCacheMisses; } |
47 void resetCacheHitsAndMisses() SK_OVERRIDE { | 47 void resetCacheHitsAndMisses() override { |
48 fCacheHits = fCacheMisses = 0; | 48 fCacheHits = fCacheMisses = 0; |
49 } | 49 } |
50 int fCacheHits; | 50 int fCacheHits; |
51 int fCacheMisses; | 51 int fCacheMisses; |
52 #endif // SK_LAZY_CACHE_STATS | 52 #endif // SK_LAZY_CACHE_STATS |
53 | 53 |
54 private: | 54 private: |
55 SkBaseMutex* fMutex; | 55 SkBaseMutex* fMutex; |
56 size_t fBudget; | 56 size_t fBudget; |
57 size_t fUsed; | 57 size_t fUsed; |
(...skipping 15 matching lines...) Expand all Loading... |
73 | 73 |
74 /** | 74 /** |
75 * A PoolDiscardableMemory is a SkDiscardableMemory that relies on | 75 * A PoolDiscardableMemory is a SkDiscardableMemory that relies on |
76 * a DiscardableMemoryPool object to manage the memory. | 76 * a DiscardableMemoryPool object to manage the memory. |
77 */ | 77 */ |
78 class PoolDiscardableMemory : public SkDiscardableMemory { | 78 class PoolDiscardableMemory : public SkDiscardableMemory { |
79 public: | 79 public: |
80 PoolDiscardableMemory(DiscardableMemoryPool* pool, | 80 PoolDiscardableMemory(DiscardableMemoryPool* pool, |
81 void* pointer, size_t bytes); | 81 void* pointer, size_t bytes); |
82 virtual ~PoolDiscardableMemory(); | 82 virtual ~PoolDiscardableMemory(); |
83 bool lock() SK_OVERRIDE; | 83 bool lock() override; |
84 void* data() SK_OVERRIDE; | 84 void* data() override; |
85 void unlock() SK_OVERRIDE; | 85 void unlock() override; |
86 friend class DiscardableMemoryPool; | 86 friend class DiscardableMemoryPool; |
87 private: | 87 private: |
88 SK_DECLARE_INTERNAL_LLIST_INTERFACE(PoolDiscardableMemory); | 88 SK_DECLARE_INTERNAL_LLIST_INTERFACE(PoolDiscardableMemory); |
89 DiscardableMemoryPool* const fPool; | 89 DiscardableMemoryPool* const fPool; |
90 bool fLocked; | 90 bool fLocked; |
91 void* fPointer; | 91 void* fPointer; |
92 const size_t fBytes; | 92 const size_t fBytes; |
93 }; | 93 }; |
94 | 94 |
95 PoolDiscardableMemory::PoolDiscardableMemory(DiscardableMemoryPool* pool, | 95 PoolDiscardableMemory::PoolDiscardableMemory(DiscardableMemoryPool* pool, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 return SkNEW_ARGS(DiscardableMemoryPool, (size, mutex)); | 260 return SkNEW_ARGS(DiscardableMemoryPool, (size, mutex)); |
261 } | 261 } |
262 | 262 |
263 SK_DECLARE_STATIC_LAZY_PTR(SkDiscardableMemoryPool, global, create_global_pool); | 263 SK_DECLARE_STATIC_LAZY_PTR(SkDiscardableMemoryPool, global, create_global_pool); |
264 | 264 |
265 SkDiscardableMemoryPool* SkGetGlobalDiscardableMemoryPool() { | 265 SkDiscardableMemoryPool* SkGetGlobalDiscardableMemoryPool() { |
266 return global.get(); | 266 return global.get(); |
267 } | 267 } |
268 | 268 |
269 //////////////////////////////////////////////////////////////////////////////// | 269 //////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |