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 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 fContext.reset(SkRef(ctx)); | 50 fContext.reset(SkRef(ctx)); |
51 fDrawTarget.reset(SkRef(target)); | 51 fDrawTarget.reset(SkRef(target)); |
52 } | 52 } |
53 | 53 |
54 void GrContext::getTestTarget(GrTestTarget* tar) { | 54 void GrContext::getTestTarget(GrTestTarget* tar) { |
55 this->flush(); | 55 this->flush(); |
56 // We could create a proxy GrDrawTarget that passes through to fGpu until ~G
rTextTarget() and | 56 // We could create a proxy GrDrawTarget that passes through to fGpu until ~G
rTextTarget() and |
57 // then disconnects. This would help prevent test writers from mixing using
the returned | 57 // then disconnects. This would help prevent test writers from mixing using
the returned |
58 // GrDrawTarget and regular drawing. We could also assert or fail in GrConte
xt drawing methods | 58 // GrDrawTarget and regular drawing. We could also assert or fail in GrConte
xt drawing methods |
59 // until ~GrTestTarget(). | 59 // until ~GrTestTarget(). |
60 SkAutoTUnref<GrDrawTarget> dt(fDrawingManager->newDrawTarget(nullptr)); | 60 GrSurfaceDesc desc; |
| 61 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 62 desc.fWidth = 256; |
| 63 desc.fHeight = 256; |
| 64 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 65 desc.fSampleCnt = 0; |
| 66 |
| 67 GrTexture* texture = this->textureProvider()->createTexture(desc, false, nul
lptr, 0); |
| 68 if (nullptr == texture) { |
| 69 return; |
| 70 } |
| 71 SkASSERT(nullptr != texture->asRenderTarget()); |
| 72 GrRenderTarget* rt = texture->asRenderTarget(); |
| 73 |
| 74 SkAutoTUnref<GrDrawTarget> dt(fDrawingManager->newDrawTarget(rt)); |
61 tar->init(this, dt); | 75 tar->init(this, dt); |
62 } | 76 } |
63 | 77 |
64 void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) { | 78 void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) { |
65 fTextBlobCache->setBudget(bytes); | 79 fTextBlobCache->setBudget(bytes); |
66 } | 80 } |
67 | 81 |
68 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
nfigs) { | 82 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
nfigs) { |
69 fBatchFontCache->setAtlasSizes_ForTesting(configs); | 83 fBatchFontCache->setAtlasSizes_ForTesting(configs); |
70 } | 84 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 GrBatchFontCache* cache = this->getBatchFontCache(); | 118 GrBatchFontCache* cache = this->getBatchFontCache(); |
105 | 119 |
106 GrTexture* atlas = cache->getTexture(format); | 120 GrTexture* atlas = cache->getTexture(format); |
107 | 121 |
108 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(target)); | 122 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(target)); |
109 // TODO: add drawContext method to encapsulate this. | 123 // TODO: add drawContext method to encapsulate this. |
110 | 124 |
111 GrPaint grPaint; | 125 GrPaint grPaint; |
112 SkMatrix mat; | 126 SkMatrix mat; |
113 mat.reset(); | 127 mat.reset(); |
114 if (!SkPaintToGrPaint(this, paint, mat, &grPaint)) { | 128 if (!SkPaintToGrPaint(this, paint, mat, &grPaint, target)) { |
115 return; | 129 return; |
116 } | 130 } |
117 SkMatrix textureMat; | 131 SkMatrix textureMat; |
118 textureMat.reset(); | 132 textureMat.reset(); |
119 // TODO: use setScaleTranslate() | 133 // TODO: use setScaleTranslate() |
120 textureMat[SkMatrix::kMScaleX] = 1.0f/rect.width(); | 134 textureMat[SkMatrix::kMScaleX] = 1.0f/rect.width(); |
121 textureMat[SkMatrix::kMScaleY] = 1.0f/rect.height(); | 135 textureMat[SkMatrix::kMScaleY] = 1.0f/rect.height(); |
122 textureMat[SkMatrix::kMTransX] = -rect.fLeft/rect.width(); | 136 textureMat[SkMatrix::kMTransX] = -rect.fLeft/rect.width(); |
123 textureMat[SkMatrix::kMTransY] = -rect.fTop/rect.height(); | 137 textureMat[SkMatrix::kMTransY] = -rect.fTop/rect.height(); |
124 | 138 |
125 grPaint.addColorTextureProcessor(atlas, textureMat); | 139 grPaint.addColorTextureProcessor(atlas, textureMat, target); |
126 | 140 |
127 GrClip clip; | 141 GrClip clip; |
128 drawContext->drawRect(clip, grPaint, mat, rect); | 142 drawContext->drawRect(clip, grPaint, mat, rect); |
129 } | 143 } |
130 | 144 |
131 #if GR_GPU_STATS | 145 #if GR_GPU_STATS |
132 void GrGpu::Stats::dump(SkString* out) { | 146 void GrGpu::Stats::dump(SkString* out) { |
133 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); | 147 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); |
134 out->appendf("Shader Compilations: %d\n", fShaderCompilations); | 148 out->appendf("Shader Compilations: %d\n", fShaderCompilations); |
135 out->appendf("Textures Created: %d\n", fTextureCreates); | 149 out->appendf("Textures Created: %d\n", fTextureCreates); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 SkASSERT(nullptr == fGpu); | 314 SkASSERT(nullptr == fGpu); |
301 fGpu = new MockGpu(this, options); | 315 fGpu = new MockGpu(this, options); |
302 SkASSERT(fGpu); | 316 SkASSERT(fGpu); |
303 this->initCommon(); | 317 this->initCommon(); |
304 | 318 |
305 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 319 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
306 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 320 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
307 // resources in the buffer pools. | 321 // resources in the buffer pools. |
308 fDrawingManager->abandon(); | 322 fDrawingManager->abandon(); |
309 } | 323 } |
OLD | NEW |