| 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 "GrResourceCache.h" |
| 13 #include "SkString.h" | 13 #include "SkString.h" |
| 14 | 14 |
| 15 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) { | 15 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) { |
| 16 SkASSERT(!fContext); | 16 SkASSERT(!fContext); |
| 17 | 17 |
| 18 fContext.reset(SkRef(ctx)); | 18 fContext.reset(SkRef(ctx)); |
| 19 fDrawTarget.reset(SkRef(target)); | 19 fDrawTarget.reset(SkRef(target)); |
| 20 | 20 |
| 21 SkNEW_IN_TLAZY(&fACR, GrDrawTarget::AutoClipRestore, (target)); | 21 SkNEW_IN_TLAZY(&fACR, GrDrawTarget::AutoClipRestore, (target)); |
| 22 SkNEW_IN_TLAZY(&fAGP, GrDrawTarget::AutoGeometryPush, (target)); | 22 SkNEW_IN_TLAZY(&fAGP, GrDrawTarget::AutoGeometryPush, (target)); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void GrContext::getTestTarget(GrTestTarget* tar) { | 25 void GrContext::getTestTarget(GrTestTarget* tar) { |
| 26 this->flush(); | 26 this->flush(); |
| 27 // We could create a proxy GrDrawTarget that passes through to fGpu until ~G
rTextTarget() and | 27 // We could create a proxy GrDrawTarget that passes through to fGpu until ~G
rTextTarget() and |
| 28 // then disconnects. This would help prevent test writers from mixing using
the returned | 28 // then disconnects. This would help prevent test writers from mixing using
the returned |
| 29 // GrDrawTarget and regular drawing. We could also assert or fail in GrConte
xt drawing methods | 29 // GrDrawTarget and regular drawing. We could also assert or fail in GrConte
xt drawing methods |
| 30 // until ~GrTestTarget(). | 30 // until ~GrTestTarget(). |
| 31 tar->init(this, fDrawBuffer); | 31 tar->init(this, fDrawBuffer); |
| 32 } | 32 } |
| 33 | 33 |
| 34 /////////////////////////////////////////////////////////////////////////////// | 34 /////////////////////////////////////////////////////////////////////////////// |
| 35 | 35 |
| 36 void GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) { | 36 void GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) { |
| 37 fMaxTextureSizeOverride = maxTextureSizeOverride; | 37 fMaxTextureSizeOverride = maxTextureSizeOverride; |
| 38 } | 38 } |
| 39 | 39 |
| 40 void GrContext::purgeAllUnlockedResources() { | 40 void GrContext::purgeAllUnlockedResources() { |
| 41 fResourceCache2->purgeAllUnlocked(); | 41 fResourceCache->purgeAllUnlocked(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void GrContext::dumpCacheStats(SkString* out) const { | 44 void GrContext::dumpCacheStats(SkString* out) const { |
| 45 #if GR_CACHE_STATS | 45 #if GR_CACHE_STATS |
| 46 fResourceCache2->dumpStats(out); | 46 fResourceCache->dumpStats(out); |
| 47 #endif | 47 #endif |
| 48 } | 48 } |
| 49 | 49 |
| 50 void GrContext::printCacheStats() const { | 50 void GrContext::printCacheStats() const { |
| 51 SkString out; | 51 SkString out; |
| 52 this->dumpCacheStats(&out); | 52 this->dumpCacheStats(&out); |
| 53 SkDebugf(out.c_str()); | 53 SkDebugf(out.c_str()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void GrContext::dumpGpuStats(SkString* out) const { | 56 void GrContext::dumpGpuStats(SkString* out) const { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 68 #if GR_GPU_STATS | 68 #if GR_GPU_STATS |
| 69 void GrGpu::Stats::dump(SkString* out) { | 69 void GrGpu::Stats::dump(SkString* out) { |
| 70 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); | 70 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); |
| 71 out->appendf("Shader Compilations: %d\n", fShaderCompilations); | 71 out->appendf("Shader Compilations: %d\n", fShaderCompilations); |
| 72 out->appendf("Textures Created: %d\n", fTextureCreates); | 72 out->appendf("Textures Created: %d\n", fTextureCreates); |
| 73 out->appendf("Texture Uploads: %d\n", fTextureUploads); | 73 out->appendf("Texture Uploads: %d\n", fTextureUploads); |
| 74 } | 74 } |
| 75 #endif | 75 #endif |
| 76 | 76 |
| 77 #if GR_CACHE_STATS | 77 #if GR_CACHE_STATS |
| 78 void GrResourceCache2::dumpStats(SkString* out) const { | 78 void GrResourceCache::dumpStats(SkString* out) const { |
| 79 this->validate(); | 79 this->validate(); |
| 80 | 80 |
| 81 int locked = 0; | 81 int locked = 0; |
| 82 int scratch = 0; | 82 int scratch = 0; |
| 83 int wrapped = 0; | 83 int wrapped = 0; |
| 84 size_t unbudgetedSize = 0; | 84 size_t unbudgetedSize = 0; |
| 85 | 85 |
| 86 ResourceList::Iter iter; | 86 ResourceList::Iter iter; |
| 87 GrGpuResource* resource = iter.init(fResources, ResourceList::Iter::kHead_It
erStart); | 87 GrGpuResource* resource = iter.init(fResources, ResourceList::Iter::kHead_It
erStart); |
| 88 | 88 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 255 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
| 256 // resources in the buffer pools. | 256 // resources in the buffer pools. |
| 257 SkDELETE(fDrawBuffer); | 257 SkDELETE(fDrawBuffer); |
| 258 SkDELETE(fDrawBufferVBAllocPool); | 258 SkDELETE(fDrawBufferVBAllocPool); |
| 259 SkDELETE(fDrawBufferIBAllocPool); | 259 SkDELETE(fDrawBufferIBAllocPool); |
| 260 | 260 |
| 261 fDrawBuffer = NULL; | 261 fDrawBuffer = NULL; |
| 262 fDrawBufferVBAllocPool = NULL; | 262 fDrawBufferVBAllocPool = NULL; |
| 263 fDrawBufferIBAllocPool = NULL; | 263 fDrawBufferIBAllocPool = NULL; |
| 264 } | 264 } |
| OLD | NEW |