| 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) { | 47 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target, GrRenderTarget* rt
) { |
| 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)); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void GrContext::getTestTarget(GrTestTarget* tar) { | 55 void GrContext::getTestTarget(GrTestTarget* tar) { |
| 55 this->flush(); | 56 this->flush(); |
| 56 // We could create a proxy GrDrawTarget that passes through to fGpu until ~G
rTextTarget() and | 57 // 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 | 58 // 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 | 59 // GrDrawTarget and regular drawing. We could also assert or fail in GrConte
xt drawing methods |
| 59 // until ~GrTestTarget(). | 60 // until ~GrTestTarget(). |
| 60 SkAutoTUnref<GrDrawTarget> dt(fDrawingManager->newDrawTarget(nullptr)); | 61 GrSurfaceDesc desc; |
| 61 tar->init(this, dt); | 62 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 63 desc.fWidth = 32; |
| 64 desc.fHeight = 32; |
| 65 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 66 desc.fSampleCnt = 0; |
| 67 |
| 68 SkAutoTUnref<GrTexture> texture(this->textureProvider()->createTexture(desc,
false, nullptr, 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); |
| 62 } | 77 } |
| 63 | 78 |
| 64 void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) { | 79 void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) { |
| 65 fTextBlobCache->setBudget(bytes); | 80 fTextBlobCache->setBudget(bytes); |
| 66 } | 81 } |
| 67 | 82 |
| 68 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
nfigs) { | 83 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
nfigs) { |
| 69 fBatchFontCache->setAtlasSizes_ForTesting(configs); | 84 fBatchFontCache->setAtlasSizes_ForTesting(configs); |
| 70 } | 85 } |
| 71 | 86 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 SkASSERT(nullptr == fGpu); | 315 SkASSERT(nullptr == fGpu); |
| 301 fGpu = new MockGpu(this, options); | 316 fGpu = new MockGpu(this, options); |
| 302 SkASSERT(fGpu); | 317 SkASSERT(fGpu); |
| 303 this->initCommon(); | 318 this->initCommon(); |
| 304 | 319 |
| 305 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 320 // 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 | 321 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
| 307 // resources in the buffer pools. | 322 // resources in the buffer pools. |
| 308 fDrawingManager->abandon(); | 323 fDrawingManager->abandon(); |
| 309 } | 324 } |
| OLD | NEW |