diff options
author | Brian Salomon <bsalomon@google.com> | 2017-11-17 09:25:23 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-17 16:22:56 +0000 |
commit | 55ad77481290384038d7638ac4136ebf32a4ee2b (patch) | |
tree | c5c99f170efa149a933d0839c7ae96645e25c243 /tools/gpu/GrContextFactory.cpp | |
parent | 3e4d1fde7fab46875cb70e23003b40aac262f0bc (diff) |
Revert "Revert "Add method to sk_gpu_test::TestContext to automatically restore the previous context.""
This reverts commit 1e09e461d2ffcf8b07242cfe93dd7d12c4d75866.
Change-Id: I95d5544a7baaa078536790493ce4119816a77e94
Reviewed-on: https://skia-review.googlesource.com/72903
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools/gpu/GrContextFactory.cpp')
-rw-r--r-- | tools/gpu/GrContextFactory.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp index 21766db2b8..00c4b65edc 100644 --- a/tools/gpu/GrContextFactory.cpp +++ b/tools/gpu/GrContextFactory.cpp @@ -52,8 +52,9 @@ GrContextFactory::~GrContextFactory() { void GrContextFactory::destroyContexts() { for (Context& context : fContexts) { + SkScopeExit restore(nullptr); if (context.fTestContext) { - context.fTestContext->makeCurrent(); + restore = context.fTestContext->makeCurrentAndAutoRestore(); } if (!context.fGrContext->unique()) { context.fGrContext->releaseResourcesAndAbandonContext(); @@ -69,7 +70,7 @@ void GrContextFactory::abandonContexts() { for (Context& context : fContexts) { if (!context.fAbandoned) { if (context.fTestContext) { - context.fTestContext->makeCurrent(); + auto restore = context.fTestContext->makeCurrentAndAutoRestore(); context.fTestContext->testAbandon(); delete(context.fTestContext); context.fTestContext = nullptr; @@ -82,9 +83,10 @@ void GrContextFactory::abandonContexts() { void GrContextFactory::releaseResourcesAndAbandonContexts() { for (Context& context : fContexts) { + SkScopeExit restore(nullptr); if (!context.fAbandoned) { if (context.fTestContext) { - context.fTestContext->makeCurrent(); + restore = context.fTestContext->makeCurrentAndAutoRestore(); } context.fGrContext->releaseResourcesAndAbandonContext(); context.fAbandoned = true; @@ -237,7 +239,7 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv default: return ContextInfo(); } - testCtx->makeCurrent(); + SkASSERT(testCtx && testCtx->backend() == backend); GrContextOptions grOptions = fGlobalOptions; if (ContextOverrides::kDisableNVPR & overrides) { @@ -252,7 +254,11 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv if (ContextOverrides::kAvoidStencilBuffers & overrides) { grOptions.fAvoidStencilBuffers = true; } - sk_sp<GrContext> grCtx = testCtx->makeGrContext(grOptions); + sk_sp<GrContext> grCtx; + { + auto restore = testCtx->makeCurrentAndAutoRestore(); + grCtx = testCtx->makeGrContext(grOptions); + } if (!grCtx.get()) { return ContextInfo(); } @@ -282,6 +288,7 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv context.fShareContext = shareContext; context.fShareIndex = shareIndex; context.fOptions = grOptions; + context.fTestContext->makeCurrent(); return ContextInfo(context.fType, context.fTestContext, context.fGrContext, context.fOptions); } |