Chromium Code Reviews| 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 "GrBatchAtlas.h" | 11 #include "GrBatchAtlas.h" |
| 12 #include "GrBatchFontCache.h" | 12 #include "GrBatchFontCache.h" |
| 13 #include "GrContextOptions.h" | 13 #include "GrContextOptions.h" |
| 14 #include "GrDrawContext.h" | |
| 14 #include "GrDrawingManager.h" | 15 #include "GrDrawingManager.h" |
| 15 #include "GrGpuResourceCacheAccess.h" | 16 #include "GrGpuResourceCacheAccess.h" |
| 16 #include "GrResourceCache.h" | 17 #include "GrResourceCache.h" |
| 17 #include "GrTextBlobCache.h" | 18 #include "GrTextBlobCache.h" |
| 19 #include "SkGrPriv.h" | |
| 18 #include "SkString.h" | 20 #include "SkString.h" |
| 19 | 21 |
| 20 namespace GrTest { | 22 namespace GrTest { |
| 21 void SetupAlwaysEvictAtlas(GrContext* context) { | 23 void SetupAlwaysEvictAtlas(GrContext* context) { |
| 22 // These sizes were selected because they allow each atlas to hold a single plot and will thus | 24 // These sizes were selected because they allow each atlas to hold a single plot and will thus |
| 23 // stress the atlas | 25 // stress the atlas |
| 24 int dim = GrBatchAtlas::kGlyphMaxDim; | 26 int dim = GrBatchAtlas::kGlyphMaxDim; |
| 25 GrBatchAtlasConfig configs[3]; | 27 GrBatchAtlasConfig configs[3]; |
| 26 configs[kA8_GrMaskFormat].fWidth = dim; | 28 configs[kA8_GrMaskFormat].fWidth = dim; |
| 27 configs[kA8_GrMaskFormat].fHeight = dim; | 29 configs[kA8_GrMaskFormat].fHeight = dim; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 return fGpu->stats()->dump(out); | 92 return fGpu->stats()->dump(out); |
| 91 #endif | 93 #endif |
| 92 } | 94 } |
| 93 | 95 |
| 94 void GrContext::printGpuStats() const { | 96 void GrContext::printGpuStats() const { |
| 95 SkString out; | 97 SkString out; |
| 96 this->dumpGpuStats(&out); | 98 this->dumpGpuStats(&out); |
| 97 SkDebugf("%s", out.c_str()); | 99 SkDebugf("%s", out.c_str()); |
| 98 } | 100 } |
| 99 | 101 |
| 102 void GrContext::drawFontCache(const SkRect& rect, GrMaskFormat format, const SkP aint& paint, | |
| 103 GrRenderTarget* target) { | |
| 104 GrBatchFontCache* cache = this->getBatchFontCache(); | |
| 105 | |
| 106 GrTexture* atlas = cache->getTexture(format); | |
| 107 | |
| 108 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(target)); | |
|
robertphillips
2015/11/06 21:53:08
// TODO: add drawContext method to encapsulate thi
jvanverth1
2015/11/06 22:06:53
Done.
| |
| 109 | |
| 110 GrPaint grPaint; | |
| 111 SkMatrix mat; | |
|
robertphillips
2015/11/06 21:51:14
reset mat ?
jvanverth1
2015/11/06 22:06:53
Done.
| |
| 112 if (!SkPaintToGrPaint(this, paint, mat, &grPaint)) { | |
| 113 return; | |
| 114 } | |
|
robertphillips
2015/11/06 21:51:14
setScaleTranslate ?
jvanverth1
2015/11/06 22:06:53
Acknowledged.
| |
| 115 SkMatrix textureMat; | |
| 116 textureMat.reset(); | |
| 117 textureMat[SkMatrix::kMScaleX] = 1.0f/rect.width(); | |
| 118 textureMat[SkMatrix::kMScaleY] = 1.0f/rect.height(); | |
| 119 textureMat[SkMatrix::kMTransX] = -rect.fLeft/rect.width(); | |
| 120 textureMat[SkMatrix::kMTransY] = -rect.fTop/rect.height(); | |
| 121 | |
| 122 grPaint.addColorTextureProcessor(atlas, textureMat); | |
| 123 | |
| 124 GrClip clip; | |
|
robertphillips
2015/11/06 21:51:14
don't need reset. Should default to wide open.
jvanverth1
2015/11/06 22:06:53
Done.
| |
| 125 clip.reset(); | |
| 126 drawContext->drawRect(clip, grPaint, mat, rect); | |
| 127 } | |
| 128 | |
| 100 #if GR_GPU_STATS | 129 #if GR_GPU_STATS |
| 101 void GrGpu::Stats::dump(SkString* out) { | 130 void GrGpu::Stats::dump(SkString* out) { |
| 102 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); | 131 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); |
| 103 out->appendf("Shader Compilations: %d\n", fShaderCompilations); | 132 out->appendf("Shader Compilations: %d\n", fShaderCompilations); |
| 104 out->appendf("Textures Created: %d\n", fTextureCreates); | 133 out->appendf("Textures Created: %d\n", fTextureCreates); |
| 105 out->appendf("Texture Uploads: %d\n", fTextureUploads); | 134 out->appendf("Texture Uploads: %d\n", fTextureUploads); |
| 106 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates); | 135 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates); |
| 107 out->appendf("Number of draws: %d\n", fNumDraws); | 136 out->appendf("Number of draws: %d\n", fNumDraws); |
| 108 } | 137 } |
| 109 #endif | 138 #endif |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 SkASSERT(nullptr == fGpu); | 317 SkASSERT(nullptr == fGpu); |
| 289 fGpu = new MockGpu(this, options); | 318 fGpu = new MockGpu(this, options); |
| 290 SkASSERT(fGpu); | 319 SkASSERT(fGpu); |
| 291 this->initCommon(options); | 320 this->initCommon(options); |
| 292 | 321 |
| 293 // We delete these because we want to test the cache starting with zero reso urces. Also, none of | 322 // We delete these because we want to test the cache starting with zero reso urces. Also, none of |
| 294 // these objects are required for any of tests that use this context. TODO: make stop allocating | 323 // these objects are required for any of tests that use this context. TODO: make stop allocating |
| 295 // resources in the buffer pools. | 324 // resources in the buffer pools. |
| 296 fDrawingManager->abandon(); | 325 fDrawingManager->abandon(); |
| 297 } | 326 } |
| OLD | NEW |