diff options
| author | 2023-06-05 21:43:43 -0700 | |
|---|---|---|
| committer | 2023-06-05 21:43:43 -0700 | |
| commit | cb95d7fe1b6d81899fe6b279400da2c991e3132c (patch) | |
| tree | a856ac45b1053009c4c11ee141c49d7faa4c8a19 /src/core/frontend | |
| parent | Merge pull request #10611 from liamwhite/audio-deadlock (diff) | |
| parent | Merge pull request #10633 from t895/variable-surface-ratio (diff) | |
| download | yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar.gz yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar.xz yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.zip | |
Merge pull request #10508 from yuzu-emu/lime
Project Lime - yuzu Android Port
Diffstat (limited to 'src/core/frontend')
| -rw-r--r-- | src/core/frontend/emu_window.cpp | 2 | ||||
| -rw-r--r-- | src/core/frontend/emu_window.h | 48 | ||||
| -rw-r--r-- | src/core/frontend/graphics_context.h | 62 |
3 files changed, 65 insertions, 47 deletions
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index 1be2dccb0..d1f1ca8c9 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp | |||
| @@ -6,8 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | namespace Core::Frontend { | 7 | namespace Core::Frontend { |
| 8 | 8 | ||
| 9 | GraphicsContext::~GraphicsContext() = default; | ||
| 10 | |||
| 11 | EmuWindow::EmuWindow() { | 9 | EmuWindow::EmuWindow() { |
| 12 | // TODO: Find a better place to set this. | 10 | // TODO: Find a better place to set this. |
| 13 | config.min_client_area_size = | 11 | config.min_client_area_size = |
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index 1093800f6..a72df034e 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h | |||
| @@ -5,11 +5,14 @@ | |||
| 5 | 5 | ||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <utility> | 7 | #include <utility> |
| 8 | |||
| 8 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 9 | #include "core/frontend/framebuffer_layout.h" | 10 | #include "core/frontend/framebuffer_layout.h" |
| 10 | 11 | ||
| 11 | namespace Core::Frontend { | 12 | namespace Core::Frontend { |
| 12 | 13 | ||
| 14 | class GraphicsContext; | ||
| 15 | |||
| 13 | /// Information for the Graphics Backends signifying what type of screen pointer is in | 16 | /// Information for the Graphics Backends signifying what type of screen pointer is in |
| 14 | /// WindowInformation | 17 | /// WindowInformation |
| 15 | enum class WindowSystemType { | 18 | enum class WindowSystemType { |
| @@ -22,51 +25,6 @@ enum class WindowSystemType { | |||
| 22 | }; | 25 | }; |
| 23 | 26 | ||
| 24 | /** | 27 | /** |
| 25 | * Represents a drawing context that supports graphics operations. | ||
| 26 | */ | ||
| 27 | class GraphicsContext { | ||
| 28 | public: | ||
| 29 | virtual ~GraphicsContext(); | ||
| 30 | |||
| 31 | /// Inform the driver to swap the front/back buffers and present the current image | ||
| 32 | virtual void SwapBuffers() {} | ||
| 33 | |||
| 34 | /// Makes the graphics context current for the caller thread | ||
| 35 | virtual void MakeCurrent() {} | ||
| 36 | |||
| 37 | /// Releases (dunno if this is the "right" word) the context from the caller thread | ||
| 38 | virtual void DoneCurrent() {} | ||
| 39 | |||
| 40 | class Scoped { | ||
| 41 | public: | ||
| 42 | [[nodiscard]] explicit Scoped(GraphicsContext& context_) : context(context_) { | ||
| 43 | context.MakeCurrent(); | ||
| 44 | } | ||
| 45 | ~Scoped() { | ||
| 46 | if (active) { | ||
| 47 | context.DoneCurrent(); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | /// In the event that context was destroyed before the Scoped is destroyed, this provides a | ||
| 52 | /// mechanism to prevent calling a destroyed object's method during the deconstructor | ||
| 53 | void Cancel() { | ||
| 54 | active = false; | ||
| 55 | } | ||
| 56 | |||
| 57 | private: | ||
| 58 | GraphicsContext& context; | ||
| 59 | bool active{true}; | ||
| 60 | }; | ||
| 61 | |||
| 62 | /// Calls MakeCurrent on the context and calls DoneCurrent when the scope for the returned value | ||
| 63 | /// ends | ||
| 64 | [[nodiscard]] Scoped Acquire() { | ||
| 65 | return Scoped{*this}; | ||
| 66 | } | ||
| 67 | }; | ||
| 68 | |||
| 69 | /** | ||
| 70 | * Abstraction class used to provide an interface between emulation code and the frontend | 28 | * Abstraction class used to provide an interface between emulation code and the frontend |
| 71 | * (e.g. SDL, QGLWidget, GLFW, etc...). | 29 | * (e.g. SDL, QGLWidget, GLFW, etc...). |
| 72 | * | 30 | * |
diff --git a/src/core/frontend/graphics_context.h b/src/core/frontend/graphics_context.h new file mode 100644 index 000000000..7554c1583 --- /dev/null +++ b/src/core/frontend/graphics_context.h | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <memory> | ||
| 7 | |||
| 8 | #include "common/dynamic_library.h" | ||
| 9 | |||
| 10 | namespace Core::Frontend { | ||
| 11 | |||
| 12 | /** | ||
| 13 | * Represents a drawing context that supports graphics operations. | ||
| 14 | */ | ||
| 15 | class GraphicsContext { | ||
| 16 | public: | ||
| 17 | virtual ~GraphicsContext() = default; | ||
| 18 | |||
| 19 | /// Inform the driver to swap the front/back buffers and present the current image | ||
| 20 | virtual void SwapBuffers() {} | ||
| 21 | |||
| 22 | /// Makes the graphics context current for the caller thread | ||
| 23 | virtual void MakeCurrent() {} | ||
| 24 | |||
| 25 | /// Releases (dunno if this is the "right" word) the context from the caller thread | ||
| 26 | virtual void DoneCurrent() {} | ||
| 27 | |||
| 28 | /// Gets the GPU driver library (used by Android only) | ||
| 29 | virtual std::shared_ptr<Common::DynamicLibrary> GetDriverLibrary() { | ||
| 30 | return {}; | ||
| 31 | } | ||
| 32 | |||
| 33 | class Scoped { | ||
| 34 | public: | ||
| 35 | [[nodiscard]] explicit Scoped(GraphicsContext& context_) : context(context_) { | ||
| 36 | context.MakeCurrent(); | ||
| 37 | } | ||
| 38 | ~Scoped() { | ||
| 39 | if (active) { | ||
| 40 | context.DoneCurrent(); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | /// In the event that context was destroyed before the Scoped is destroyed, this provides a | ||
| 45 | /// mechanism to prevent calling a destroyed object's method during the deconstructor | ||
| 46 | void Cancel() { | ||
| 47 | active = false; | ||
| 48 | } | ||
| 49 | |||
| 50 | private: | ||
| 51 | GraphicsContext& context; | ||
| 52 | bool active{true}; | ||
| 53 | }; | ||
| 54 | |||
| 55 | /// Calls MakeCurrent on the context and calls DoneCurrent when the scope for the returned value | ||
| 56 | /// ends | ||
| 57 | [[nodiscard]] Scoped Acquire() { | ||
| 58 | return Scoped{*this}; | ||
| 59 | } | ||
| 60 | }; | ||
| 61 | |||
| 62 | } // namespace Core::Frontend | ||