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 | 10 |
11 #include "GrInOrderDrawBuffer.h" | 11 #include "GrInOrderDrawBuffer.h" |
12 #include "GrResourceCache2.h" | 12 #include "GrResourceCache2.h" |
| 13 #include "SkString.h" |
13 | 14 |
14 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) { | 15 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) { |
15 SkASSERT(!fContext); | 16 SkASSERT(!fContext); |
16 | 17 |
17 fContext.reset(SkRef(ctx)); | 18 fContext.reset(SkRef(ctx)); |
18 fDrawTarget.reset(SkRef(target)); | 19 fDrawTarget.reset(SkRef(target)); |
19 | 20 |
20 SkNEW_IN_TLAZY(&fACR, GrDrawTarget::AutoClipRestore, (target)); | 21 SkNEW_IN_TLAZY(&fACR, GrDrawTarget::AutoClipRestore, (target)); |
21 SkNEW_IN_TLAZY(&fAGP, GrDrawTarget::AutoGeometryPush, (target)); | 22 SkNEW_IN_TLAZY(&fAGP, GrDrawTarget::AutoGeometryPush, (target)); |
22 } | 23 } |
(...skipping 10 matching lines...) Expand all Loading... |
33 /////////////////////////////////////////////////////////////////////////////// | 34 /////////////////////////////////////////////////////////////////////////////// |
34 | 35 |
35 void GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) { | 36 void GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) { |
36 fMaxTextureSizeOverride = maxTextureSizeOverride; | 37 fMaxTextureSizeOverride = maxTextureSizeOverride; |
37 } | 38 } |
38 | 39 |
39 void GrContext::purgeAllUnlockedResources() { | 40 void GrContext::purgeAllUnlockedResources() { |
40 fResourceCache2->purgeAllUnlocked(); | 41 fResourceCache2->purgeAllUnlocked(); |
41 } | 42 } |
42 | 43 |
| 44 void GrContext::dumpCacheStats(SkString* out) const { |
| 45 #if GR_CACHE_STATS |
| 46 fResourceCache2->dumpStats(out); |
| 47 #endif |
| 48 } |
| 49 |
| 50 void GrContext::printCacheStats() const { |
| 51 SkString out; |
| 52 this->dumpCacheStats(&out); |
| 53 SkDebugf(out.c_str()); |
| 54 } |
| 55 |
| 56 void GrContext::dumpGpuStats(SkString* out) const { |
| 57 #if GR_GPU_STATS |
| 58 return fGpu->stats()->dump(out); |
| 59 #endif |
| 60 } |
| 61 |
| 62 void GrContext::printGpuStats() const { |
| 63 SkString out; |
| 64 this->dumpGpuStats(&out); |
| 65 SkDebugf(out.c_str()); |
| 66 } |
| 67 |
| 68 #if GR_GPU_STATS |
| 69 void GrGpu::Stats::dump(SkString* out) { |
| 70 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); |
| 71 out->appendf("Shader Compilations: %d\n", fShaderCompilations); |
| 72 } |
| 73 #endif |
| 74 |
| 75 #if GR_CACHE_STATS |
| 76 void GrResourceCache2::dumpStats(SkString* out) const { |
| 77 this->validate(); |
| 78 |
| 79 int locked = 0; |
| 80 int scratch = 0; |
| 81 int wrapped = 0; |
| 82 size_t unbudgetedSize = 0; |
| 83 |
| 84 ResourceList::Iter iter; |
| 85 GrGpuResource* resource = iter.init(fResources, ResourceList::Iter::kHead_It
erStart); |
| 86 |
| 87 for ( ; resource; resource = iter.next()) { |
| 88 if (!resource->isPurgeable()) { |
| 89 ++locked; |
| 90 } |
| 91 if (resource->cacheAccess().isScratch()) { |
| 92 ++scratch; |
| 93 } |
| 94 if (resource->cacheAccess().isWrapped()) { |
| 95 ++wrapped; |
| 96 } |
| 97 if (!resource->cacheAccess().isBudgeted()) { |
| 98 unbudgetedSize += resource->gpuMemorySize(); |
| 99 } |
| 100 } |
| 101 |
| 102 float countUtilization = (100.f * fBudgetedCount) / fMaxCount; |
| 103 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes; |
| 104 |
| 105 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes); |
| 106 out->appendf("\t\tEntry Count: current %d" |
| 107 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full),
high %d\n", |
| 108 fCount, fBudgetedCount, wrapped, locked, scratch, countUtilizat
ion, |
| 109 fHighWaterCount); |
| 110 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu
dgeted) high %d\n", |
| 111 (int)fBytes, (int)fBudgetedBytes, byteUtilization, |
| 112 (int)unbudgetedSize, (int)fHighWaterBytes); |
| 113 } |
| 114 |
| 115 #endif |
| 116 |
| 117 |
43 /////////////////////////////////////////////////////////////////////////////// | 118 /////////////////////////////////////////////////////////////////////////////// |
44 // Code for the mock context. It's built on a mock GrGpu class that does nothing
. | 119 // Code for the mock context. It's built on a mock GrGpu class that does nothing
. |
45 //// | 120 //// |
46 | 121 |
47 #include "GrBufferAllocPool.h" | 122 #include "GrBufferAllocPool.h" |
48 #include "GrInOrderDrawBuffer.h" | 123 #include "GrInOrderDrawBuffer.h" |
49 #include "GrGpu.h" | 124 #include "GrGpu.h" |
50 | 125 |
51 class GrPipeline; | 126 class GrPipeline; |
52 | 127 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 254 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
180 // resources in the buffer pools. | 255 // resources in the buffer pools. |
181 SkDELETE(fDrawBuffer); | 256 SkDELETE(fDrawBuffer); |
182 SkDELETE(fDrawBufferVBAllocPool); | 257 SkDELETE(fDrawBufferVBAllocPool); |
183 SkDELETE(fDrawBufferIBAllocPool); | 258 SkDELETE(fDrawBufferIBAllocPool); |
184 | 259 |
185 fDrawBuffer = NULL; | 260 fDrawBuffer = NULL; |
186 fDrawBufferVBAllocPool = NULL; | 261 fDrawBufferVBAllocPool = NULL; |
187 fDrawBufferIBAllocPool = NULL; | 262 fDrawBufferIBAllocPool = NULL; |
188 } | 263 } |
OLD | NEW |