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 #ifndef SkImageCache_DEFINED | 8 #ifndef SkImageCache_DEFINED |
9 #define SkImageCache_DEFINED | 9 #define SkImageCache_DEFINED |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 * @return Pointer to the newly allocated memory, or NULL. This memory is s
afe to use until | 27 * @return Pointer to the newly allocated memory, or NULL. This memory is s
afe to use until |
28 * releaseCache is called with ID. | 28 * releaseCache is called with ID. |
29 */ | 29 */ |
30 virtual void* allocAndPinCache(size_t bytes, intptr_t* ID) = 0; | 30 virtual void* allocAndPinCache(size_t bytes, intptr_t* ID) = 0; |
31 | 31 |
32 /** | 32 /** |
33 * Re-request the memory associated with ID. | 33 * Re-request the memory associated with ID. |
34 * @param ID Unique ID for the memory block. | 34 * @param ID Unique ID for the memory block. |
35 * @return Pointer: If non-NULL, points to the previously allocated memory,
in which case | 35 * @return Pointer: If non-NULL, points to the previously allocated memory,
in which case |
36 * this call must be balanced with a call to releaseCache. If NULL,
the memory | 36 * this call must be balanced with a call to releaseCache. If NULL,
the memory |
37 * has been reclaimed, so allocAndPinCache must be called again, an
d ID is no | 37 * has been reclaimed, so allocAndPinCache must be called again wit
h a pointer to |
38 * longer valid (thus throwAwayCache need not be called). | 38 * the same ID. |
39 */ | 39 */ |
40 virtual void* pinCache(intptr_t ID) = 0; | 40 virtual void* pinCache(intptr_t ID) = 0; |
41 | 41 |
42 /** | 42 /** |
43 * Inform the cache that it is safe to free the block of memory correspondi
ng to ID. After | 43 * Inform the cache that it is safe to free the block of memory correspondi
ng to ID. After |
44 * calling this function, the pointer returnted by allocAndPinCache or pinC
ache must not be | 44 * calling this function, the pointer returned by allocAndPinCache or pinCa
che must not be |
45 * used again. In order to access the same memory after this, pinCache must
be called. | 45 * used again. In order to access the same memory after this, pinCache must
be called with |
| 46 * the same ID. |
46 * @param ID Unique ID for the memory block which is now safe to age out of
the cache. | 47 * @param ID Unique ID for the memory block which is now safe to age out of
the cache. |
47 */ | 48 */ |
48 virtual void releaseCache(intptr_t ID) = 0; | 49 virtual void releaseCache(intptr_t ID) = 0; |
49 | 50 |
50 /** | 51 /** |
51 * Inform the cache that the block of memory associated with ID will not be
asked for again. | 52 * Inform the cache that the block of memory associated with ID will not be
asked for again. |
52 * After this call, ID is no longer valid. Must not be called while the ass
ociated memory is | 53 * After this call, ID is no longer valid. Must not be called while the ass
ociated memory is |
53 * pinned. Must be called to balance a successful allocAndPinCache, unless
a later pinCache | 54 * pinned. Must be called to balance a successful allocAndPinCache. |
54 * returns NULL. | |
55 */ | 55 */ |
56 virtual void throwAwayCache(intptr_t ID) = 0; | 56 virtual void throwAwayCache(intptr_t ID) = 0; |
57 | 57 |
58 /** | 58 /** |
59 * ID which does not correspond to any valid cache. | 59 * ID which does not correspond to any valid cache. |
60 */ | 60 */ |
61 static const intptr_t UNINITIALIZED_ID = 0; | 61 static const intptr_t UNINITIALIZED_ID = 0; |
62 | 62 |
63 #ifdef SK_DEBUG | 63 #ifdef SK_DEBUG |
64 enum CacheStatus { | 64 enum CacheStatus { |
65 kPinned_CacheStatus, | 65 kPinned_CacheStatus, |
66 kUnpinned_CacheStatus, | 66 kUnpinned_CacheStatus, |
67 kThrownAway_CacheStatus, | 67 kThrownAway_CacheStatus, |
68 }; | 68 }; |
69 | 69 |
70 /** | 70 /** |
71 * Debug only function to get the status of a particular block of memory. | 71 * Debug only function to get the status of a particular block of memory. |
72 */ | 72 */ |
73 virtual CacheStatus getCacheStatus(intptr_t ID) const = 0; | 73 virtual CacheStatus getCacheStatus(intptr_t ID) const = 0; |
74 #endif | 74 #endif |
75 }; | 75 }; |
76 #endif // SkImageCache_DEFINED | 76 #endif // SkImageCache_DEFINED |
OLD | NEW |