OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 "GrTest.h" | 9 #include "GrTest.h" |
10 #include "GrContextOptions.h" | 10 #include "GrContextOptions.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 #endif | 72 #endif |
73 | 73 |
74 #if GR_CACHE_STATS | 74 #if GR_CACHE_STATS |
75 void GrResourceCache::dumpStats(SkString* out) const { | 75 void GrResourceCache::dumpStats(SkString* out) const { |
76 this->validate(); | 76 this->validate(); |
77 | 77 |
78 int locked = fNonpurgeableResources.count(); | 78 int locked = fNonpurgeableResources.count(); |
79 | 79 |
80 struct Stats { | 80 struct Stats { |
81 int fScratch; | 81 int fScratch; |
82 int fWrapped; | 82 int fExternal; |
| 83 int fBorrowed; |
| 84 int fAdopted; |
83 size_t fUnbudgetedSize; | 85 size_t fUnbudgetedSize; |
84 | 86 |
85 Stats() : fScratch(0), fWrapped(0), fUnbudgetedSize(0) {} | 87 Stats() : fScratch(0), fExternal(0), fBorrowed(0), fAdopted(0), fUnbudge
tedSize(0) {} |
86 | 88 |
87 void update(GrGpuResource* resource) { | 89 void update(GrGpuResource* resource) { |
88 if (resource->cacheAccess().isScratch()) { | 90 if (resource->cacheAccess().isScratch()) { |
89 ++fScratch; | 91 ++fScratch; |
90 } | 92 } |
91 if (resource->cacheAccess().isWrapped()) { | 93 if (resource->cacheAccess().isExternal()) { |
92 ++fWrapped; | 94 ++fExternal; |
| 95 } |
| 96 if (resource->cacheAccess().isBorrowed()) { |
| 97 ++fBorrowed; |
| 98 } |
| 99 if (resource->cacheAccess().isAdopted()) { |
| 100 ++fAdopted; |
93 } | 101 } |
94 if (!resource->resourcePriv().isBudgeted()) { | 102 if (!resource->resourcePriv().isBudgeted()) { |
95 fUnbudgetedSize += resource->gpuMemorySize(); | 103 fUnbudgetedSize += resource->gpuMemorySize(); |
96 } | 104 } |
97 } | 105 } |
98 }; | 106 }; |
99 | 107 |
100 Stats stats; | 108 Stats stats; |
101 | 109 |
102 for (int i = 0; i < fNonpurgeableResources.count(); ++i) { | 110 for (int i = 0; i < fNonpurgeableResources.count(); ++i) { |
103 stats.update(fNonpurgeableResources[i]); | 111 stats.update(fNonpurgeableResources[i]); |
104 } | 112 } |
105 for (int i = 0; i < fPurgeableQueue.count(); ++i) { | 113 for (int i = 0; i < fPurgeableQueue.count(); ++i) { |
106 stats.update(fPurgeableQueue.at(i)); | 114 stats.update(fPurgeableQueue.at(i)); |
107 } | 115 } |
108 | 116 |
109 float countUtilization = (100.f * fBudgetedCount) / fMaxCount; | 117 float countUtilization = (100.f * fBudgetedCount) / fMaxCount; |
110 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes; | 118 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes; |
111 | 119 |
112 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes); | 120 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes); |
113 out->appendf("\t\tEntry Count: current %d" | 121 out->appendf("\t\tEntry Count: current %d" |
114 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full),
high %d\n", | 122 " (%d budgeted, %d external(%d borrowed, %d adopted), %d locked
, %d scratch %.2g%% full), high %d\n", |
115 this->getResourceCount(), fBudgetedCount, stats.fWrapped, locke
d, stats.fScratch, | 123 this->getResourceCount(), fBudgetedCount, stats.fExternal, stat
s.fBorrowed, |
116 countUtilization, fHighWaterCount); | 124 stats.fAdopted, locked, stats.fScratch, countUtilization, fHigh
WaterCount); |
117 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu
dgeted) high %d\n", | 125 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu
dgeted) high %d\n", |
118 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization, | 126 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization, |
119 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes)); | 127 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes)); |
120 } | 128 } |
121 | 129 |
122 #endif | 130 #endif |
123 | 131 |
124 /////////////////////////////////////////////////////////////////////////////// | 132 /////////////////////////////////////////////////////////////////////////////// |
125 | 133 |
126 void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT
imestamp; } | 134 void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT
imestamp; } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, | 180 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, |
173 const void* srcData, size_t rowBytes) override { | 181 const void* srcData, size_t rowBytes) override { |
174 return NULL; | 182 return NULL; |
175 } | 183 } |
176 | 184 |
177 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc
e::LifeCycle, | 185 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc
e::LifeCycle, |
178 const void* srcData) override { | 186 const void* srcData) override { |
179 return NULL; | 187 return NULL; |
180 } | 188 } |
181 | 189 |
182 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) override { retu
rn NULL; } | 190 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, |
| 191 GrWrapOwnership) override { return NULL; } |
183 | 192 |
184 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&)
override { | 193 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, |
| 194 GrWrapOwnership) override { |
185 return NULL; | 195 return NULL; |
186 } | 196 } |
187 | 197 |
188 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override { r
eturn NULL; } | 198 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override { r
eturn NULL; } |
189 | 199 |
190 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override { ret
urn NULL; } | 200 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override { ret
urn NULL; } |
191 | 201 |
192 void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, | 202 void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, |
193 bool canIgnoreRect) override {} | 203 bool canIgnoreRect) override {} |
194 | 204 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 SkASSERT(NULL == fGpu); | 253 SkASSERT(NULL == fGpu); |
244 fGpu = SkNEW_ARGS(MockGpu, (this, options)); | 254 fGpu = SkNEW_ARGS(MockGpu, (this, options)); |
245 SkASSERT(fGpu); | 255 SkASSERT(fGpu); |
246 this->initCommon(); | 256 this->initCommon(); |
247 | 257 |
248 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 258 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
249 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 259 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
250 // resources in the buffer pools. | 260 // resources in the buffer pools. |
251 fDrawingMgr.abandon(); | 261 fDrawingMgr.abandon(); |
252 } | 262 } |
OLD | NEW |