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

Side by Side Diff: src/gpu/GrGpuResource.cpp

Issue 921323002: Make GrResourceCache use a priority queue of purgeable resources. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 5 years, 10 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/core/SkTDPQueue.h ('k') | src/gpu/GrGpuResourceCacheAccess.h » ('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 #include "GrGpuResource.h" 9 #include "GrGpuResource.h"
10 #include "GrResourceCache.h" 10 #include "GrResourceCache.h"
11 #include "GrGpu.h" 11 #include "GrGpu.h"
12 #include "GrGpuResourcePriv.h" 12 #include "GrGpuResourcePriv.h"
13 13
14 static inline GrResourceCache* get_resource_cache(GrGpu* gpu) { 14 static inline GrResourceCache* get_resource_cache(GrGpu* gpu) {
15 SkASSERT(gpu); 15 SkASSERT(gpu);
16 SkASSERT(gpu->getContext()); 16 SkASSERT(gpu->getContext());
17 SkASSERT(gpu->getContext()->getResourceCache()); 17 SkASSERT(gpu->getContext()->getResourceCache());
18 return gpu->getContext()->getResourceCache(); 18 return gpu->getContext()->getResourceCache();
19 } 19 }
20 20
21 GrGpuResource::GrGpuResource(GrGpu* gpu, LifeCycle lifeCycle) 21 GrGpuResource::GrGpuResource(GrGpu* gpu, LifeCycle lifeCycle)
22 : fGpu(gpu) 22 : fGpu(gpu)
23 , fGpuMemorySize(kInvalidGpuMemorySize) 23 , fGpuMemorySize(kInvalidGpuMemorySize)
24 , fLifeCycle(lifeCycle) 24 , fLifeCycle(lifeCycle)
25 , fUniqueID(CreateUniqueID()) { 25 , fUniqueID(CreateUniqueID()) {
26 SkDEBUGCODE(fCacheArrayIndex = -1);
26 } 27 }
27 28
28 void GrGpuResource::registerWithCache() { 29 void GrGpuResource::registerWithCache() {
29 get_resource_cache(fGpu)->resourceAccess().insertResource(this); 30 get_resource_cache(fGpu)->resourceAccess().insertResource(this);
30 } 31 }
31 32
32 GrGpuResource::~GrGpuResource() { 33 GrGpuResource::~GrGpuResource() {
33 // The cache should have released or destroyed this resource. 34 // The cache should have released or destroyed this resource.
34 SkASSERT(this->wasDestroyed()); 35 SkASSERT(this->wasDestroyed());
35 } 36 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 155 }
155 156
156 uint32_t GrGpuResource::CreateUniqueID() { 157 uint32_t GrGpuResource::CreateUniqueID() {
157 static int32_t gUniqueID = SK_InvalidUniqueID; 158 static int32_t gUniqueID = SK_InvalidUniqueID;
158 uint32_t id; 159 uint32_t id;
159 do { 160 do {
160 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); 161 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
161 } while (id == SK_InvalidUniqueID); 162 } while (id == SK_InvalidUniqueID);
162 return id; 163 return id;
163 } 164 }
OLDNEW
« no previous file with comments | « src/core/SkTDPQueue.h ('k') | src/gpu/GrGpuResourceCacheAccess.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698