From 5526a1d9055e131f711c2bfae3d4a14a6180bdb8 Mon Sep 17 00:00:00 2001 From: BearOso Date: Thu, 1 Jun 2023 18:01:08 -0500 Subject: [PATCH] Add missing files. --- frontend-common/opengl_context.hpp | 30 ++++++++++++++++ frontend-common/wayland_egl_context.hpp | 41 +++++++++++++++++++++ frontend-common/wayland_surface.hpp | 48 +++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 frontend-common/opengl_context.hpp create mode 100644 frontend-common/wayland_egl_context.hpp create mode 100644 frontend-common/wayland_surface.hpp diff --git a/frontend-common/opengl_context.hpp b/frontend-common/opengl_context.hpp new file mode 100644 index 00000000..62b1c10e --- /dev/null +++ b/frontend-common/opengl_context.hpp @@ -0,0 +1,30 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +#ifndef __GTK_OPENGL_CONTEXT_H +#define __GTK_OPENGL_CONTEXT_H + +class OpenGLContext +{ + public: + virtual ~OpenGLContext(){}; + virtual bool create_context() = 0; + virtual void resize() = 0; + virtual void swap_buffers() = 0; + virtual void swap_interval(int frames) = 0; + virtual void make_current() = 0; + virtual bool ready() + { + return true; + }; + + int x; + int y; + int width; + int height; +}; + +#endif diff --git a/frontend-common/wayland_egl_context.hpp b/frontend-common/wayland_egl_context.hpp new file mode 100644 index 00000000..be91bba5 --- /dev/null +++ b/frontend-common/wayland_egl_context.hpp @@ -0,0 +1,41 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +#ifndef __WAYLAND_EGL_CONTEXT_H +#define __WAYLAND_EGL_CONTEXT_H + +#include "opengl_context.hpp" +#include "wayland_surface.hpp" + +#include "../external/glad/include/glad/egl.h" +#include +#include + +class WaylandEGLContext : public OpenGLContext +{ + public: + WaylandEGLContext(); + ~WaylandEGLContext(); + bool attach(wl_display *display, wl_surface *surface, WaylandSurface::Metrics m); + bool create_context(); + void resize() {}; + void resize(WaylandSurface::Metrics m); + void swap_buffers(); + void swap_interval(int frames); + void make_current(); + bool ready(); + + EGLDisplay egl_display; + EGLSurface egl_surface; + EGLContext egl_context; + EGLConfig egl_config; + + wl_egl_window *egl_window; + + std::unique_ptr wayland_surface; +}; + +#endif diff --git a/frontend-common/wayland_surface.hpp b/frontend-common/wayland_surface.hpp new file mode 100644 index 00000000..647ceb7e --- /dev/null +++ b/frontend-common/wayland_surface.hpp @@ -0,0 +1,48 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +#pragma once + +#include "viewporter-client-protocol.h" +#include "fractional-scale-v1.h" +#include + +class WaylandSurface +{ + public: + WaylandSurface(); + ~WaylandSurface(); + + struct Metrics { + int x, y, width, height, scale; + }; + + bool attach(wl_display *display, wl_surface *surface, Metrics source_metrics); + void resize(Metrics new_metrics); + std::tuple get_size(); + + struct wl_display *display; + struct wl_registry *registry; + struct wl_compositor *compositor; + struct wl_subcompositor *subcompositor; + + struct wl_surface *parent; + struct wl_surface *child; + struct wl_subsurface *subsurface; + struct wl_region *region; + + Metrics metrics; + double actual_scale; + + struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager; + struct zwp_idle_inhibitor_v1 *idle_inhibitor; + + struct wp_viewporter *viewporter; + struct wp_viewport *viewport; + + struct wp_fractional_scale_manager_v1 *fractional_scale_manager; + struct wp_fractional_scale_v1 *fractional_scale; +};