| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrTest.h" | 8 #include "GrTest.h" |
| 9 | 9 |
| 10 #include "GrBatchAtlas.h" | 10 #include "GrBatchAtlas.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 configs[kARGB_GrMaskFormat].fHeight = dim; | 45 configs[kARGB_GrMaskFormat].fHeight = dim; |
| 46 configs[kARGB_GrMaskFormat].fLog2Width = SkNextLog2(dim); | 46 configs[kARGB_GrMaskFormat].fLog2Width = SkNextLog2(dim); |
| 47 configs[kARGB_GrMaskFormat].fLog2Height = SkNextLog2(dim); | 47 configs[kARGB_GrMaskFormat].fLog2Height = SkNextLog2(dim); |
| 48 configs[kARGB_GrMaskFormat].fPlotWidth = dim; | 48 configs[kARGB_GrMaskFormat].fPlotWidth = dim; |
| 49 configs[kARGB_GrMaskFormat].fPlotHeight = dim; | 49 configs[kARGB_GrMaskFormat].fPlotHeight = dim; |
| 50 | 50 |
| 51 context->setTextContextAtlasSizes_ForTesting(configs); | 51 context->setTextContextAtlasSizes_ForTesting(configs); |
| 52 } | 52 } |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target, GrRenderTarget* rt
) { | 55 void GrTestTarget::init(GrContext* ctx, sk_sp<GrDrawContext> drawContext) { |
| 56 SkASSERT(!fContext); | 56 SkASSERT(!fContext); |
| 57 | 57 |
| 58 fContext.reset(SkRef(ctx)); | 58 fContext.reset(SkRef(ctx)); |
| 59 fDrawTarget.reset(SkRef(target)); | 59 fDrawContext = drawContext; |
| 60 fRenderTarget.reset(SkRef(rt)); | |
| 61 } | 60 } |
| 62 | 61 |
| 63 void GrContext::getTestTarget(GrTestTarget* tar, GrRenderTarget* rt) { | 62 void GrContext::getTestTarget(GrTestTarget* tar, sk_sp<GrDrawContext> drawContex
t) { |
| 64 this->flush(); | 63 this->flush(); |
| 64 SkASSERT(drawContext); |
| 65 // We could create a proxy GrDrawTarget that passes through to fGpu until ~G
rTextTarget() and | 65 // We could create a proxy GrDrawTarget that passes through to fGpu until ~G
rTextTarget() and |
| 66 // then disconnects. This would help prevent test writers from mixing using
the returned | 66 // then disconnects. This would help prevent test writers from mixing using
the returned |
| 67 // GrDrawTarget and regular drawing. We could also assert or fail in GrConte
xt drawing methods | 67 // GrDrawTarget and regular drawing. We could also assert or fail in GrConte
xt drawing methods |
| 68 // until ~GrTestTarget(). | 68 // until ~GrTestTarget(). |
| 69 if (!rt) { | 69 tar->init(this, std::move(drawContext)); |
| 70 GrSurfaceDesc desc; | |
| 71 desc.fFlags = kRenderTarget_GrSurfaceFlag; | |
| 72 desc.fWidth = 32; | |
| 73 desc.fHeight = 32; | |
| 74 desc.fConfig = kRGBA_8888_GrPixelConfig; | |
| 75 desc.fSampleCnt = 0; | |
| 76 | |
| 77 SkAutoTUnref<GrTexture> texture(this->textureProvider()->createTexture( | |
| 78 desc, SkBudgeted::kNo, nullptr, 0)); | |
| 79 if (nullptr == texture) { | |
| 80 return; | |
| 81 } | |
| 82 SkASSERT(nullptr != texture->asRenderTarget()); | |
| 83 rt = texture->asRenderTarget(); | |
| 84 } | |
| 85 | |
| 86 SkAutoTUnref<GrDrawTarget> dt(fDrawingManager->newDrawTarget(rt)); | |
| 87 tar->init(this, dt, rt); | |
| 88 } | 70 } |
| 89 | 71 |
| 90 void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) { | 72 void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) { |
| 91 fTextBlobCache->setBudget(bytes); | 73 fTextBlobCache->setBudget(bytes); |
| 92 } | 74 } |
| 93 | 75 |
| 94 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
nfigs) { | 76 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
nfigs) { |
| 95 fBatchFontCache->setAtlasSizes_ForTesting(configs); | 77 fBatchFontCache->setAtlasSizes_ForTesting(configs); |
| 96 } | 78 } |
| 97 | 79 |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 SkASSERT(nullptr == fGpu); | 397 SkASSERT(nullptr == fGpu); |
| 416 fGpu = new MockGpu(this, options); | 398 fGpu = new MockGpu(this, options); |
| 417 SkASSERT(fGpu); | 399 SkASSERT(fGpu); |
| 418 this->initCommon(options); | 400 this->initCommon(options); |
| 419 | 401 |
| 420 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 402 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
| 421 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 403 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
| 422 // resources in the buffer pools. | 404 // resources in the buffer pools. |
| 423 fDrawingManager->abandon(); | 405 fDrawingManager->abandon(); |
| 424 } | 406 } |
| OLD | NEW |