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

Side by Side Diff: src/lazy/SkDiscardableMemoryPool.h

Issue 228613003: Move SkDecodingImageGenerator.h to include/ (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkDiscardableMemoryPool_DEFINED
9 #define SkDiscardableMemoryPool_DEFINED
10
11 #include "SkDiscardableMemory.h"
12
13 #ifndef SK_LAZY_CACHE_STATS
14 #ifdef SK_DEBUG
15 #define SK_LAZY_CACHE_STATS 1
16 #else
17 #define SK_LAZY_CACHE_STATS 0
18 #endif
19 #endif
20
21 /**
22 * An implementation of Discardable Memory that manages a fixed-size
23 * budget of memory. When the allocated memory exceeds this size,
24 * unlocked blocks of memory are purged. If all memory is locked, it
25 * can exceed the memory-use budget.
26 */
27 class SkDiscardableMemoryPool : public SkDiscardableMemory::Factory {
28 public:
29 virtual ~SkDiscardableMemoryPool() { }
30
31 virtual size_t getRAMUsed() = 0;
32 virtual void setRAMBudget(size_t budget) = 0;
33 virtual size_t getRAMBudget() = 0;
34
35 /** purges all unlocked DMs */
36 virtual void dumpPool() = 0;
37
38 #if SK_LAZY_CACHE_STATS
39 /**
40 * These two values are a count of the number of successful and
41 * failed calls to SkDiscardableMemory::lock() for all DMs managed
42 * by this pool.
43 */
44 virtual int getCacheHits() = 0;
45 virtual int getCacheMisses() = 0;
46 virtual void resetCacheHitsAndMisses() = 0;
47 #endif
48
49 /**
50 * This non-global pool can be used for unit tests to verify that
51 * the pool works.
52 * Without mutex, will be not be thread safe.
53 */
54 static SkDiscardableMemoryPool* Create(
55 size_t size, SkBaseMutex* mutex = NULL);
56 };
57
58 /**
59 * Returns (and creates if needed) a threadsafe global
60 * SkDiscardableMemoryPool.
61 */
62 SkDiscardableMemoryPool* SkGetGlobalDiscardableMemoryPool();
63
64 #if !defined(SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE)
65 #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (128 * 1024 * 1024)
66 #endif
67
68 #endif // SkDiscardableMemoryPool_DEFINED
OLDNEW
« include/lazy/SkDiscardableMemoryPool.h ('K') | « src/images/SkDecodingImageGenerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698