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

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

Issue 2307053002: Restructure flushing relationship between GrContext, GrDrawingManager, and GrResourceCache. (Closed)
Patch Set: Fix uninit vars Created 4 years, 3 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
« no previous file with comments | « src/gpu/GrDrawingManager.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 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 GrResourceCache_DEFINED 8 #ifndef GrResourceCache_DEFINED
9 #define GrResourceCache_DEFINED 9 #define GrResourceCache_DEFINED
10 10
11 #include "GrGpuResource.h" 11 #include "GrGpuResource.h"
12 #include "GrGpuResourceCacheAccess.h" 12 #include "GrGpuResourceCacheAccess.h"
13 #include "GrGpuResourcePriv.h" 13 #include "GrGpuResourcePriv.h"
14 #include "GrResourceCache.h"
14 #include "GrResourceKey.h" 15 #include "GrResourceKey.h"
15 #include "SkMessageBus.h" 16 #include "SkMessageBus.h"
16 #include "SkRefCnt.h" 17 #include "SkRefCnt.h"
17 #include "SkTArray.h" 18 #include "SkTArray.h"
18 #include "SkTDPQueue.h" 19 #include "SkTDPQueue.h"
19 #include "SkTInternalLList.h" 20 #include "SkTInternalLList.h"
20 #include "SkTMultiMap.h" 21 #include "SkTMultiMap.h"
21 22
22 class GrCaps; 23 class GrCaps;
23 class SkString; 24 class SkString;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return SkToBool(fUniqueHash.find(key)); 157 return SkToBool(fUniqueHash.find(key));
157 } 158 }
158 159
159 /** Purges resources to become under budget and processes resources with inv alidated unique 160 /** Purges resources to become under budget and processes resources with inv alidated unique
160 keys. */ 161 keys. */
161 void purgeAsNeeded(); 162 void purgeAsNeeded();
162 163
163 /** Purges all resources that don't have external owners. */ 164 /** Purges all resources that don't have external owners. */
164 void purgeAllUnlocked(); 165 void purgeAllUnlocked();
165 166
166 /** 167 /** Returns true if the cache would like a flush to occur in order to make m ore resources
167 * The callback function used by the cache when it is still over budget afte r a purge. The 168 purgeable. */
168 * passed in 'data' is the same 'data' handed to setOverbudgetCallback. 169 bool requestsFlush() const { return fRequestFlush; }
169 */
170 typedef void (*PFOverBudgetCB)(void* data);
171 170
172 /** 171 enum FlushType {
173 * Set the callback the cache should use when it is still over budget after a purge. The 'data' 172 kExternal,
174 * provided here will be passed back to the callback. Note that the cache wi ll attempt to purge 173 kImmediateMode,
175 * any resources newly freed by the callback. 174 kCacheRequested,
176 */ 175 };
177 void setOverBudgetCallback(PFOverBudgetCB overBudgetCB, void* data) { 176 void notifyFlushOccurred(FlushType);
178 fOverBudgetCB = overBudgetCB;
179 fOverBudgetData = data;
180 }
181
182 void notifyFlushOccurred();
183 177
184 #if GR_CACHE_STATS 178 #if GR_CACHE_STATS
185 struct Stats { 179 struct Stats {
186 int fTotal; 180 int fTotal;
187 int fNumPurgeable; 181 int fNumPurgeable;
188 int fNumNonPurgeable; 182 int fNumNonPurgeable;
189 183
190 int fScratch; 184 int fScratch;
191 int fWrapped; 185 int fWrapped;
192 size_t fUnbudgetedSize; 186 size_t fUnbudgetedSize;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 #endif 313 #endif
320 314
321 // our current stats for all resources 315 // our current stats for all resources
322 SkDEBUGCODE(int fCount;) 316 SkDEBUGCODE(int fCount;)
323 size_t fBytes; 317 size_t fBytes;
324 318
325 // our current stats for resources that count against the budget 319 // our current stats for resources that count against the budget
326 int fBudgetedCount; 320 int fBudgetedCount;
327 size_t fBudgetedBytes; 321 size_t fBudgetedBytes;
328 322
329 PFOverBudgetCB fOverBudgetCB; 323 bool fRequestFlush;
330 void* fOverBudgetData;
331 324
332 // We keep track of the "timestamps" of the last n flushes. If a resource ha sn't been used in 325 // We keep track of the "timestamps" of the last n flushes. If a resource ha sn't been used in
333 // that time then we well preemptively purge it to reduce memory usage. 326 // that time then we well preemptively purge it to reduce memory usage.
334 uint32_t* fFlushTimestamps; 327 uint32_t* fFlushTimestamps;
335 int fLastFlushTimestampIndex; 328 int fLastFlushTimestampIndex;
336 329
337 InvalidUniqueKeyInbox fInvalidUniqueKeyInbox; 330 InvalidUniqueKeyInbox fInvalidUniqueKeyInbox;
338 331
339 // This resource is allowed to be in the nonpurgeable array for the sake of validate() because 332 // This resource is allowed to be in the nonpurgeable array for the sake of validate() because
340 // we're in the midst of converting it to purgeable status. 333 // we're in the midst of converting it to purgeable status.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 413
421 friend class GrGpuResource; // To access all the proxy inline methods. 414 friend class GrGpuResource; // To access all the proxy inline methods.
422 friend class GrResourceCache; // To create this type. 415 friend class GrResourceCache; // To create this type.
423 }; 416 };
424 417
425 inline GrResourceCache::ResourceAccess GrResourceCache::resourceAccess() { 418 inline GrResourceCache::ResourceAccess GrResourceCache::resourceAccess() {
426 return ResourceAccess(this); 419 return ResourceAccess(this);
427 } 420 }
428 421
429 #endif 422 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawingManager.cpp ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698