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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 configs[kARGB_GrMaskFormat].fWidth = dim; | 38 configs[kARGB_GrMaskFormat].fWidth = dim; |
39 configs[kARGB_GrMaskFormat].fHeight = dim; | 39 configs[kARGB_GrMaskFormat].fHeight = dim; |
40 configs[kARGB_GrMaskFormat].fPlotWidth = dim; | 40 configs[kARGB_GrMaskFormat].fPlotWidth = dim; |
41 configs[kARGB_GrMaskFormat].fPlotHeight = dim; | 41 configs[kARGB_GrMaskFormat].fPlotHeight = dim; |
42 | 42 |
43 context->setTextContextAtlasSizes_ForTesting(configs); | 43 context->setTextContextAtlasSizes_ForTesting(configs); |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target, GrRenderTarget* rt
) { | 47 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) { |
48 SkASSERT(!fContext); | 48 SkASSERT(!fContext); |
49 | 49 |
50 fContext.reset(SkRef(ctx)); | 50 fContext.reset(SkRef(ctx)); |
51 fDrawTarget.reset(SkRef(target)); | 51 fDrawTarget.reset(SkRef(target)); |
52 fRenderTarget.reset(SkRef(rt)); | |
53 } | 52 } |
54 | 53 |
55 void GrContext::getTestTarget(GrTestTarget* tar) { | 54 void GrContext::getTestTarget(GrTestTarget* tar) { |
56 this->flush(); | 55 this->flush(); |
57 // 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 |
58 // 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 |
59 // 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 |
60 // until ~GrTestTarget(). | 59 // until ~GrTestTarget(). |
61 GrSurfaceDesc desc; | 60 SkAutoTUnref<GrDrawTarget> dt(fDrawingManager->newDrawTarget(nullptr)); |
62 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 61 tar->init(this, dt); |
63 desc.fWidth = 32; | |
64 desc.fHeight = 32; | |
65 desc.fConfig = kRGBA_8888_GrPixelConfig; | |
66 desc.fSampleCnt = 0; | |
67 | |
68 GrTexture* texture = this->textureProvider()->createTexture(desc, false, nul
lptr, 0); | |
69 if (nullptr == texture) { | |
70 return; | |
71 } | |
72 SkASSERT(nullptr != texture->asRenderTarget()); | |
73 GrRenderTarget* rt = texture->asRenderTarget(); | |
74 | |
75 SkAutoTUnref<GrDrawTarget> dt(fDrawingManager->newDrawTarget(rt)); | |
76 tar->init(this, dt, rt); | |
77 } | 62 } |
78 | 63 |
79 void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) { | 64 void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) { |
80 fTextBlobCache->setBudget(bytes); | 65 fTextBlobCache->setBudget(bytes); |
81 } | 66 } |
82 | 67 |
83 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
nfigs) { | 68 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
nfigs) { |
84 fBatchFontCache->setAtlasSizes_ForTesting(configs); | 69 fBatchFontCache->setAtlasSizes_ForTesting(configs); |
85 } | 70 } |
86 | 71 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 SkASSERT(nullptr == fGpu); | 300 SkASSERT(nullptr == fGpu); |
316 fGpu = new MockGpu(this, options); | 301 fGpu = new MockGpu(this, options); |
317 SkASSERT(fGpu); | 302 SkASSERT(fGpu); |
318 this->initCommon(); | 303 this->initCommon(); |
319 | 304 |
320 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 305 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
321 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 306 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
322 // resources in the buffer pools. | 307 // resources in the buffer pools. |
323 fDrawingManager->abandon(); | 308 fDrawingManager->abandon(); |
324 } | 309 } |
OLD | NEW |