OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkGraphics_DEFINED | 10 #ifndef SkGraphics_DEFINED |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 */ | 79 */ |
80 static void PurgeFontCache(); | 80 static void PurgeFontCache(); |
81 | 81 |
82 /** | 82 /** |
83 * Scaling bitmaps with the SkPaint::kHigh_FilterLevel setting is | 83 * Scaling bitmaps with the SkPaint::kHigh_FilterLevel setting is |
84 * expensive, so the result is saved in the global Scaled Image | 84 * expensive, so the result is saved in the global Scaled Image |
85 * Cache. | 85 * Cache. |
86 * | 86 * |
87 * This function returns the memory usage of the Scaled Image Cache. | 87 * This function returns the memory usage of the Scaled Image Cache. |
88 */ | 88 */ |
89 static size_t GetImageCacheTotalBytesUsed(); | 89 static size_t GetResourceCacheTotalBytesUsed(); |
| 90 |
90 /** | 91 /** |
91 * These functions get/set the memory usage limit for the Scaled | 92 * These functions get/set the memory usage limit for the resource cache, u
sed for temporary |
92 * Image Cache. Bitmaps are purged from the cache when the | 93 * bitmaps and other resources. Entries are purged from the cache when the
memory useage |
93 * memory useage exceeds this limit. | 94 * exceeds this limit. |
94 */ | 95 */ |
95 static size_t GetImageCacheTotalByteLimit(); | 96 static size_t GetResourceCacheTotalByteLimit(); |
96 static size_t SetImageCacheTotalByteLimit(size_t newLimit); | 97 static size_t SetResourceCacheTotalByteLimit(size_t newLimit); |
97 | 98 |
98 // DEPRECATED | 99 /** |
| 100 * When the cachable entry is very lage (e.g. a large scaled bitmap), addin
g it to the cache |
| 101 * can cause most/all of the existing entries to be purged. To avoid the, t
he client can set |
| 102 * a limit for a single allocation. If a cacheable entry would have been ca
ched, but its size |
| 103 * exceeds this limit, then we do not attempt to cache it at all. |
| 104 * |
| 105 * Zero is the default value, meaning we always attempt to cache entries. |
| 106 */ |
| 107 static size_t GetResourceCacheSingleAllocationByteLimit(); |
| 108 static size_t SetResourceCacheSingleAllocationByteLimit(size_t newLimit); |
| 109 |
| 110 #ifdef SK_SUPPORT_LEGACY_IMAGECACHE_NAME |
99 static size_t GetImageCacheBytesUsed() { | 111 static size_t GetImageCacheBytesUsed() { |
100 return GetImageCacheTotalBytesUsed(); | 112 return GetImageCacheTotalBytesUsed(); |
101 } | 113 } |
102 // DEPRECATED | |
103 static size_t GetImageCacheByteLimit() { | 114 static size_t GetImageCacheByteLimit() { |
104 return GetImageCacheTotalByteLimit(); | 115 return GetImageCacheTotalByteLimit(); |
105 } | 116 } |
106 // DEPRECATED | |
107 static size_t SetImageCacheByteLimit(size_t newLimit) { | 117 static size_t SetImageCacheByteLimit(size_t newLimit) { |
108 return SetImageCacheTotalByteLimit(newLimit); | 118 return SetImageCacheTotalByteLimit(newLimit); |
109 } | 119 } |
110 | 120 static size_t GetImageCacheTotalBytesUsed() { |
111 /** | 121 return GetResourceCacheTotalBytesUsed(); |
112 * Scaling bitmaps with the SkPaint::kHigh_FilterLevel setting is | 122 } |
113 * expensive, so the result is saved in the global Scaled Image | 123 static size_t GetImageCacheTotalByteLimit() { |
114 * Cache. When the resulting bitmap is too large, this can | 124 return GetResourceCacheTotalByteLimit(); |
115 * overload the cache. If the ImageCacheSingleAllocationByteLimit | 125 } |
116 * is set to a non-zero number, and the resulting bitmap would be | 126 static size_t SetImageCacheTotalByteLimit(size_t newLimit) { |
117 * larger than that value, the bitmap scaling algorithm falls | 127 return SetResourceCacheTotalByteLimit(newLimit); |
118 * back onto a cheaper algorithm and does not cache the result. | 128 } |
119 * Zero is the default value. | 129 static size_t GetImageCacheSingleAllocationByteLimit() { |
120 */ | 130 return GetResourceCacheSingleAllocationByteLimit(); |
121 static size_t GetImageCacheSingleAllocationByteLimit(); | 131 } |
122 static size_t SetImageCacheSingleAllocationByteLimit(size_t newLimit); | 132 static size_t SetImageCacheSingleAllocationByteLimit(size_t newLimit) { |
| 133 return SetResourceCacheSingleAllocationByteLimit(newLimit); |
| 134 } |
| 135 #endif |
123 | 136 |
124 /** | 137 /** |
125 * Applications with command line options may pass optional state, such | 138 * Applications with command line options may pass optional state, such |
126 * as cache sizes, here, for instance: | 139 * as cache sizes, here, for instance: |
127 * font-cache-limit=12345678 | 140 * font-cache-limit=12345678 |
128 * | 141 * |
129 * The flags format is name=value[;name=value...] with no spaces. | 142 * The flags format is name=value[;name=value...] with no spaces. |
130 * This format is subject to change. | 143 * This format is subject to change. |
131 */ | 144 */ |
132 static void SetFlags(const char* flags); | 145 static void SetFlags(const char* flags); |
(...skipping 30 matching lines...) Expand all Loading... |
163 public: | 176 public: |
164 SkAutoGraphics() { | 177 SkAutoGraphics() { |
165 SkGraphics::Init(); | 178 SkGraphics::Init(); |
166 } | 179 } |
167 ~SkAutoGraphics() { | 180 ~SkAutoGraphics() { |
168 SkGraphics::Term(); | 181 SkGraphics::Term(); |
169 } | 182 } |
170 }; | 183 }; |
171 | 184 |
172 #endif | 185 #endif |
OLD | NEW |