diff options
Diffstat (limited to 'src/core/frontend')
| -rw-r--r-- | src/core/frontend/scope_acquire_window_context.cpp | 18 | ||||
| -rw-r--r-- | src/core/frontend/scope_acquire_window_context.h | 23 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/core/frontend/scope_acquire_window_context.cpp b/src/core/frontend/scope_acquire_window_context.cpp new file mode 100644 index 000000000..3663dad17 --- /dev/null +++ b/src/core/frontend/scope_acquire_window_context.cpp | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/frontend/emu_window.h" | ||
| 6 | #include "core/frontend/scope_acquire_window_context.h" | ||
| 7 | |||
| 8 | namespace Core::Frontend { | ||
| 9 | |||
| 10 | ScopeAcquireWindowContext::ScopeAcquireWindowContext(Core::Frontend::EmuWindow& emu_window_) | ||
| 11 | : emu_window{emu_window_} { | ||
| 12 | emu_window.MakeCurrent(); | ||
| 13 | } | ||
| 14 | ScopeAcquireWindowContext::~ScopeAcquireWindowContext() { | ||
| 15 | emu_window.DoneCurrent(); | ||
| 16 | } | ||
| 17 | |||
| 18 | } // namespace Core::Frontend | ||
diff --git a/src/core/frontend/scope_acquire_window_context.h b/src/core/frontend/scope_acquire_window_context.h new file mode 100644 index 000000000..2d9f6e825 --- /dev/null +++ b/src/core/frontend/scope_acquire_window_context.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | namespace Core::Frontend { | ||
| 10 | |||
| 11 | class EmuWindow; | ||
| 12 | |||
| 13 | /// Helper class to acquire/release window context within a given scope | ||
| 14 | class ScopeAcquireWindowContext : NonCopyable { | ||
| 15 | public: | ||
| 16 | explicit ScopeAcquireWindowContext(Core::Frontend::EmuWindow& window); | ||
| 17 | ~ScopeAcquireWindowContext(); | ||
| 18 | |||
| 19 | private: | ||
| 20 | Core::Frontend::EmuWindow& emu_window; | ||
| 21 | }; | ||
| 22 | |||
| 23 | } // namespace Core::Frontend | ||