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

Side by Side Diff: src/gpu/GrResourceCache.h

Issue 19591003: Add purgeAsNeeded calls before addResource calls (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: added extraCount & extraSize to account for future memory requirements Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 319
320 /** 320 /**
321 * Removes every resource in the cache that isn't locked. 321 * Removes every resource in the cache that isn't locked.
322 */ 322 */
323 void purgeAllUnlocked(); 323 void purgeAllUnlocked();
324 324
325 /** 325 /**
326 * Allow cache to purge unused resources to obey resource limitations 326 * Allow cache to purge unused resources to obey resource limitations
327 * Note: this entry point will be hidden (again) once totally ref-driven 327 * Note: this entry point will be hidden (again) once totally ref-driven
328 * cache maintenance is implemented 328 * cache maintenance is implemented
329 *
330 * extraCount and extraBytes are added to the current resource allocation
331 * to make sure enough room is available for future additions (e.g,
332 * 10MB across 10 textures is about to be added).
329 */ 333 */
330 void purgeAsNeeded(); 334 void purgeAsNeeded(int extraCount = 0, size_t extraBytes = 0);
331 335
332 #if GR_DEBUG 336 #if GR_DEBUG
333 void validate() const; 337 void validate() const;
334 #else 338 #else
335 void validate() const {} 339 void validate() const {}
336 #endif 340 #endif
337 341
338 #if GR_CACHE_STATS 342 #if GR_CACHE_STATS
339 void printStats(); 343 void printStats();
340 #endif 344 #endif
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 size_t fEntryBytes; 381 size_t fEntryBytes;
378 int fClientDetachedCount; 382 int fClientDetachedCount;
379 size_t fClientDetachedBytes; 383 size_t fClientDetachedBytes;
380 384
381 // prevents recursive purging 385 // prevents recursive purging
382 bool fPurging; 386 bool fPurging;
383 387
384 PFOverbudgetCB fOverbudgetCB; 388 PFOverbudgetCB fOverbudgetCB;
385 void* fOverbudgetData; 389 void* fOverbudgetData;
386 390
387 void internalPurge(); 391 void internalPurge(int extraCount, size_t extraBytes);
388 392
389 #if GR_DEBUG 393 #if GR_DEBUG
390 static size_t countBytes(const SkTInternalLList<GrResourceEntry>& list); 394 static size_t countBytes(const SkTInternalLList<GrResourceEntry>& list);
391 #endif 395 #endif
392 }; 396 };
393 397
394 /////////////////////////////////////////////////////////////////////////////// 398 ///////////////////////////////////////////////////////////////////////////////
395 399
396 #if GR_DEBUG 400 #if GR_DEBUG
397 class GrAutoResourceCacheValidate { 401 class GrAutoResourceCacheValidate {
398 public: 402 public:
399 GrAutoResourceCacheValidate(GrResourceCache* cache) : fCache(cache) { 403 GrAutoResourceCacheValidate(GrResourceCache* cache) : fCache(cache) {
400 cache->validate(); 404 cache->validate();
401 } 405 }
402 ~GrAutoResourceCacheValidate() { 406 ~GrAutoResourceCacheValidate() {
403 fCache->validate(); 407 fCache->validate();
404 } 408 }
405 private: 409 private:
406 GrResourceCache* fCache; 410 GrResourceCache* fCache;
407 }; 411 };
408 #else 412 #else
409 class GrAutoResourceCacheValidate { 413 class GrAutoResourceCacheValidate {
410 public: 414 public:
411 GrAutoResourceCacheValidate(GrResourceCache*) {} 415 GrAutoResourceCacheValidate(GrResourceCache*) {}
412 }; 416 };
413 #endif 417 #endif
414 418
415 #endif 419 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698