From dfee4c3995f0e2ff14f17176b7d35bbf6db47c17 Mon Sep 17 00:00:00 2001 From: riidefi <34194588+riidefi@users.noreply.github.com> Date: Thu, 13 Jun 2024 20:28:05 -0600 Subject: [PATCH] [brres-sys] Drop `plate` dep --- .../lib/brres-sys/src/core/util/oishii.hpp | 1 - .../brres-sys/src/vendor/plate/Platform.hpp | 111 ------------------ .../lib/brres-sys/src/vendor/plate/gl.hpp | 14 --- .../src/vendor/plate/toolkit/Viewport.hpp | 85 -------------- 4 files changed, 211 deletions(-) delete mode 100644 source/brres/lib/brres-sys/src/vendor/plate/Platform.hpp delete mode 100644 source/brres/lib/brres-sys/src/vendor/plate/gl.hpp delete mode 100644 source/brres/lib/brres-sys/src/vendor/plate/toolkit/Viewport.hpp diff --git a/source/brres/lib/brres-sys/src/core/util/oishii.hpp b/source/brres/lib/brres-sys/src/core/util/oishii.hpp index 7785f6268..436c2559f 100644 --- a/source/brres/lib/brres-sys/src/core/util/oishii.hpp +++ b/source/brres/lib/brres-sys/src/core/util/oishii.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include inline std::optional> diff --git a/source/brres/lib/brres-sys/src/vendor/plate/Platform.hpp b/source/brres/lib/brres-sys/src/vendor/plate/Platform.hpp deleted file mode 100644 index 76b73a6aa..000000000 --- a/source/brres/lib/brres-sys/src/vendor/plate/Platform.hpp +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @file - * @brief Headers for the root platform/window interface. Implemented in - * impl/glfw_win32.cpp, impl/sdl_ems.cpp - */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace plate { - -struct FileData { - std::unique_ptr mData; - std::size_t mLen; - std::string mPath; - - FileData(std::unique_ptr data, std::size_t len, - const std::string& path) - : mData(std::move(data)), mLen(len), mPath(path) {} -}; - -class Platform { -public: - /** - * @brief The constructor. - * - * @param width Initial width of the window. - * @param height Initial height of the window. - * @param title Initial title of the window. This will be the name of the - * browser tab on web platforms. - */ - Platform(unsigned width, unsigned height, const std::string& title); - - /** - * @brief The destructor. - */ - virtual ~Platform(); - - /** - * @brief Enter the main loop. - */ - void enter(); - -protected: - /** - * @brief Process each frame. - */ - virtual void rootCalc() {} - - /** - * @brief Render each frame. - */ - virtual void rootDraw() {} - -public: - /** - * @brief Handle a file being dropped on the application. - * - * @details Called at the beginning of each frame, before calc/draw. - * - * @param data File data. - * @param len Length of the data buffer. - * @param name Path of the file on disc. - */ - virtual void vdropDirect(std::unique_ptr data, std::size_t len, - const std::string& name) {} - - static bool supportsFileDialogues(); - - /** - * @brief Write a file to disc. On the web backend, the file will - * instead be supplied as a download. - * - * @param data Binary blob. - * @param path Path to write the file at. - * - */ - static void writeFile(const std::span data, const std::string_view path); - - virtual bool shouldClose() { return true; } - - void hideMouse(); - void showMouse(); - - void setVsync(bool enabled); - - void* getPlatformWindow() { return mPlatformWindow; } - std::string getTitle() const { return mTitle; } - - void enqueueDrop(const std::string& path) { mDropQueue.push(path); } - -private: - void* mPlatformWindow = nullptr; - std::string mTitle; - - std::queue mDropQueue; - std::queue mDataDropQueue; - -#ifdef RII_BACKEND_SDL -public: - void mainLoopInternal(); -#endif -}; - -} // namespace plate diff --git a/source/brres/lib/brres-sys/src/vendor/plate/gl.hpp b/source/brres/lib/brres-sys/src/vendor/plate/gl.hpp deleted file mode 100644 index 34876eb3e..000000000 --- a/source/brres/lib/brres-sys/src/vendor/plate/gl.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// Include order matters -#if defined(RII_BACKEND_GLFW) -#include -#define RII_GL -#elif defined(RII_BACKEND_SDL) -#include -#define RII_GL -#endif - -#if defined(RII_BACKEND_GLFW) -#include "glfw/glfw3.h" -#elif defined(RII_BACKEND_SDL) -#include -#endif diff --git a/source/brres/lib/brres-sys/src/vendor/plate/toolkit/Viewport.hpp b/source/brres/lib/brres-sys/src/vendor/plate/toolkit/Viewport.hpp deleted file mode 100644 index f7704179e..000000000 --- a/source/brres/lib/brres-sys/src/vendor/plate/toolkit/Viewport.hpp +++ /dev/null @@ -1,85 +0,0 @@ -#pragma once - -#include - -namespace plate::tk { - -//! The design here is not entirely ImGui style (immediate / stateless), as it -//! is much more efficient to directly hold onto the frame buffer. -//! -class Viewport { -public: - //! The constructor. - //! - Viewport(); - - //! The destructor. - //! - virtual ~Viewport(); - - //! @brief Begin a viewport block. - //! - //! All begin() calls must be paired with an end() call. They cannot be - //! nested. - //! - bool begin(unsigned width, unsigned height); - - //! @brief End a viewport block. - //! - //! It is invalid to call end() when not immediately followed by begin(). - //! - void end(); - -private: - // Create a new FBO (no operation if width/height match) - void createFbo(unsigned width, unsigned height); - - // Destroy the last FBO, freeing memory. Not necessary on first begin() or - // when dimensions match with the last frame. - // Does nothing if no FBO is loaded. - void destroyFbo(); - - struct Flags { - // Have the Color Buffer, FBO, and RBO been loaded? - // (This also implies mLastWidth and mLastHeight are valid) - bool fboLoaded : 1; - // (Debug) Are we in a begin() block? - bool inBegin : 1; - } mFlags{}; - - bool isFboLoaded() const { return mFlags.fboLoaded; } - void setFboLoaded(bool v) { mFlags.fboLoaded = v; } - bool isInBegin() const { return mFlags.inBegin; } - void setInBegin(bool v) { mFlags.inBegin = v; } - - // GL handles - uint32_t mImageBufId = ~static_cast(0); - uint32_t mFboId = ~static_cast(0); - uint32_t mRboId = ~static_cast(0); - -public: - // Remember the last resolution. - struct ResolutionData { - unsigned width = 0; - unsigned height = 0; - - float retina_x = 1.0f; - float retina_y = 1.0f; - - // Adjust for Retina display - int computeGlWidth() const { - return static_cast(static_cast(width) * retina_x); - } - // Adjust for Retina display - int computeGlHeight() const { - return static_cast(static_cast(height) * retina_y); - } - - bool operator==(const ResolutionData&) const = default; - }; - ResolutionData queryResolution(unsigned width, unsigned height) const; - - ResolutionData mLastResolution; -}; - -} // namespace plate::tk