| 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 | 
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 86 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
     nfigs) { | 86 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
     nfigs) { | 
| 87     fBatchFontCache->setAtlasSizes_ForTesting(configs); | 87     fBatchFontCache->setAtlasSizes_ForTesting(configs); | 
| 88 } | 88 } | 
| 89 | 89 | 
| 90 /////////////////////////////////////////////////////////////////////////////// | 90 /////////////////////////////////////////////////////////////////////////////// | 
| 91 | 91 | 
| 92 void GrContext::purgeAllUnlockedResources() { | 92 void GrContext::purgeAllUnlockedResources() { | 
| 93     fResourceCache->purgeAllUnlocked(); | 93     fResourceCache->purgeAllUnlocked(); | 
| 94 } | 94 } | 
| 95 | 95 | 
|  | 96 void GrContext::resetGpuStats() const { | 
|  | 97 #if GR_GPU_STATS | 
|  | 98     fGpu->stats()->reset(); | 
|  | 99 #endif | 
|  | 100 } | 
|  | 101 | 
| 96 void GrContext::dumpCacheStats(SkString* out) const { | 102 void GrContext::dumpCacheStats(SkString* out) const { | 
| 97 #if GR_CACHE_STATS | 103 #if GR_CACHE_STATS | 
| 98     fResourceCache->dumpStats(out); | 104     fResourceCache->dumpStats(out); | 
| 99 #endif | 105 #endif | 
| 100 } | 106 } | 
| 101 | 107 | 
| 102 void GrContext::printCacheStats() const { | 108 void GrContext::printCacheStats() const { | 
| 103     SkString out; | 109     SkString out; | 
| 104     this->dumpCacheStats(&out); | 110     this->dumpCacheStats(&out); | 
| 105     SkDebugf("%s", out.c_str()); | 111     SkDebugf("%s", out.c_str()); | 
| 106 } | 112 } | 
| 107 | 113 | 
| 108 void GrContext::dumpGpuStats(SkString* out) const { | 114 void GrContext::dumpGpuStats(SkString* out) const { | 
| 109 #if GR_GPU_STATS | 115 #if GR_GPU_STATS | 
| 110     return fGpu->stats()->dump(out); | 116     return fGpu->stats()->dump(out); | 
| 111 #endif | 117 #endif | 
| 112 } | 118 } | 
| 113 | 119 | 
|  | 120 void GrContext::dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys, | 
|  | 121                                           SkTArray<double>* values) const { | 
|  | 122 #if GR_GPU_STATS | 
|  | 123     return fGpu->stats()->dumpKeyValuePairs(keys, values); | 
|  | 124 #endif | 
|  | 125 } | 
|  | 126 | 
| 114 void GrContext::printGpuStats() const { | 127 void GrContext::printGpuStats() const { | 
| 115     SkString out; | 128     SkString out; | 
| 116     this->dumpGpuStats(&out); | 129     this->dumpGpuStats(&out); | 
| 117     SkDebugf("%s", out.c_str()); | 130     SkDebugf("%s", out.c_str()); | 
| 118 } | 131 } | 
| 119 | 132 | 
| 120 void GrContext::drawFontCache(const SkRect& rect, GrMaskFormat format, const SkP
     aint& paint, | 133 void GrContext::drawFontCache(const SkRect& rect, GrMaskFormat format, const SkP
     aint& paint, | 
| 121                               GrRenderTarget* target) { | 134                               GrRenderTarget* target) { | 
| 122     GrBatchFontCache* cache = this->getBatchFontCache(); | 135     GrBatchFontCache* cache = this->getBatchFontCache(); | 
| 123 | 136 | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 148 | 161 | 
| 149 #if GR_GPU_STATS | 162 #if GR_GPU_STATS | 
| 150 void GrGpu::Stats::dump(SkString* out) { | 163 void GrGpu::Stats::dump(SkString* out) { | 
| 151     out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); | 164     out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); | 
| 152     out->appendf("Shader Compilations: %d\n", fShaderCompilations); | 165     out->appendf("Shader Compilations: %d\n", fShaderCompilations); | 
| 153     out->appendf("Textures Created: %d\n", fTextureCreates); | 166     out->appendf("Textures Created: %d\n", fTextureCreates); | 
| 154     out->appendf("Texture Uploads: %d\n", fTextureUploads); | 167     out->appendf("Texture Uploads: %d\n", fTextureUploads); | 
| 155     out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates); | 168     out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates); | 
| 156     out->appendf("Number of draws: %d\n", fNumDraws); | 169     out->appendf("Number of draws: %d\n", fNumDraws); | 
| 157 } | 170 } | 
|  | 171 | 
|  | 172 void GrGpu::Stats::dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>*
      values) { | 
|  | 173     keys->push_back(SkString("render_target_binds")); values->push_back(fRenderT
     argetBinds); | 
|  | 174     keys->push_back(SkString("shader_compilations")); values->push_back(fShaderC
     ompilations); | 
|  | 175     keys->push_back(SkString("textures_created")); values->push_back(fTextureCre
     ates); | 
|  | 176     keys->push_back(SkString("texture_uploads")); values->push_back(fTextureUplo
     ads); | 
|  | 177     keys->push_back(SkString("stencil_buffer_creates")); values->push_back(fSten
     cilAttachmentCreates); | 
|  | 178     keys->push_back(SkString("number_of_draws")); values->push_back(fNumDraws); | 
|  | 179 } | 
|  | 180 | 
| 158 #endif | 181 #endif | 
| 159 | 182 | 
| 160 #if GR_CACHE_STATS | 183 #if GR_CACHE_STATS | 
| 161 void GrResourceCache::getStats(Stats* stats) const { | 184 void GrResourceCache::getStats(Stats* stats) const { | 
| 162     stats->reset(); | 185     stats->reset(); | 
| 163 | 186 | 
| 164     stats->fTotal = this->getResourceCount(); | 187     stats->fTotal = this->getResourceCount(); | 
| 165     stats->fNumNonPurgeable = fNonpurgeableResources.count(); | 188     stats->fNumNonPurgeable = fNonpurgeableResources.count(); | 
| 166     stats->fNumPurgeable = fPurgeableQueue.count(); | 189     stats->fNumPurgeable = fPurgeableQueue.count(); | 
| 167 | 190 | 
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 318     SkASSERT(nullptr == fGpu); | 341     SkASSERT(nullptr == fGpu); | 
| 319     fGpu = new MockGpu(this, options); | 342     fGpu = new MockGpu(this, options); | 
| 320     SkASSERT(fGpu); | 343     SkASSERT(fGpu); | 
| 321     this->initCommon(); | 344     this->initCommon(); | 
| 322 | 345 | 
| 323     // We delete these because we want to test the cache starting with zero reso
     urces. Also, none of | 346     // We delete these because we want to test the cache starting with zero reso
     urces. Also, none of | 
| 324     // these objects are required for any of tests that use this context. TODO: 
     make stop allocating | 347     // these objects are required for any of tests that use this context. TODO: 
     make stop allocating | 
| 325     // resources in the buffer pools. | 348     // resources in the buffer pools. | 
| 326     fDrawingManager->abandon(); | 349     fDrawingManager->abandon(); | 
| 327 } | 350 } | 
| OLD | NEW | 
|---|