diff options
author | 2015-11-16 11:02:05 -0800 | |
---|---|---|
committer | 2015-11-16 11:02:05 -0800 | |
commit | 504ce5dc772e14be2f5697b00ac82fcf82127763 (patch) | |
tree | 08d896e660c8ac5487152bd84ffb98d26107a17c /src/gpu | |
parent | 3c2d32b8e27820a6e149d9ded67cbdf2411cc5c9 (diff) |
Optionally pass rendertarget to getTestTarget
This shouldn't really make any difference but allocating and holding on to a GrRenderTarget for each test target generates image differences for Mali GPUs. This CL allows an existing render target to be used for the test target.
TBR=bsalomon@google.com
Review URL: https://codereview.chromium.org/1447113002
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrTest.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp index f6ece6c79e..f0f6370254 100644 --- a/src/gpu/GrTest.cpp +++ b/src/gpu/GrTest.cpp @@ -52,25 +52,28 @@ void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target, GrRenderTarget* rt fRenderTarget.reset(SkRef(rt)); } -void GrContext::getTestTarget(GrTestTarget* tar) { +void GrContext::getTestTarget(GrTestTarget* tar, GrRenderTarget* rt) { this->flush(); // We could create a proxy GrDrawTarget that passes through to fGpu until ~GrTextTarget() and // then disconnects. This would help prevent test writers from mixing using the returned // GrDrawTarget and regular drawing. We could also assert or fail in GrContext drawing methods // until ~GrTestTarget(). - GrSurfaceDesc desc; - desc.fFlags = kRenderTarget_GrSurfaceFlag; - desc.fWidth = 32; - desc.fHeight = 32; - desc.fConfig = kRGBA_8888_GrPixelConfig; - desc.fSampleCnt = 0; - - SkAutoTUnref<GrTexture> texture(this->textureProvider()->createTexture(desc, false, nullptr, 0)); - if (nullptr == texture) { - return; + if (!rt) { + GrSurfaceDesc desc; + desc.fFlags = kRenderTarget_GrSurfaceFlag; + desc.fWidth = 32; + desc.fHeight = 32; + desc.fConfig = kRGBA_8888_GrPixelConfig; + desc.fSampleCnt = 0; + + SkAutoTUnref<GrTexture> texture(this->textureProvider()->createTexture(desc, false, + nullptr, 0)); + if (nullptr == texture) { + return; + } + SkASSERT(nullptr != texture->asRenderTarget()); + rt = texture->asRenderTarget(); } - SkASSERT(nullptr != texture->asRenderTarget()); - GrRenderTarget* rt = texture->asRenderTarget(); SkAutoTUnref<GrDrawTarget> dt(fDrawingManager->newDrawTarget(rt)); tar->init(this, dt, rt); |