| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target, GrRenderTarget* rt
) { | 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 fRenderTarget.reset(SkRef(rt)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void GrContext::getTestTarget(GrTestTarget* tar) { | 55 void GrContext::getTestTarget(GrTestTarget* tar, GrRenderTarget* rt) { |
| 56 this->flush(); | 56 this->flush(); |
| 57 // 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 |
| 58 // 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 |
| 59 // 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 |
| 60 // until ~GrTestTarget(). | 60 // until ~GrTestTarget(). |
| 61 GrSurfaceDesc desc; | 61 if (!rt) { |
| 62 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 62 GrSurfaceDesc desc; |
| 63 desc.fWidth = 32; | 63 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 64 desc.fHeight = 32; | 64 desc.fWidth = 32; |
| 65 desc.fConfig = kRGBA_8888_GrPixelConfig; | 65 desc.fHeight = 32; |
| 66 desc.fSampleCnt = 0; | 66 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 67 desc.fSampleCnt = 0; |
| 67 | 68 |
| 68 SkAutoTUnref<GrTexture> texture(this->textureProvider()->createTexture(desc,
false, nullptr, 0)); | 69 SkAutoTUnref<GrTexture> texture(this->textureProvider()->createTexture(d
esc, false, |
| 69 if (nullptr == texture) { | 70 n
ullptr, 0)); |
| 70 return; | 71 if (nullptr == texture) { |
| 72 return; |
| 73 } |
| 74 SkASSERT(nullptr != texture->asRenderTarget()); |
| 75 rt = texture->asRenderTarget(); |
| 71 } | 76 } |
| 72 SkASSERT(nullptr != texture->asRenderTarget()); | |
| 73 GrRenderTarget* rt = texture->asRenderTarget(); | |
| 74 | 77 |
| 75 SkAutoTUnref<GrDrawTarget> dt(fDrawingManager->newDrawTarget(rt)); | 78 SkAutoTUnref<GrDrawTarget> dt(fDrawingManager->newDrawTarget(rt)); |
| 76 tar->init(this, dt, rt); | 79 tar->init(this, dt, rt); |
| 77 } | 80 } |
| 78 | 81 |
| 79 void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) { | 82 void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) { |
| 80 fTextBlobCache->setBudget(bytes); | 83 fTextBlobCache->setBudget(bytes); |
| 81 } | 84 } |
| 82 | 85 |
| 83 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
nfigs) { | 86 void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* co
nfigs) { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 SkASSERT(nullptr == fGpu); | 318 SkASSERT(nullptr == fGpu); |
| 316 fGpu = new MockGpu(this, options); | 319 fGpu = new MockGpu(this, options); |
| 317 SkASSERT(fGpu); | 320 SkASSERT(fGpu); |
| 318 this->initCommon(); | 321 this->initCommon(); |
| 319 | 322 |
| 320 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 323 // 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 | 324 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
| 322 // resources in the buffer pools. | 325 // resources in the buffer pools. |
| 323 fDrawingManager->abandon(); | 326 fDrawingManager->abandon(); |
| 324 } | 327 } |
| OLD | NEW |