OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
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 | 10 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 * head of the list. If/when we must purge some of the entries, we walk the | 199 * head of the list. If/when we must purge some of the entries, we walk the |
200 * list backwards from the tail, since those are the least recently used. | 200 * list backwards from the tail, since those are the least recently used. |
201 * | 201 * |
202 * For fast searches, we maintain a sorted array (based on the GrResourceKey) | 202 * For fast searches, we maintain a sorted array (based on the GrResourceKey) |
203 * which we can bsearch. When a new entry is added, it is inserted into this | 203 * which we can bsearch. When a new entry is added, it is inserted into this |
204 * array. | 204 * array. |
205 * | 205 * |
206 * For even faster searches, a hash is computed from the Key. If there is | 206 * For even faster searches, a hash is computed from the Key. If there is |
207 * a collision between two keys with the same hash, we fall back on the | 207 * a collision between two keys with the same hash, we fall back on the |
208 * bsearch, and update the hash to reflect the most recent Key requested. | 208 * bsearch, and update the hash to reflect the most recent Key requested. |
| 209 * |
| 210 * It is a goal to make the GrResourceCache the central repository and bookkeep
er |
| 211 * of all resources. It should replace the linked list of GrResources that |
| 212 * GrGpu uses to call abandon/release. |
209 */ | 213 */ |
210 class GrResourceCache { | 214 class GrResourceCache { |
211 public: | 215 public: |
212 GrResourceCache(int maxCount, size_t maxBytes); | 216 GrResourceCache(int maxCount, size_t maxBytes); |
213 ~GrResourceCache(); | 217 ~GrResourceCache(); |
214 | 218 |
215 /** | 219 /** |
216 * Return the current resource cache limits. | 220 * Return the current resource cache limits. |
217 * | 221 * |
218 * @param maxResource If non-null, returns maximum number of resources | 222 * @param maxResource If non-null, returns maximum number of resources |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 GrResourceCache* fCache; | 382 GrResourceCache* fCache; |
379 }; | 383 }; |
380 #else | 384 #else |
381 class GrAutoResourceCacheValidate { | 385 class GrAutoResourceCacheValidate { |
382 public: | 386 public: |
383 GrAutoResourceCacheValidate(GrResourceCache*) {} | 387 GrAutoResourceCacheValidate(GrResourceCache*) {} |
384 }; | 388 }; |
385 #endif | 389 #endif |
386 | 390 |
387 #endif | 391 #endif |
OLD | NEW |