Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: src/gpu/GrTest.cpp

Issue 1410663005: Add text animation sample; tweak DrawShip sample (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Correct fix for CrOS Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « samplecode/SampleShip.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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));
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
100 #if GR_GPU_STATS 131 #if GR_GPU_STATS
101 void GrGpu::Stats::dump(SkString* out) { 132 void GrGpu::Stats::dump(SkString* out) {
102 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); 133 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds);
103 out->appendf("Shader Compilations: %d\n", fShaderCompilations); 134 out->appendf("Shader Compilations: %d\n", fShaderCompilations);
104 out->appendf("Textures Created: %d\n", fTextureCreates); 135 out->appendf("Textures Created: %d\n", fTextureCreates);
105 out->appendf("Texture Uploads: %d\n", fTextureUploads); 136 out->appendf("Texture Uploads: %d\n", fTextureUploads);
106 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates); 137 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates);
107 out->appendf("Number of draws: %d\n", fNumDraws); 138 out->appendf("Number of draws: %d\n", fNumDraws);
108 } 139 }
109 #endif 140 #endif
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 SkASSERT(nullptr == fGpu); 319 SkASSERT(nullptr == fGpu);
289 fGpu = new MockGpu(this, options); 320 fGpu = new MockGpu(this, options);
290 SkASSERT(fGpu); 321 SkASSERT(fGpu);
291 this->initCommon(options); 322 this->initCommon(options);
292 323
293 // We delete these because we want to test the cache starting with zero reso urces. Also, none of 324 // 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 325 // these objects are required for any of tests that use this context. TODO: make stop allocating
295 // resources in the buffer pools. 326 // resources in the buffer pools.
296 fDrawingManager->abandon(); 327 fDrawingManager->abandon();
297 } 328 }
OLDNEW
« no previous file with comments | « samplecode/SampleShip.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698