diff options
author | Brian Salomon <bsalomon@google.com> | 2017-11-16 10:17:20 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-16 16:30:53 +0000 |
commit | 5627d65146cb92624b682389e017d488872228c7 (patch) | |
tree | 9b90fe789341a23d05dc0e896eeafc1a20b70a26 /src/pdf | |
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 'src/pdf')
-rw-r--r-- | src/pdf/SkScopeExit.h | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/pdf/SkScopeExit.h b/src/pdf/SkScopeExit.h deleted file mode 100644 index 5b7bcdc076..0000000000 --- a/src/pdf/SkScopeExit.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef SkScopeExit_DEFINED -#define SkScopeExit_DEFINED - -#include "SkTypes.h" - -/** - * SK_AT_SCOPE_EXIT(stmt) evaluates stmt when the current scope ends. - * - * E.g. - * { - * int x = 5; - * { - * SK_AT_SCOPE_EXIT(x--); - * SkASSERT(x == 5); - * } - * SkASSERT(x == 4); - * } - */ -template <typename Fn> -class SkScopeExit { -public: - SkScopeExit(Fn f) : fFn(std::move(f)) {} - ~SkScopeExit() { fFn(); } - -private: - Fn fFn; - - SkScopeExit( const SkScopeExit& ) = delete; - SkScopeExit& operator=(const SkScopeExit& ) = delete; - SkScopeExit( SkScopeExit&&) = delete; - SkScopeExit& operator=( SkScopeExit&&) = delete; -}; - -template <typename Fn> -inline SkScopeExit<Fn> SkMakeScopeExit(Fn&& fn) { - return {std::move(fn)}; -} - -#define SK_AT_SCOPE_EXIT(stmt) \ - SK_UNUSED auto&& SK_MACRO_APPEND_LINE(at_scope_exit_) = \ - SkMakeScopeExit([&]() { stmt; }); - -#endif // SkScopeExit_DEFINED |