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