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

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

Issue 18466005: Allow the resource cache to (indirectly) flush the InOrderDrawBuffer (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Addressed code review issues 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 * of these, it will be purged (LRU) to keep the cache within these limits. 231 * of these, it will be purged (LRU) to keep the cache within these limits.
232 * 232 *
233 * @param maxResources The maximum number of resources that can be held in 233 * @param maxResources The maximum number of resources that can be held in
234 * the cache. 234 * the cache.
235 * @param maxBytes The maximum number of bytes of resource memory that 235 * @param maxBytes The maximum number of bytes of resource memory that
236 * can be held in the cache. 236 * can be held in the cache.
237 */ 237 */
238 void setLimits(int maxResource, size_t maxResourceBytes); 238 void setLimits(int maxResource, size_t maxResourceBytes);
239 239
240 /** 240 /**
241 * The callback function used by the cache when it is still over budget
242 * after a purge. The passed in 'data' is the same 'data' handed to
243 * setOverbudgetCallback. The callback returns true if some resources
244 * have been freed.
245 */
246 typedef bool (*PFOverbudgetCB)(void* data);
247
248 /**
249 * Set the callback the cache should use when it is still over budget
250 * after a purge. The 'data' provided here will be passed back to the
251 * callback. The cache will attempt to purge any resources newly freed
252 * by the callback.
253 */
254 void setOverbudgetCallback(PFOverbudgetCB overbudgetCB, void* data) {
255 fOverbudgetCB = overbudgetCB;
256 fOverbudgetData = data;
257 }
258
259 /**
241 * Returns the number of bytes consumed by cached resources. 260 * Returns the number of bytes consumed by cached resources.
242 */ 261 */
243 size_t getCachedResourceBytes() const { return fEntryBytes; } 262 size_t getCachedResourceBytes() const { return fEntryBytes; }
244 263
245 // For a found or added resource to be completely exclusive to the caller 264 // For a found or added resource to be completely exclusive to the caller
246 // both the kNoOtherOwners and kHide flags need to be specified 265 // both the kNoOtherOwners and kHide flags need to be specified
247 enum OwnershipFlags { 266 enum OwnershipFlags {
248 kNoOtherOwners_OwnershipFlag = 0x1, // found/added resource has no other owners 267 kNoOtherOwners_OwnershipFlag = 0x1, // found/added resource has no other owners
249 kHide_OwnershipFlag = 0x2 // found/added resource is hidden from future 'find's 268 kHide_OwnershipFlag = 0x2 // found/added resource is hidden from future 'find's
250 }; 269 };
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 int fHighWaterClientDetachedCount; 372 int fHighWaterClientDetachedCount;
354 size_t fHighWaterClientDetachedBytes; 373 size_t fHighWaterClientDetachedBytes;
355 #endif 374 #endif
356 375
357 int fEntryCount; 376 int fEntryCount;
358 size_t fEntryBytes; 377 size_t fEntryBytes;
359 int fClientDetachedCount; 378 int fClientDetachedCount;
360 size_t fClientDetachedBytes; 379 size_t fClientDetachedBytes;
361 380
362 // prevents recursive purging 381 // prevents recursive purging
363 bool fPurging; 382 bool fPurging;
383
384 PFOverbudgetCB fOverbudgetCB;
385 void* fOverbudgetData;
386
387 void internalPurge();
364 388
365 #if GR_DEBUG 389 #if GR_DEBUG
366 static size_t countBytes(const SkTInternalLList<GrResourceEntry>& list); 390 static size_t countBytes(const SkTInternalLList<GrResourceEntry>& list);
367 #endif 391 #endif
368 }; 392 };
369 393
370 /////////////////////////////////////////////////////////////////////////////// 394 ///////////////////////////////////////////////////////////////////////////////
371 395
372 #if GR_DEBUG 396 #if GR_DEBUG
373 class GrAutoResourceCacheValidate { 397 class GrAutoResourceCacheValidate {
374 public: 398 public:
375 GrAutoResourceCacheValidate(GrResourceCache* cache) : fCache(cache) { 399 GrAutoResourceCacheValidate(GrResourceCache* cache) : fCache(cache) {
376 cache->validate(); 400 cache->validate();
377 } 401 }
378 ~GrAutoResourceCacheValidate() { 402 ~GrAutoResourceCacheValidate() {
379 fCache->validate(); 403 fCache->validate();
380 } 404 }
381 private: 405 private:
382 GrResourceCache* fCache; 406 GrResourceCache* fCache;
383 }; 407 };
384 #else 408 #else
385 class GrAutoResourceCacheValidate { 409 class GrAutoResourceCacheValidate {
386 public: 410 public:
387 GrAutoResourceCacheValidate(GrResourceCache*) {} 411 GrAutoResourceCacheValidate(GrResourceCache*) {}
388 }; 412 };
389 #endif 413 #endif
390 414
391 #endif 415 #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