diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
-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 | 69 |
4 files changed, 73 insertions, 47 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 45328158f..157858c82 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -140,6 +140,7 @@ add_library(core STATIC frontend/emu_window.h frontend/framebuffer_layout.cpp frontend/framebuffer_layout.h + frontend/graphics_context.h hid/emulated_console.cpp hid/emulated_console.h hid/emulated_controller.cpp 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 @@ namespace Core::Frontend { -GraphicsContext::~GraphicsContext() = default; - EmuWindow::EmuWindow() { // TODO: Find a better place to set this. 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 @@ #include <memory> #include <utility> + #include "common/common_types.h" #include "core/frontend/framebuffer_layout.h" namespace Core::Frontend { +class GraphicsContext; + /// Information for the Graphics Backends signifying what type of screen pointer is in /// WindowInformation enum class WindowSystemType { @@ -22,51 +25,6 @@ enum class WindowSystemType { }; /** - * Represents a drawing context that supports graphics operations. - */ -class GraphicsContext { -public: - virtual ~GraphicsContext(); - - /// Inform the driver to swap the front/back buffers and present the current image - virtual void SwapBuffers() {} - - /// Makes the graphics context current for the caller thread - virtual void MakeCurrent() {} - - /// Releases (dunno if this is the "right" word) the context from the caller thread - virtual void DoneCurrent() {} - - class Scoped { - public: - [[nodiscard]] explicit Scoped(GraphicsContext& context_) : context(context_) { - context.MakeCurrent(); - } - ~Scoped() { - if (active) { - context.DoneCurrent(); - } - } - - /// In the event that context was destroyed before the Scoped is destroyed, this provides a - /// mechanism to prevent calling a destroyed object's method during the deconstructor - void Cancel() { - active = false; - } - - private: - GraphicsContext& context; - bool active{true}; - }; - - /// Calls MakeCurrent on the context and calls DoneCurrent when the scope for the returned value - /// ends - [[nodiscard]] Scoped Acquire() { - return Scoped{*this}; - } -}; - -/** * Abstraction class used to provide an interface between emulation code and the frontend * (e.g. SDL, QGLWidget, GLFW, etc...). * diff --git a/src/core/frontend/graphics_context.h b/src/core/frontend/graphics_context.h new file mode 100644 index 000000000..064b19a96 --- /dev/null +++ b/src/core/frontend/graphics_context.h @@ -0,0 +1,69 @@ +// SPDX-FileCopyrightText: 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <optional> +#include <string> + +namespace Core::Frontend { + +/** + * Represents a drawing context that supports graphics operations. + */ +class GraphicsContext { +public: + virtual ~GraphicsContext() = default; + + /// Inform the driver to swap the front/back buffers and present the current image + virtual void SwapBuffers() {} + + /// Makes the graphics context current for the caller thread + virtual void MakeCurrent() {} + + /// Releases (dunno if this is the "right" word) the context from the caller thread + virtual void DoneCurrent() {} + + /// Parameters used to configure custom drivers (used by Android only) + struct CustomDriverParameters { + std::string hook_lib_dir; + std::string custom_driver_dir; + std::string custom_driver_name; + std::string file_redirect_dir; + }; + + /// Gets custom driver parameters configured by the frontend (used by Android only) + virtual std::optional<CustomDriverParameters> GetCustomDriverParameters() { + return {}; + } + + class Scoped { + public: + [[nodiscard]] explicit Scoped(GraphicsContext& context_) : context(context_) { + context.MakeCurrent(); + } + ~Scoped() { + if (active) { + context.DoneCurrent(); + } + } + + /// In the event that context was destroyed before the Scoped is destroyed, this provides a + /// mechanism to prevent calling a destroyed object's method during the deconstructor + void Cancel() { + active = false; + } + + private: + GraphicsContext& context; + bool active{true}; + }; + + /// Calls MakeCurrent on the context and calls DoneCurrent when the scope for the returned value + /// ends + [[nodiscard]] Scoped Acquire() { + return Scoped{*this}; + } +}; + +} // namespace Core::Frontend |