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

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

Issue 1286203002: Defer flushes if kPreferNoIO is specified (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use explicit size in test Created 5 years, 4 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/GrGpu.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 2014 Google Inc. 3 * Copyright 2014 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 #ifndef GrResourceCache_DEFINED 9 #ifndef GrResourceCache_DEFINED
10 #define GrResourceCache_DEFINED 10 #define GrResourceCache_DEFINED
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 enum { 119 enum {
120 /** Preferentially returns scratch resources with no pending IO. */ 120 /** Preferentially returns scratch resources with no pending IO. */
121 kPreferNoPendingIO_ScratchFlag = 0x1, 121 kPreferNoPendingIO_ScratchFlag = 0x1,
122 /** Will not return any resources that match but have pending IO. */ 122 /** Will not return any resources that match but have pending IO. */
123 kRequireNoPendingIO_ScratchFlag = 0x2, 123 kRequireNoPendingIO_ScratchFlag = 0x2,
124 }; 124 };
125 125
126 /** 126 /**
127 * Find a resource that matches a scratch key. 127 * Find a resource that matches a scratch key.
128 */ 128 */
129 GrGpuResource* findAndRefScratchResource(const GrScratchKey& scratchKey, uin t32_t flags = 0); 129 GrGpuResource* findAndRefScratchResource(const GrScratchKey& scratchKey,
130 size_t resourceSize,
131 uint32_t flags);
130 132
131 #ifdef SK_DEBUG 133 #ifdef SK_DEBUG
132 // This is not particularly fast and only used for validation, so debug only . 134 // This is not particularly fast and only used for validation, so debug only .
133 int countScratchEntriesForKey(const GrScratchKey& scratchKey) const { 135 int countScratchEntriesForKey(const GrScratchKey& scratchKey) const {
134 return fScratchMap.countForKey(scratchKey); 136 return fScratchMap.countForKey(scratchKey);
135 } 137 }
136 #endif 138 #endif
137 139
138 /** 140 /**
139 * Find a resource that matches a unique key. 141 * Find a resource that matches a unique key.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void didChangeBudgetStatus(GrGpuResource*); 201 void didChangeBudgetStatus(GrGpuResource*);
200 void refAndMakeResourceMRU(GrGpuResource*); 202 void refAndMakeResourceMRU(GrGpuResource*);
201 /// @} 203 /// @}
202 204
203 void resetFlushTimestamps(); 205 void resetFlushTimestamps();
204 void processInvalidUniqueKeys(const SkTArray<GrUniqueKeyInvalidatedMessage>& ); 206 void processInvalidUniqueKeys(const SkTArray<GrUniqueKeyInvalidatedMessage>& );
205 void addToNonpurgeableArray(GrGpuResource*); 207 void addToNonpurgeableArray(GrGpuResource*);
206 void removeFromNonpurgeableArray(GrGpuResource*); 208 void removeFromNonpurgeableArray(GrGpuResource*);
207 bool overBudget() const { return fBudgetedBytes > fMaxBytes || fBudgetedCoun t > fMaxCount; } 209 bool overBudget() const { return fBudgetedBytes > fMaxBytes || fBudgetedCoun t > fMaxCount; }
208 210
211 bool wouldFit(size_t bytes) {
212 return fBudgetedBytes+bytes <= fMaxBytes && fBudgetedCount+1 <= fMaxCoun t;
213 }
214
209 uint32_t getNextTimestamp(); 215 uint32_t getNextTimestamp();
210 216
211 #ifdef SK_DEBUG 217 #ifdef SK_DEBUG
212 bool isInCache(const GrGpuResource* r) const; 218 bool isInCache(const GrGpuResource* r) const;
213 void validate() const; 219 void validate() const;
214 #else 220 #else
215 void validate() const {} 221 void validate() const {}
216 #endif 222 #endif
217 223
218 class AutoValidate; 224 class AutoValidate;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 377
372 friend class GrGpuResource; // To access all the proxy inline methods. 378 friend class GrGpuResource; // To access all the proxy inline methods.
373 friend class GrResourceCache; // To create this type. 379 friend class GrResourceCache; // To create this type.
374 }; 380 };
375 381
376 inline GrResourceCache::ResourceAccess GrResourceCache::resourceAccess() { 382 inline GrResourceCache::ResourceAccess GrResourceCache::resourceAccess() {
377 return ResourceAccess(this); 383 return ResourceAccess(this);
378 } 384 }
379 385
380 #endif 386 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698