diff options
author | 2017-11-16 10:17:20 -0500 | |
---|---|---|
committer | 2017-11-16 16:30:53 +0000 | |
commit | 5627d65146cb92624b682389e017d488872228c7 (patch) | |
tree | 9b90fe789341a23d05dc0e896eeafc1a20b70a26 /tools/gpu/TestContext.cpp | |
parent | 47f6029d3dc5ee9e484931a13a14dcbe9d3f23d3 (diff) |
Add method to sk_gpu_test::TestContext to automatically restore the previous context.
The motivation for this is to allow a GM to create a GL context, do some some work in it, and then return to the context that was set when it was invoked.
Change-Id: Ie8496072a10f8f3ff36a08889e593a6ca961b61a
Reviewed-on: https://skia-review.googlesource.com/70720
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools/gpu/TestContext.cpp')
-rw-r--r-- | tools/gpu/TestContext.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/gpu/TestContext.cpp b/tools/gpu/TestContext.cpp index c80c4ea4df..f760cc7738 100644 --- a/tools/gpu/TestContext.cpp +++ b/tools/gpu/TestContext.cpp @@ -37,8 +37,15 @@ sk_sp<GrContext> TestContext::makeGrContext(const GrContextOptions&) { void TestContext::makeCurrent() const { this->onPlatformMakeCurrent(); } +SkScopeExit TestContext::makeCurrentAndAutoRestore() const { + auto asr = SkScopeExit(this->onPlatformGetAutoContextRestore()); + this->makeCurrent(); + return asr; +} + void TestContext::swapBuffers() { this->onPlatformSwapBuffers(); } + void TestContext::waitOnSyncOrSwap() { if (!fFenceSync) { // Fallback on the platform SwapBuffers method for synchronization. This may have no effect. |