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

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

Issue 1506203002: Move texture drawing utility method to SkGpuDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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
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 "GrDrawContext.h"
15 #include "GrDrawingManager.h" 15 #include "GrDrawingManager.h"
16 #include "GrGpuResourceCacheAccess.h" 16 #include "GrGpuResourceCacheAccess.h"
17 #include "GrResourceCache.h" 17 #include "GrResourceCache.h"
18 #include "GrTextBlobCache.h" 18 #include "GrTextBlobCache.h"
19
20 #include "SkGpuDevice.h"
19 #include "SkGrPriv.h" 21 #include "SkGrPriv.h"
20 #include "SkString.h" 22 #include "SkString.h"
21 23
22 namespace GrTest { 24 namespace GrTest {
23 void SetupAlwaysEvictAtlas(GrContext* context) { 25 void SetupAlwaysEvictAtlas(GrContext* context) {
24 // These sizes were selected because they allow each atlas to hold a single plot and will thus 26 // These sizes were selected because they allow each atlas to hold a single plot and will thus
25 // stress the atlas 27 // stress the atlas
26 int dim = GrBatchAtlas::kGlyphMaxDim; 28 int dim = GrBatchAtlas::kGlyphMaxDim;
27 GrBatchAtlasConfig configs[3]; 29 GrBatchAtlasConfig configs[3];
28 configs[kA8_GrMaskFormat].fWidth = dim; 30 configs[kA8_GrMaskFormat].fWidth = dim;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return fGpu->stats()->dumpKeyValuePairs(keys, values); 132 return fGpu->stats()->dumpKeyValuePairs(keys, values);
131 #endif 133 #endif
132 } 134 }
133 135
134 void GrContext::printGpuStats() const { 136 void GrContext::printGpuStats() const {
135 SkString out; 137 SkString out;
136 this->dumpGpuStats(&out); 138 this->dumpGpuStats(&out);
137 SkDebugf("%s", out.c_str()); 139 SkDebugf("%s", out.c_str());
138 } 140 }
139 141
140 void GrContext::drawFontCache(const SkRect& rect, GrMaskFormat format, const SkP aint& paint, 142 GrTexture* GrContext::getFontAtlasTexture(GrMaskFormat format) {
141 GrRenderTarget* target) {
142 GrBatchFontCache* cache = this->getBatchFontCache(); 143 GrBatchFontCache* cache = this->getBatchFontCache();
143 144
144 GrTexture* atlas = cache->getTexture(format); 145 return cache->getTexture(format);
146 }
145 147
146 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(target)); 148 void SkGpuDevice::drawTexture(GrTexture* tex, const SkRect& dst, const SkPaint& paint) {
147 // TODO: add drawContext method to encapsulate this.
148
149 GrPaint grPaint; 149 GrPaint grPaint;
150 SkMatrix mat; 150 SkMatrix mat;
151 mat.reset(); 151 mat.reset();
152 if (!SkPaintToGrPaint(this, paint, mat, &grPaint)) { 152 if (!SkPaintToGrPaint(this->context(), paint, mat, &grPaint)) {
153 return; 153 return;
154 } 154 }
155 SkMatrix textureMat; 155 SkMatrix textureMat;
156 textureMat.reset(); 156 textureMat.reset();
157 // TODO: use setScaleTranslate() 157 textureMat[SkMatrix::kMScaleX] = 1.0f/dst.width();
158 textureMat[SkMatrix::kMScaleX] = 1.0f/rect.width(); 158 textureMat[SkMatrix::kMScaleY] = 1.0f/dst.height();
159 textureMat[SkMatrix::kMScaleY] = 1.0f/rect.height(); 159 textureMat[SkMatrix::kMTransX] = -dst.fLeft/dst.width();
160 textureMat[SkMatrix::kMTransX] = -rect.fLeft/rect.width(); 160 textureMat[SkMatrix::kMTransY] = -dst.fTop/dst.height();
161 textureMat[SkMatrix::kMTransY] = -rect.fTop/rect.height();
162 161
163 grPaint.addColorTextureProcessor(atlas, textureMat); 162 grPaint.addColorTextureProcessor(tex, textureMat);
164 163
165 GrClip clip; 164 GrClip clip;
166 drawContext->drawRect(clip, grPaint, mat, rect); 165 fDrawContext->drawRect(clip, grPaint, mat, dst);
167 } 166 }
168 167
168
169 #if GR_GPU_STATS 169 #if GR_GPU_STATS
170 void GrGpu::Stats::dump(SkString* out) { 170 void GrGpu::Stats::dump(SkString* out) {
171 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); 171 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds);
172 out->appendf("Shader Compilations: %d\n", fShaderCompilations); 172 out->appendf("Shader Compilations: %d\n", fShaderCompilations);
173 out->appendf("Textures Created: %d\n", fTextureCreates); 173 out->appendf("Textures Created: %d\n", fTextureCreates);
174 out->appendf("Texture Uploads: %d\n", fTextureUploads); 174 out->appendf("Texture Uploads: %d\n", fTextureUploads);
175 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates); 175 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates);
176 out->appendf("Number of draws: %d\n", fNumDraws); 176 out->appendf("Number of draws: %d\n", fNumDraws);
177 } 177 }
178 178
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 SkASSERT(nullptr == fGpu); 369 SkASSERT(nullptr == fGpu);
370 fGpu = new MockGpu(this, options); 370 fGpu = new MockGpu(this, options);
371 SkASSERT(fGpu); 371 SkASSERT(fGpu);
372 this->initCommon(options); 372 this->initCommon(options);
373 373
374 // We delete these because we want to test the cache starting with zero reso urces. Also, none of 374 // We delete these because we want to test the cache starting with zero reso urces. Also, none of
375 // these objects are required for any of tests that use this context. TODO: make stop allocating 375 // these objects are required for any of tests that use this context. TODO: make stop allocating
376 // resources in the buffer pools. 376 // resources in the buffer pools.
377 fDrawingManager->abandon(); 377 fDrawingManager->abandon();
378 } 378 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698