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 size_t fUnbudgetedSize; | 83 size_t fUnbudgetedSize; |
84 | 84 |
85 Stats() : fScratch(0), fWrapped(0), fUnbudgetedSize(0) {} | 85 Stats() : fScratch(0), fExternal(0), fUnbudgetedSize(0) {} |
86 | 86 |
87 void update(GrGpuResource* resource) { | 87 void update(GrGpuResource* resource) { |
88 if (resource->cacheAccess().isScratch()) { | 88 if (resource->cacheAccess().isScratch()) { |
89 ++fScratch; | 89 ++fScratch; |
90 } | 90 } |
robertphillips
2015/06/18 14:18:49
Is it worth differentiating the counts for the bor
bsalomon
2015/06/18 15:19:37
Done.
| |
91 if (resource->cacheAccess().isWrapped()) { | 91 if (resource->cacheAccess().isExternal()) { |
92 ++fWrapped; | 92 ++fExternal; |
93 } | 93 } |
94 if (!resource->resourcePriv().isBudgeted()) { | 94 if (!resource->resourcePriv().isBudgeted()) { |
95 fUnbudgetedSize += resource->gpuMemorySize(); | 95 fUnbudgetedSize += resource->gpuMemorySize(); |
96 } | 96 } |
97 } | 97 } |
98 }; | 98 }; |
99 | 99 |
100 Stats stats; | 100 Stats stats; |
101 | 101 |
102 for (int i = 0; i < fNonpurgeableResources.count(); ++i) { | 102 for (int i = 0; i < fNonpurgeableResources.count(); ++i) { |
103 stats.update(fNonpurgeableResources[i]); | 103 stats.update(fNonpurgeableResources[i]); |
104 } | 104 } |
105 for (int i = 0; i < fPurgeableQueue.count(); ++i) { | 105 for (int i = 0; i < fPurgeableQueue.count(); ++i) { |
106 stats.update(fPurgeableQueue.at(i)); | 106 stats.update(fPurgeableQueue.at(i)); |
107 } | 107 } |
108 | 108 |
109 float countUtilization = (100.f * fBudgetedCount) / fMaxCount; | 109 float countUtilization = (100.f * fBudgetedCount) / fMaxCount; |
110 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes; | 110 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes; |
111 | 111 |
112 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes); | 112 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes); |
113 out->appendf("\t\tEntry Count: current %d" | 113 out->appendf("\t\tEntry Count: current %d" |
114 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), high %d\n", | 114 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), high %d\n", |
115 this->getResourceCount(), fBudgetedCount, stats.fWrapped, locke d, stats.fScratch, | 115 this->getResourceCount(), fBudgetedCount, stats.fExternal, lock ed, stats.fScratch, |
116 countUtilization, fHighWaterCount); | 116 countUtilization, fHighWaterCount); |
117 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu dgeted) high %d\n", | 117 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu dgeted) high %d\n", |
118 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization, | 118 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization, |
119 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes)); | 119 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes)); |
120 } | 120 } |
121 | 121 |
122 #endif | 122 #endif |
123 | 123 |
124 /////////////////////////////////////////////////////////////////////////////// | 124 /////////////////////////////////////////////////////////////////////////////// |
125 | 125 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc le lifeCycle, | 172 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc le lifeCycle, |
173 const void* srcData, size_t rowBytes) override { | 173 const void* srcData, size_t rowBytes) override { |
174 return NULL; | 174 return NULL; |
175 } | 175 } |
176 | 176 |
177 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc e::LifeCycle, | 177 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc e::LifeCycle, |
178 const void* srcData) override { | 178 const void* srcData) override { |
179 return NULL; | 179 return NULL; |
180 } | 180 } |
181 | 181 |
182 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) override { retu rn NULL; } | 182 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, |
183 GrWrapOwnership) override { return NULL; } | |
183 | 184 |
184 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) override { | 185 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, |
186 GrWrapOwnership) override { | |
185 return NULL; | 187 return NULL; |
186 } | 188 } |
187 | 189 |
188 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override { r eturn NULL; } | 190 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override { r eturn NULL; } |
189 | 191 |
190 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override { ret urn NULL; } | 192 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override { ret urn NULL; } |
191 | 193 |
192 void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, | 194 void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, |
193 bool canIgnoreRect) override {} | 195 bool canIgnoreRect) override {} |
194 | 196 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 SkASSERT(NULL == fGpu); | 245 SkASSERT(NULL == fGpu); |
244 fGpu = SkNEW_ARGS(MockGpu, (this, options)); | 246 fGpu = SkNEW_ARGS(MockGpu, (this, options)); |
245 SkASSERT(fGpu); | 247 SkASSERT(fGpu); |
246 this->initCommon(); | 248 this->initCommon(); |
247 | 249 |
248 // We delete these because we want to test the cache starting with zero reso urces. Also, none of | 250 // 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 | 251 // these objects are required for any of tests that use this context. TODO: make stop allocating |
250 // resources in the buffer pools. | 252 // resources in the buffer pools. |
251 fDrawingMgr.abandon(); | 253 fDrawingMgr.abandon(); |
252 } | 254 } |
OLD | NEW |