diff --git a/CMakeLists.txt b/CMakeLists.txt index 559ffb6..6d89428 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,16 +158,16 @@ if(WAYLAND_SUPPORT_FOUND) wayland-egl ${OPENGL_egl_LIBRARY}) set(WAYLAND_SOURCES - src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h - src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp - src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.cpp - src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h - src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.cpp - src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h - src/WallpaperEngine/Render/Drivers/Output/CWaylandOutputViewport.cpp - src/WallpaperEngine/Render/Drivers/Output/CWaylandOutputViewport.h - src/WallpaperEngine/Input/Drivers/CWaylandMouseInput.cpp - src/WallpaperEngine/Input/Drivers/CWaylandMouseInput.h + src/WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.h + src/WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.cpp + src/WallpaperEngine/Render/Drivers/Detectors/WaylandFullScreenDetector.cpp + src/WallpaperEngine/Render/Drivers/Detectors/WaylandFullScreenDetector.h + src/WallpaperEngine/Render/Drivers/Output/WaylandOutput.cpp + src/WallpaperEngine/Render/Drivers/Output/WaylandOutput.h + src/WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.cpp + src/WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.h + src/WallpaperEngine/Input/Drivers/WaylandMouseInput.cpp + src/WallpaperEngine/Input/Drivers/WaylandMouseInput.h ${WAYLAND_OUTPUT_DIR}/xdg-shell-protocol.c ${WAYLAND_OUTPUT_DIR}/xdg-shell-protocol.h ${WAYLAND_OUTPUT_DIR}/wlr-foreign-toplevel-management-unstable-v1-protocol.c @@ -197,10 +197,10 @@ if(X11_SUPPORT_FOUND) ${X11_LIBRARIES} ${X11_Xrandr_LIB}) set(X11_SOURCES - src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp - src/WallpaperEngine/Render/Drivers/Output/CX11Output.h - src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp - src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h) + src/WallpaperEngine/Render/Drivers/Output/X11Output.cpp + src/WallpaperEngine/Render/Drivers/Output/X11Output.h + src/WallpaperEngine/Render/Drivers/Detectors/X11FullScreenDetector.cpp + src/WallpaperEngine/Render/Drivers/Detectors/X11FullScreenDetector.h) SET(X11_INCLUDES ${X11_INCLUDE_DIR} ${XRANDR_INCLUDE_DIR}) @@ -259,16 +259,16 @@ add_executable( src/Steam/FileSystem/FileSystem.cpp src/Steam/FileSystem/FileSystem.h - src/WallpaperEngine/Logging/CLog.cpp - src/WallpaperEngine/Logging/CLog.h + src/WallpaperEngine/Logging/Log.cpp + src/WallpaperEngine/Logging/Log.h - src/WallpaperEngine/Application/CApplicationContext.cpp - src/WallpaperEngine/Application/CApplicationContext.h - src/WallpaperEngine/Application/CWallpaperApplication.cpp - src/WallpaperEngine/Application/CWallpaperApplication.h + src/WallpaperEngine/Application/ApplicationContext.cpp + src/WallpaperEngine/Application/ApplicationContext.h + src/WallpaperEngine/Application/WallpaperApplication.cpp + src/WallpaperEngine/Application/WallpaperApplication.h - src/WallpaperEngine/Assets/CAssetLoadException.cpp - src/WallpaperEngine/Assets/CAssetLoadException.h + src/WallpaperEngine/Assets/AssetLoadException.cpp + src/WallpaperEngine/Assets/AssetLoadException.h src/WallpaperEngine/FileSystem/Container.h src/WallpaperEngine/FileSystem/Container.cpp @@ -280,100 +280,99 @@ add_executable( src/WallpaperEngine/FileSystem/Adapters/Virtual.cpp src/WallpaperEngine/FileSystem/Adapters/Virtual.h - src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.cpp - src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.h - src/WallpaperEngine/Audio/Drivers/Recorders/CPlaybackRecorder.cpp - src/WallpaperEngine/Audio/Drivers/Recorders/CPlaybackRecorder.h + src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.cpp + src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.h + src/WallpaperEngine/Audio/Drivers/Recorders/PlaybackRecorder.cpp + src/WallpaperEngine/Audio/Drivers/Recorders/PlaybackRecorder.h - src/WallpaperEngine/Audio/Drivers/Detectors/CPulseAudioPlayingDetector.cpp - src/WallpaperEngine/Audio/Drivers/Detectors/CPulseAudioPlayingDetector.h - src/WallpaperEngine/Audio/Drivers/Detectors/CAudioPlayingDetector.cpp - src/WallpaperEngine/Audio/Drivers/Detectors/CAudioPlayingDetector.h + src/WallpaperEngine/Audio/Drivers/Detectors/PulseAudioPlayingDetector.cpp + src/WallpaperEngine/Audio/Drivers/Detectors/PulseAudioPlayingDetector.h + src/WallpaperEngine/Audio/Drivers/Detectors/AudioPlayingDetector.cpp + src/WallpaperEngine/Audio/Drivers/Detectors/AudioPlayingDetector.h - src/WallpaperEngine/Audio/Drivers/CAudioDriver.cpp - src/WallpaperEngine/Audio/Drivers/CAudioDriver.h - src/WallpaperEngine/Audio/Drivers/CSDLAudioDriver.cpp - src/WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h - src/WallpaperEngine/Audio/CAudioContext.cpp - src/WallpaperEngine/Audio/CAudioContext.h - src/WallpaperEngine/Audio/CAudioStream.cpp - src/WallpaperEngine/Audio/CAudioStream.h + src/WallpaperEngine/Audio/Drivers/AudioDriver.cpp + src/WallpaperEngine/Audio/Drivers/AudioDriver.h + src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.cpp + src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.h + src/WallpaperEngine/Audio/AudioContext.cpp + src/WallpaperEngine/Audio/AudioContext.h + src/WallpaperEngine/Audio/AudioStream.cpp + src/WallpaperEngine/Audio/AudioStream.h - src/WallpaperEngine/Input/CInputContext.cpp - src/WallpaperEngine/Input/CInputContext.h - src/WallpaperEngine/Input/CMouseInput.cpp - src/WallpaperEngine/Input/CMouseInput.h - src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.cpp - src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.h + src/WallpaperEngine/Input/InputContext.cpp + src/WallpaperEngine/Input/InputContext.h + src/WallpaperEngine/Input/MouseInput.h + src/WallpaperEngine/Input/Drivers/GLFWMouseInput.cpp + src/WallpaperEngine/Input/Drivers/GLFWMouseInput.h - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.cpp - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.cpp - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.cpp - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.cpp - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.cpp - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h - src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.cpp + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariable.cpp + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableFloat.h + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableFloat.cpp + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableInteger.h + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableInteger.cpp + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector2.h + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector2.cpp + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector3.h + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector3.cpp + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector4.h + src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector4.cpp - src/WallpaperEngine/Render/Shaders/CShader.h - src/WallpaperEngine/Render/Shaders/CShader.cpp - src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp - src/WallpaperEngine/Render/Shaders/CShaderUnit.h - src/WallpaperEngine/Render/Shaders/CGLSLContext.cpp - src/WallpaperEngine/Render/Shaders/CGLSLContext.h + src/WallpaperEngine/Render/Shaders/Shader.h + src/WallpaperEngine/Render/Shaders/Shader.cpp + src/WallpaperEngine/Render/Shaders/ShaderUnit.cpp + src/WallpaperEngine/Render/Shaders/ShaderUnit.h + src/WallpaperEngine/Render/Shaders/GLSLContext.cpp + src/WallpaperEngine/Render/Shaders/GLSLContext.h - src/WallpaperEngine/Render/Helpers/CContextAware.cpp - src/WallpaperEngine/Render/Helpers/CContextAware.h + src/WallpaperEngine/Render/Helpers/ContextAware.cpp + src/WallpaperEngine/Render/Helpers/ContextAware.h - src/WallpaperEngine/Render/Drivers/CVideoFactories.cpp - src/WallpaperEngine/Render/Drivers/CVideoFactories.h + src/WallpaperEngine/Render/Drivers/VideoFactories.cpp + src/WallpaperEngine/Render/Drivers/VideoFactories.h - src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.cpp - src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h + src/WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.cpp + src/WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.h - src/WallpaperEngine/Render/Drivers/Output/COutput.cpp - src/WallpaperEngine/Render/Drivers/Output/COutput.h - src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.cpp - src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h - src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.cpp - src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.h - src/WallpaperEngine/Render/Drivers/Output/COutputViewport.cpp - src/WallpaperEngine/Render/Drivers/Output/COutputViewport.h - src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h - src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp - src/WallpaperEngine/Render/Drivers/CVideoDriver.h - src/WallpaperEngine/Render/Drivers/CVideoDriver.cpp - src/WallpaperEngine/Render/CRenderContext.h - src/WallpaperEngine/Render/CRenderContext.cpp - src/WallpaperEngine/Render/CTextureCache.h - src/WallpaperEngine/Render/CTextureCache.cpp - src/WallpaperEngine/Render/CFBOProvider.cpp - src/WallpaperEngine/Render/CFBOProvider.h + src/WallpaperEngine/Render/Drivers/Output/Output.cpp + src/WallpaperEngine/Render/Drivers/Output/Output.h + src/WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.cpp + src/WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.h + src/WallpaperEngine/Render/Drivers/Output/GLFWOutputViewport.cpp + src/WallpaperEngine/Render/Drivers/Output/GLFWOutputViewport.h + src/WallpaperEngine/Render/Drivers/Output/OutputViewport.cpp + src/WallpaperEngine/Render/Drivers/Output/OutputViewport.h + src/WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.h + src/WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.cpp + src/WallpaperEngine/Render/Drivers/VideoDriver.h + src/WallpaperEngine/Render/Drivers/VideoDriver.cpp + src/WallpaperEngine/Render/RenderContext.h + src/WallpaperEngine/Render/RenderContext.cpp + src/WallpaperEngine/Render/TextureCache.h + src/WallpaperEngine/Render/TextureCache.cpp + src/WallpaperEngine/Render/FBOProvider.cpp + src/WallpaperEngine/Render/FBOProvider.h - src/WallpaperEngine/Render/Helpers/CContextAware.cpp - src/WallpaperEngine/Render/Helpers/CContextAware.h + src/WallpaperEngine/Render/Helpers/ContextAware.cpp + src/WallpaperEngine/Render/Helpers/ContextAware.h src/WallpaperEngine/Render/CWallpaper.h src/WallpaperEngine/Render/CWallpaper.cpp - src/WallpaperEngine/Render/CWallpaperState.h - src/WallpaperEngine/Render/CWallpaperState.cpp + src/WallpaperEngine/Render/WallpaperState.h + src/WallpaperEngine/Render/WallpaperState.cpp src/WallpaperEngine/Render/Wallpapers/CScene.h src/WallpaperEngine/Render/Wallpapers/CScene.cpp src/WallpaperEngine/Render/Wallpapers/CVideo.h src/WallpaperEngine/Render/Wallpapers/CVideo.cpp src/WallpaperEngine/Render/Wallpapers/CWeb.h src/WallpaperEngine/Render/Wallpapers/CWeb.cpp - src/WallpaperEngine/Render/CCamera.h - src/WallpaperEngine/Render/CCamera.cpp + src/WallpaperEngine/Render/Camera.h + src/WallpaperEngine/Render/Camera.cpp src/WallpaperEngine/Render/CObject.h src/WallpaperEngine/Render/CObject.cpp src/WallpaperEngine/Render/CTexture.cpp src/WallpaperEngine/Render/CTexture.h - src/WallpaperEngine/Render/ITexture.h + src/WallpaperEngine/Render/TextureProvider.h src/WallpaperEngine/Render/Objects/CImage.h src/WallpaperEngine/Render/Objects/CImage.cpp @@ -385,20 +384,20 @@ add_executable( src/WallpaperEngine/Render/Objects/Effects/CPass.h src/WallpaperEngine/Render/Objects/Effects/CPass.cpp - src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.cpp - src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.h - src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.cpp - src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.h - src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.cpp - src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.h - src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.cpp - src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.h - src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.cpp - src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.h - src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.cpp - src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.h - src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp - src/WallpaperEngine/WebBrowser/CWebBrowserContext.h + src/WallpaperEngine/WebBrowser/CEF/RenderHandler.cpp + src/WallpaperEngine/WebBrowser/CEF/RenderHandler.h + src/WallpaperEngine/WebBrowser/CEF/BrowserClient.cpp + src/WallpaperEngine/WebBrowser/CEF/BrowserClient.h + src/WallpaperEngine/WebBrowser/CEF/BrowserApp.cpp + src/WallpaperEngine/WebBrowser/CEF/BrowserApp.h + src/WallpaperEngine/WebBrowser/CEF/SubprocessApp.cpp + src/WallpaperEngine/WebBrowser/CEF/SubprocessApp.h + src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandlerFactory.cpp + src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandlerFactory.h + src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandler.cpp + src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandler.h + src/WallpaperEngine/WebBrowser/WebBrowserContext.cpp + src/WallpaperEngine/WebBrowser/WebBrowserContext.h src/WallpaperEngine/Data/Assets/Types.h src/WallpaperEngine/Data/Assets/Texture.h @@ -451,11 +450,7 @@ add_executable( ${WAYLAND_SOURCES} ${X11_SOURCES} - ${DEMOMODE_SOURCES} - src/WallpaperEngine/FileSystem/Adapters/Package.h - src/WallpaperEngine/FileSystem/Adapters/Package.cpp - src/WallpaperEngine/FileSystem/Adapters/Virtual.h - src/WallpaperEngine/FileSystem/Adapters/Virtual.cpp) + ${DEMOMODE_SOURCES}) target_link_libraries (linux-wallpaperengine PUBLIC ${OPENGL_LIBRARIES} diff --git a/src/Steam/FileSystem/FileSystem.cpp b/src/Steam/FileSystem/FileSystem.cpp index 4b4fc8d..71ba2f9 100644 --- a/src/Steam/FileSystem/FileSystem.cpp +++ b/src/Steam/FileSystem/FileSystem.cpp @@ -1,5 +1,5 @@ #include "FileSystem.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" #include #include #include diff --git a/src/WallpaperEngine/Application/CApplicationContext.cpp b/src/WallpaperEngine/Application/ApplicationContext.cpp similarity index 94% rename from src/WallpaperEngine/Application/CApplicationContext.cpp rename to src/WallpaperEngine/Application/ApplicationContext.cpp index 6ea50d3..7e4dd64 100644 --- a/src/WallpaperEngine/Application/CApplicationContext.cpp +++ b/src/WallpaperEngine/Application/ApplicationContext.cpp @@ -1,7 +1,7 @@ -#include "CApplicationContext.h" +#include "ApplicationContext.h" #include "Steam/FileSystem/FileSystem.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" #include #include @@ -14,7 +14,7 @@ using namespace WallpaperEngine::Application; -CApplicationContext::CApplicationContext (int argc, char* argv []) : +ApplicationContext::ApplicationContext (int argc, char* argv []) : m_argc (argc), m_argv (argv) { std::string lastScreen; @@ -93,16 +93,16 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) : .help ("Scaling mode to use when rendering the background, this applies to the previous --window or --screen-root output, or the default background if no other background is specified") .choices ("stretch", "fit", "fill", "default") .action([this, &lastScreen](const std::string& value) -> void { - WallpaperEngine::Render::CWallpaperState::TextureUVsScaling mode; + WallpaperEngine::Render::WallpaperState::TextureUVsScaling mode; if (value == "stretch") { - mode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::StretchUVs; + mode = WallpaperEngine::Render::WallpaperState::TextureUVsScaling::StretchUVs; } else if (value == "fit") { - mode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::ZoomFitUVs; + mode = WallpaperEngine::Render::WallpaperState::TextureUVsScaling::ZoomFitUVs; } else if (value == "fill") { - mode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::ZoomFillUVs; + mode = WallpaperEngine::Render::WallpaperState::TextureUVsScaling::ZoomFillUVs; } else if (value == "default") { - mode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::DefaultUVs; + mode = WallpaperEngine::Render::WallpaperState::TextureUVsScaling::DefaultUVs; } else { sLog.exception ("Invalid scaling mode: ", value); } @@ -299,22 +299,22 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) : } } -int CApplicationContext::getArgc () const { +int ApplicationContext::getArgc () const { return this->m_argc; } -char** CApplicationContext::getArgv () const { +char** ApplicationContext::getArgv () const { return this->m_argv; } -std::filesystem::path CApplicationContext::translateBackground (const std::string& bgIdOrPath) { +std::filesystem::path ApplicationContext::translateBackground (const std::string& bgIdOrPath) { if (bgIdOrPath.find ('/') == std::string::npos) return Steam::FileSystem::workshopDirectory (WORKSHOP_APP_ID, bgIdOrPath); return bgIdOrPath; } -void CApplicationContext::validateAssets () { +void ApplicationContext::validateAssets () { if (!this->settings.general.assets.empty ()) { sLog.out ("Using wallpaper engine's assets at ", this->settings.general.assets, " based on --assets-dir parameter"); @@ -329,7 +329,7 @@ void CApplicationContext::validateAssets () { } } -void CApplicationContext::validateScreenshot () const { +void ApplicationContext::validateScreenshot () const { if (!this->settings.screenshot.take) return; diff --git a/src/WallpaperEngine/Application/CApplicationContext.h b/src/WallpaperEngine/Application/ApplicationContext.h similarity index 90% rename from src/WallpaperEngine/Application/CApplicationContext.h rename to src/WallpaperEngine/Application/ApplicationContext.h index 0710a38..13e00bc 100644 --- a/src/WallpaperEngine/Application/CApplicationContext.h +++ b/src/WallpaperEngine/Application/ApplicationContext.h @@ -7,10 +7,10 @@ #include -#include "CApplicationState.h" +#include "ApplicationState.h" -#include "../Render/ITexture.h" -#include "WallpaperEngine/Render/CWallpaperState.h" +#include "../Render/TextureProvider.h" +#include "WallpaperEngine/Render/WallpaperState.h" #include "WallpaperEngine/Data/Model/Project.h" @@ -19,9 +19,9 @@ using namespace WallpaperEngine::Data::Assets; /** * Application information as parsed off the command line arguments */ -class CApplicationContext { +class ApplicationContext { public: - CApplicationContext (int argc, char* argv []); + ApplicationContext (int argc, char* argv []); enum WINDOW_MODE { /** Default window mode */ @@ -50,7 +50,7 @@ class CApplicationContext { /** Properties to change values for */ std::map properties; /** The scaling mode for different screens */ - std::map screenScalings; + std::map screenScalings; /** The clamping mode for different screens */ std::map screenClamps; } general; @@ -70,7 +70,7 @@ class CApplicationContext { /** The window size used in explicit window */ glm::ivec4 geometry; TextureFlags clamp; - WallpaperEngine::Render::CWallpaperState::TextureUVsScaling scalingMode; + WallpaperEngine::Render::WallpaperState::TextureUVsScaling scalingMode; } window; } render; @@ -127,7 +127,7 @@ class CApplicationContext { .window = { .geometry = {}, .clamp = TextureFlags_ClampUVs, - .scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::DefaultUVs, + .scalingMode = WallpaperEngine::Render::WallpaperState::TextureUVsScaling::DefaultUVs, }, }, .audio = { @@ -147,7 +147,7 @@ class CApplicationContext { }, }; - CApplicationState state; + ApplicationState state; [[nodiscard]] int getArgc() const; [[nodiscard]] char** getArgv() const; diff --git a/src/WallpaperEngine/Application/CApplicationState.h b/src/WallpaperEngine/Application/ApplicationState.h similarity index 85% rename from src/WallpaperEngine/Application/CApplicationState.h rename to src/WallpaperEngine/Application/ApplicationState.h index 697f0bf..c437a22 100644 --- a/src/WallpaperEngine/Application/CApplicationState.h +++ b/src/WallpaperEngine/Application/ApplicationState.h @@ -1,12 +1,12 @@ #pragma once -#include "CApplicationContext.h" +#include "ApplicationContext.h" namespace WallpaperEngine::Application { /** * Represents current application state */ -class CApplicationState { +class ApplicationState { public: struct { bool keepRunning; diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.cpp b/src/WallpaperEngine/Application/WallpaperApplication.cpp similarity index 88% rename from src/WallpaperEngine/Application/CWallpaperApplication.cpp rename to src/WallpaperEngine/Application/WallpaperApplication.cpp index 61c0ae7..62481e6 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.cpp +++ b/src/WallpaperEngine/Application/WallpaperApplication.cpp @@ -1,16 +1,16 @@ -#include "CWallpaperApplication.h" +#include "WallpaperApplication.h" #include "Steam/FileSystem/FileSystem.h" -#include "WallpaperEngine/Application/CApplicationState.h" -#include "WallpaperEngine/Assets/CAssetLoadException.h" -#include "WallpaperEngine/Audio/Drivers/Detectors/CPulseAudioPlayingDetector.h" +#include "WallpaperEngine/Application/ApplicationState.h" +#include "WallpaperEngine/Assets/AssetLoadException.h" +#include "WallpaperEngine/Audio/Drivers/Detectors/PulseAudioPlayingDetector.h" #include "WallpaperEngine/FileSystem/Container.h" -#include "WallpaperEngine/Logging/CLog.h" -#include "WallpaperEngine/Render/CRenderContext.h" -#include "WallpaperEngine/Render/Drivers/CVideoFactories.h" +#include "WallpaperEngine/Logging/Log.h" +#include "WallpaperEngine/Render/Drivers/VideoFactories.h" +#include "WallpaperEngine/Render/RenderContext.h" -#include "WallpaperEngine/Data/Parsers/ProjectParser.h" #include "WallpaperEngine/Data/Dumpers/StringPrinter.h" +#include "WallpaperEngine/Data/Parsers/ProjectParser.h" #include "WallpaperEngine/Data/Model/Wallpaper.h" #include "WallpaperEngine/Data/Model/Property.h" @@ -33,14 +33,14 @@ using namespace WallpaperEngine::Application; using namespace WallpaperEngine::Data::Model; using namespace WallpaperEngine::FileSystem; -CWallpaperApplication::CWallpaperApplication (CApplicationContext& context) : +WallpaperApplication::WallpaperApplication (ApplicationContext& context) : m_context (context) { this->loadBackgrounds (); this->setupProperties (); this->setupBrowser(); } -ContainerUniquePtr CWallpaperApplication::setupContainer (const std::string& bg) const { +ContainerUniquePtr WallpaperApplication::setupContainer (const std::string& bg) const { auto container = std::make_unique (); std::filesystem::path path (bg); @@ -196,9 +196,9 @@ ContainerUniquePtr CWallpaperApplication::setupContainer (const std::string& bg) return container; } -void CWallpaperApplication::loadBackgrounds () { - if (this->m_context.settings.render.mode == CApplicationContext::NORMAL_WINDOW || - this->m_context.settings.render.mode == CApplicationContext::EXPLICIT_WINDOW) { +void WallpaperApplication::loadBackgrounds () { + if (this->m_context.settings.render.mode == ApplicationContext::NORMAL_WINDOW || + this->m_context.settings.render.mode == ApplicationContext::EXPLICIT_WINDOW) { this->m_backgrounds ["default"] = this->loadBackground (this->m_context.settings.general.defaultBackground); return; } @@ -213,14 +213,14 @@ void CWallpaperApplication::loadBackgrounds () { } } -ProjectUniquePtr CWallpaperApplication::loadBackground (const std::string& bg) { +ProjectUniquePtr WallpaperApplication::loadBackground (const std::string& bg) { auto container = this->setupContainer (bg); auto json = WallpaperEngine::Data::JSON::JSON::parse (container->readString ("project.json")); return WallpaperEngine::Data::Parsers::ProjectParser::parse (json, std::move(container)); } -void CWallpaperApplication::setupPropertiesForProject (const Project& project) { +void WallpaperApplication::setupPropertiesForProject (const Project& project) { // show properties if required for (const auto& [key, cur] : project.properties) { // update the value of the property @@ -237,12 +237,12 @@ void CWallpaperApplication::setupPropertiesForProject (const Project& project) { } } -void CWallpaperApplication::setupProperties () { +void WallpaperApplication::setupProperties () { for (const auto& [background, info] : this->m_backgrounds) this->setupPropertiesForProject (*info); } -void CWallpaperApplication::setupBrowser () { +void WallpaperApplication::setupBrowser () { bool anyWebProject = std::any_of ( this->m_backgrounds.begin (), this->m_backgrounds.end (), [](const std::pair& pair) -> bool { @@ -255,10 +255,10 @@ void CWallpaperApplication::setupBrowser () { return; } - this->m_browserContext = std::make_unique (*this); + this->m_browserContext = std::make_unique (*this); } -void CWallpaperApplication::takeScreenshot (const std::filesystem::path& filename) const { +void WallpaperApplication::takeScreenshot (const std::filesystem::path& filename) const { // this should be getting called at the end of the frame, so the right thing should be bound already const int width = this->m_renderContext->getOutput ().getFullWidth (); const int height = this->m_renderContext->getOutput ().getFullHeight (); @@ -328,7 +328,7 @@ void CWallpaperApplication::takeScreenshot (const std::filesystem::path& filenam delete [] bitmap; } -void CWallpaperApplication::setupOutput () { +void WallpaperApplication::setupOutput () { const char* XDG_SESSION_TYPE = getenv ("XDG_SESSION_TYPE"); if (!XDG_SESSION_TYPE) { @@ -347,7 +347,7 @@ void CWallpaperApplication::setupOutput () { this->m_fullScreenDetector = sVideoFactories.createFullscreenDetector (XDG_SESSION_TYPE, this->m_context, *this->m_videoDriver); } -void CWallpaperApplication::setupAudio () { +void WallpaperApplication::setupAudio () { // ensure audioprocessing is required by any background, and we have it enabled bool audioProcessingRequired = std::any_of ( this->m_backgrounds.begin (), this->m_backgrounds.end (), @@ -357,26 +357,26 @@ void CWallpaperApplication::setupAudio () { ); if (audioProcessingRequired && this->m_context.settings.audio.audioprocessing) { - this->m_audioRecorder = std::make_unique (); + this->m_audioRecorder = std::make_unique (); } else { - this->m_audioRecorder = std::make_unique (); + this->m_audioRecorder = std::make_unique (); } if (this->m_context.settings.audio.automute) { - m_audioDetector = std::make_unique (this->m_context, *this->m_fullScreenDetector); + m_audioDetector = std::make_unique (this->m_context, *this->m_fullScreenDetector); } else { - m_audioDetector = std::make_unique (this->m_context, *this->m_fullScreenDetector); + m_audioDetector = std::make_unique (this->m_context, *this->m_fullScreenDetector); } // initialize sdl audio driver - m_audioDriver = std::make_unique (this->m_context, *this->m_audioDetector, *this->m_audioRecorder); + m_audioDriver = std::make_unique (this->m_context, *this->m_audioDetector, *this->m_audioRecorder); // initialize audio context - m_audioContext = std::make_unique (*m_audioDriver); + m_audioContext = std::make_unique (*m_audioDriver); } -void CWallpaperApplication::prepareOutputs () { +void WallpaperApplication::prepareOutputs () { // initialize render context - m_renderContext = std::make_unique (*m_videoDriver, *this); + m_renderContext = std::make_unique (*m_videoDriver, *this); // create a new background for each screen // set all the specific wallpapers required @@ -392,7 +392,7 @@ void CWallpaperApplication::prepareOutputs () { } } -void CWallpaperApplication::show () { +void WallpaperApplication::show () { this->setupOutput (); this->setupAudio (); this->prepareOutputs (); @@ -498,24 +498,24 @@ void CWallpaperApplication::show () { SDL_Quit (); } -void CWallpaperApplication::update (Render::Drivers::Output::COutputViewport* viewport) { +void WallpaperApplication::update (Render::Drivers::Output::OutputViewport* viewport) { // render the scene m_renderContext->render (viewport); } -void CWallpaperApplication::signal (int signal) { +void WallpaperApplication::signal (int signal) { sLog.out ("Stop requested by signal ", signal); this->m_context.state.general.keepRunning = false; } -const std::map& CWallpaperApplication::getBackgrounds () const { +const std::map& WallpaperApplication::getBackgrounds () const { return this->m_backgrounds; } -CApplicationContext& CWallpaperApplication::getContext () const { +ApplicationContext& WallpaperApplication::getContext () const { return this->m_context; } -const WallpaperEngine::Render::Drivers::Output::COutput& CWallpaperApplication::getOutput () const { +const WallpaperEngine::Render::Drivers::Output::Output& WallpaperApplication::getOutput () const { return this->m_renderContext->getOutput (); } diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.h b/src/WallpaperEngine/Application/WallpaperApplication.h similarity index 65% rename from src/WallpaperEngine/Application/CWallpaperApplication.h rename to src/WallpaperEngine/Application/WallpaperApplication.h index b2400f3..1f709dd 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.h +++ b/src/WallpaperEngine/Application/WallpaperApplication.h @@ -1,17 +1,17 @@ #pragma once -#include "WallpaperEngine/Application/CApplicationContext.h" +#include "WallpaperEngine/Application/ApplicationContext.h" -#include "WallpaperEngine/Render/CRenderContext.h" #include "WallpaperEngine/Render/CWallpaper.h" -#include "WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h" -#include "WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h" -#include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h" +#include "WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.h" +#include "WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.h" +#include "WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.h" +#include "WallpaperEngine/Render/RenderContext.h" -#include "WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h" +#include "WallpaperEngine/Audio/Drivers/SDLAudioDriver.h" -#include "WallpaperEngine/Input/CInputContext.h" -#include "WallpaperEngine/WebBrowser/CWebBrowserContext.h" +#include "WallpaperEngine/Input/InputContext.h" +#include "WallpaperEngine/WebBrowser/WebBrowserContext.h" #include "WallpaperEngine/Data/Model/Types.h" @@ -19,12 +19,10 @@ namespace WallpaperEngine::Application { using namespace WallpaperEngine::Data::Model; /** * Small wrapper class over the actual wallpaper's main application skeleton - * - * @author Alexis Maiquez */ -class CWallpaperApplication { +class WallpaperApplication { public: - explicit CWallpaperApplication (CApplicationContext& context); + explicit WallpaperApplication (ApplicationContext& context); /** * Shows the application until it's closed @@ -43,15 +41,15 @@ class CWallpaperApplication { /** * @return The current application context */ - [[nodiscard]] CApplicationContext& getContext () const; + [[nodiscard]] ApplicationContext& getContext () const; /** * Renders a frame */ - void update (Render::Drivers::Output::COutputViewport* viewport); + void update (Render::Drivers::Output::OutputViewport* viewport); /** * Gets the output */ - [[nodiscard]] const WallpaperEngine::Render::Drivers::Output::COutput& getOutput () const; + [[nodiscard]] const WallpaperEngine::Render::Drivers::Output::Output& getOutput () const; private: /** @@ -106,17 +104,17 @@ class CWallpaperApplication { void takeScreenshot (const std::filesystem::path& filename) const; /** The application context that contains the current app settings */ - CApplicationContext& m_context; + ApplicationContext& m_context; /** Maps screens to backgrounds */ std::map m_backgrounds {}; - std::unique_ptr m_audioDetector = nullptr; - std::unique_ptr m_audioContext = nullptr; - std::unique_ptr m_audioDriver = nullptr; - std::unique_ptr m_audioRecorder = nullptr; - std::unique_ptr m_renderContext = nullptr; - std::unique_ptr m_videoDriver = nullptr; - std::unique_ptr m_fullScreenDetector = nullptr; - std::unique_ptr m_browserContext = nullptr; + std::unique_ptr m_audioDetector = nullptr; + std::unique_ptr m_audioContext = nullptr; + std::unique_ptr m_audioDriver = nullptr; + std::unique_ptr m_audioRecorder = nullptr; + std::unique_ptr m_renderContext = nullptr; + std::unique_ptr m_videoDriver = nullptr; + std::unique_ptr m_fullScreenDetector = nullptr; + std::unique_ptr m_browserContext = nullptr; }; } // namespace WallpaperEngine::Application diff --git a/src/WallpaperEngine/Assets/AssetLoadException.cpp b/src/WallpaperEngine/Assets/AssetLoadException.cpp new file mode 100644 index 0000000..db439ee --- /dev/null +++ b/src/WallpaperEngine/Assets/AssetLoadException.cpp @@ -0,0 +1,10 @@ +#include "AssetLoadException.h" + +using namespace WallpaperEngine::Render; + +AssetLoadException::AssetLoadException (const std::string& filename, const std::string& extrainfo) : + m_message ("Cannot find file " + filename + ": " + extrainfo) {} + +const char* AssetLoadException::what () const noexcept { + return this->m_message.c_str (); +} diff --git a/src/WallpaperEngine/Assets/CAssetLoadException.h b/src/WallpaperEngine/Assets/AssetLoadException.h similarity index 60% rename from src/WallpaperEngine/Assets/CAssetLoadException.h rename to src/WallpaperEngine/Assets/AssetLoadException.h index 609fef3..225dc2d 100644 --- a/src/WallpaperEngine/Assets/CAssetLoadException.h +++ b/src/WallpaperEngine/Assets/AssetLoadException.h @@ -4,10 +4,10 @@ #include // TODO: REWRITE THIS ONE TO MAKE MORE SENSE, IT REALLY MEANS "FILE-RELATED EXCEPTION" -namespace WallpaperEngine::Assets { -class CAssetLoadException final : public std::exception { +namespace WallpaperEngine::Render { +class AssetLoadException final : public std::exception { public: - explicit CAssetLoadException (const std::string& filename, const std::string& extrainfo = ""); + explicit AssetLoadException (const std::string& filename, const std::string& extrainfo = ""); [[nodiscard]] const char* what () const noexcept override; private: diff --git a/src/WallpaperEngine/Assets/CAssetLoadException.cpp b/src/WallpaperEngine/Assets/CAssetLoadException.cpp deleted file mode 100644 index 3b8eb2e..0000000 --- a/src/WallpaperEngine/Assets/CAssetLoadException.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "CAssetLoadException.h" - -using namespace WallpaperEngine::Assets; - -CAssetLoadException::CAssetLoadException (const std::string& filename, const std::string& extrainfo) : - m_message ("Cannot find file " + filename + ": " + extrainfo) {} - -const char* CAssetLoadException::what () const noexcept { - return this->m_message.c_str (); -} diff --git a/src/WallpaperEngine/Audio/AudioContext.cpp b/src/WallpaperEngine/Audio/AudioContext.cpp new file mode 100644 index 0000000..dd04649 --- /dev/null +++ b/src/WallpaperEngine/Audio/AudioContext.cpp @@ -0,0 +1,30 @@ +#include "AudioContext.h" +#include "WallpaperEngine/Audio/Drivers/AudioDriver.h" + +namespace WallpaperEngine::Audio { +AudioContext::AudioContext (Drivers::AudioDriver& driver) : m_driver (driver) {} + +void AudioContext::addStream (AudioStream* stream) { + this->m_driver.addStream (stream); +} + +AVSampleFormat AudioContext::getFormat () const { + return this->m_driver.getFormat (); +} + +int AudioContext::getSampleRate () const { + return this->m_driver.getSampleRate (); +} + +int AudioContext::getChannels () const { + return this->m_driver.getChannels (); +} + +Application::ApplicationContext& AudioContext::getApplicationContext () { + return this->m_driver.getApplicationContext (); +} + +Drivers::Recorders::PlaybackRecorder& AudioContext::getRecorder () { + return this->m_driver.getRecorder (); +} +} // namespace WallpaperEngine::Audio \ No newline at end of file diff --git a/src/WallpaperEngine/Audio/CAudioContext.h b/src/WallpaperEngine/Audio/AudioContext.h similarity index 65% rename from src/WallpaperEngine/Audio/CAudioContext.h rename to src/WallpaperEngine/Audio/AudioContext.h index 26c5eb8..db7e7fd 100644 --- a/src/WallpaperEngine/Audio/CAudioContext.h +++ b/src/WallpaperEngine/Audio/AudioContext.h @@ -3,35 +3,35 @@ #include #include -#include "WallpaperEngine/Application/CApplicationContext.h" -#include "WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.h" +#include "WallpaperEngine/Application/ApplicationContext.h" +#include "WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.h" namespace WallpaperEngine { namespace Application { -class CApplicationContext; +class ApplicationContext; } namespace Audio { namespace Drivers { -class CAudioDriver; +class AudioDriver; namespace Recorders { -class CPulseAudioPlaybackRecorder; +class PulseAudioPlaybackRecorder; } } // namespace Drivers -class CAudioStream; +class AudioStream; -class CAudioContext { +class AudioContext { public: - explicit CAudioContext (Drivers::CAudioDriver& driver); + explicit AudioContext (Drivers::AudioDriver& driver); /** * Registers the given stream in the driver for playing * * @param stream */ - void addStream (CAudioStream* stream); + void addStream (AudioStream* stream); /** * TODO: MAYBE THIS SHOULD BE OUR OWN DEFINITIONS INSTEAD OF LIBRARY SPECIFIC ONES? @@ -50,15 +50,15 @@ class CAudioContext { /** * @return The application context under which the audio driver is initialized */ - Application::CApplicationContext& getApplicationContext (); + Application::ApplicationContext& getApplicationContext (); /** * @return The audio recorder to use to capture stereo mix data */ - [[nodiscard]] Drivers::Recorders::CPlaybackRecorder& getRecorder (); + [[nodiscard]] Drivers::Recorders::PlaybackRecorder& getRecorder (); private: /** The audio driver in use */ - Drivers::CAudioDriver& m_driver; + Drivers::AudioDriver& m_driver; }; } // namespace Audio } // namespace WallpaperEngine \ No newline at end of file diff --git a/src/WallpaperEngine/Audio/CAudioStream.cpp b/src/WallpaperEngine/Audio/AudioStream.cpp similarity index 90% rename from src/WallpaperEngine/Audio/CAudioStream.cpp rename to src/WallpaperEngine/Audio/AudioStream.cpp index 7671c20..6814bb9 100644 --- a/src/WallpaperEngine/Audio/CAudioStream.cpp +++ b/src/WallpaperEngine/Audio/AudioStream.cpp @@ -1,5 +1,5 @@ -#include "CAudioStream.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "AudioStream.h" +#include "WallpaperEngine/Logging/Log.h" #include #include #include @@ -10,7 +10,7 @@ using namespace WallpaperEngine::Audio; int audio_read_thread (void* arg) { SDL_mutex* waitMutex = SDL_CreateMutex (); - auto* stream = static_cast (arg); + auto* stream = static_cast (arg); AVPacket* packet = av_packet_alloc (); int ret = 0; @@ -60,7 +60,7 @@ int audio_read_thread (void* arg) { } static int audio_read_data_callback (void* streamarg, uint8_t* buffer, int buffer_size) { - const auto stream = static_cast (streamarg); + const auto stream = static_cast (streamarg); stream->getBuffer ()->read (reinterpret_cast (buffer), buffer_size); @@ -69,7 +69,7 @@ static int audio_read_data_callback (void* streamarg, uint8_t* buffer, int buffe } int64_t audio_seek_data_callback (void* streamarg, int64_t offset, int whence) { - const auto stream = static_cast (streamarg); + const auto stream = static_cast (streamarg); // this was supported before, now we don't as there's no easy way to tell length // so returning <0 signals no support for it @@ -84,12 +84,12 @@ int64_t audio_seek_data_callback (void* streamarg, int64_t offset, int whence) { return offset; } -CAudioStream::CAudioStream (CAudioContext& context, const std::string& filename) : +AudioStream::AudioStream (AudioContext& context, const std::string& filename) : m_audioContext (context) { this->loadCustomContent (filename.c_str ()); } -CAudioStream::CAudioStream (CAudioContext& context, const ReadStreamSharedPtr& buffer, uint32_t length) : +AudioStream::AudioStream (AudioContext& context, const ReadStreamSharedPtr& buffer, uint32_t length) : m_audioContext (context) { // setup a custom context first this->m_formatContext = avformat_alloc_context (); @@ -111,14 +111,14 @@ CAudioStream::CAudioStream (CAudioContext& context, const ReadStreamSharedPtr& b this->loadCustomContent (); } -CAudioStream::CAudioStream (CAudioContext& audioContext, AVCodecContext* context) : +AudioStream::AudioStream (AudioContext& audioContext, AVCodecContext* context) : m_audioContext (audioContext), m_context (context), m_queue (new PacketQueue) { this->initialize (); } -CAudioStream::~CAudioStream () { +AudioStream::~AudioStream () { if (this->m_swrctx != nullptr && swr_is_initialized (this->m_swrctx) == true) swr_close (this->m_swrctx); if (this->m_swrctx != nullptr) @@ -127,7 +127,7 @@ CAudioStream::~CAudioStream () { // TODO: FREE EVERYTHING ELSE THAT THIS CLASS HOLDS! } -void CAudioStream::loadCustomContent (const char* filename) { +void AudioStream::loadCustomContent (const char* filename) { if (avformat_open_input (&this->m_formatContext, filename, nullptr, nullptr) != 0) sLog.exception ("Cannot open audio file: ", filename); if (avformat_find_stream_info (this->m_formatContext, nullptr) < 0) @@ -170,7 +170,7 @@ void CAudioStream::loadCustomContent (const char* filename) { SDL_CreateThread (audio_read_thread, filename, this); } -void CAudioStream::initialize () { +void AudioStream::initialize () { // allocate the FIFO buffer #if FF_API_FIFO_OLD_API this->m_queue->packetList = av_fifo_alloc (sizeof (MyAVPacketList)); @@ -226,7 +226,7 @@ void CAudioStream::initialize () { this->m_initialized = true; } -void CAudioStream::queuePacket (AVPacket* pkt) { +void AudioStream::queuePacket (AVPacket* pkt) { // clone the packet AVPacket* clone = av_packet_alloc (); @@ -245,7 +245,7 @@ void CAudioStream::queuePacket (AVPacket* pkt) { av_packet_free (&pkt); } -bool CAudioStream::doQueue (AVPacket* pkt) { +bool AudioStream::doQueue (AVPacket* pkt) { MyAVPacketList entry {pkt}; #if FF_API_FIFO_OLD_API @@ -269,7 +269,7 @@ bool CAudioStream::doQueue (AVPacket* pkt) { return true; } -void CAudioStream::dequeuePacket (AVPacket* output) { +void AudioStream::dequeuePacket (AVPacket* output) { MyAVPacketList entry{}; SDL_LockMutex (this->m_queue->mutex); @@ -303,51 +303,51 @@ void CAudioStream::dequeuePacket (AVPacket* output) { SDL_UnlockMutex (this->m_queue->mutex); } -AVCodecContext* CAudioStream::getContext () { +AVCodecContext* AudioStream::getContext () { return this->m_context; } -AVFormatContext* CAudioStream::getFormatContext () { +AVFormatContext* AudioStream::getFormatContext () { return this->m_formatContext; } -int CAudioStream::getAudioStream () const { +int AudioStream::getAudioStream () const { return this->m_audioStream; } -bool CAudioStream::isInitialized () const { +bool AudioStream::isInitialized () const { return this->m_initialized; } -void CAudioStream::setRepeat (bool newRepeat) { +void AudioStream::setRepeat (bool newRepeat) { this->m_repeat = newRepeat; } -bool CAudioStream::isRepeat () const { +bool AudioStream::isRepeat () const { return this->m_repeat; } -ReadStreamSharedPtr& CAudioStream::getBuffer () { +ReadStreamSharedPtr& AudioStream::getBuffer () { return this->m_buffer; } -uint32_t CAudioStream::getLength () const { +uint32_t AudioStream::getLength () const { return this->m_length; } -SDL_cond* CAudioStream::getWaitCondition () { +SDL_cond* AudioStream::getWaitCondition () { return this->m_queue->wait; } -int CAudioStream::getQueueSize () { +int AudioStream::getQueueSize () { return this->m_queue->size; } -int CAudioStream::getQueuePacketCount () { +int AudioStream::getQueuePacketCount () { return this->m_queue->nb_packets; } -AVRational CAudioStream::getTimeBase () { +AVRational AudioStream::getTimeBase () { if (this->m_audioStream == NO_AUDIO_STREAM) { return {0, 0}; } @@ -355,19 +355,19 @@ AVRational CAudioStream::getTimeBase () { return this->m_formatContext->streams [this->m_audioStream]->time_base; } -int64_t CAudioStream::getQueueDuration () { +int64_t AudioStream::getQueueDuration () { return this->m_queue->duration; } -bool CAudioStream::isQueueEmpty () { +bool AudioStream::isQueueEmpty () { return this->m_queue->nb_packets == 0; } -SDL_mutex* CAudioStream::getMutex () { +SDL_mutex* AudioStream::getMutex () { return this->m_queue->mutex; } -void CAudioStream::stop () { +void AudioStream::stop () { if (!this->isInitialized ()) return; @@ -375,7 +375,7 @@ void CAudioStream::stop () { this->m_initialized = false; } -int CAudioStream::resampleAudio (const AVFrame* decoded_audio_frame, uint8_t* out_buf) { +int AudioStream::resampleAudio (const AVFrame* decoded_audio_frame, uint8_t* out_buf) { int out_linesize = 0; int ret; int out_nb_channels; @@ -487,7 +487,7 @@ int CAudioStream::resampleAudio (const AVFrame* decoded_audio_frame, uint8_t* ou return resampled_data_size; } -int CAudioStream::decodeFrame (uint8_t* audioBuffer, int bufferSize) { +int AudioStream::decodeFrame (uint8_t* audioBuffer, int bufferSize) { AVPacket* pkt = av_packet_alloc (); static uint8_t* audio_pkt_data = nullptr; static int audio_pkt_size = 0; @@ -553,6 +553,6 @@ int CAudioStream::decodeFrame (uint8_t* audioBuffer, int bufferSize) { return 0; } -CAudioContext& CAudioStream::getAudioContext () const { +AudioContext& AudioStream::getAudioContext () const { return this->m_audioContext; } \ No newline at end of file diff --git a/src/WallpaperEngine/Audio/CAudioStream.h b/src/WallpaperEngine/Audio/AudioStream.h similarity index 92% rename from src/WallpaperEngine/Audio/CAudioStream.h rename to src/WallpaperEngine/Audio/AudioStream.h index 7f236e3..dd26048 100644 --- a/src/WallpaperEngine/Audio/CAudioStream.h +++ b/src/WallpaperEngine/Audio/AudioStream.h @@ -14,7 +14,7 @@ extern "C" { #include #include -#include "WallpaperEngine/Audio/CAudioContext.h" +#include "WallpaperEngine/Audio/AudioContext.h" // TODO: FIND A BETTER PLACE TO DO THIS? OLD_API MIGHT EXIST BUT THIS DEFINE MIGHT NOT BE DEFINED... #ifndef FF_API_FIFO_OLD_API @@ -29,19 +29,19 @@ extern "C" { #define NO_AUDIO_STREAM (-1) namespace WallpaperEngine::Audio { -class CAudioContext; +class AudioContext; using namespace WallpaperEngine::FileSystem; /** * Represents a playable audio stream for the audio driver */ -class CAudioStream { +class AudioStream { public: - CAudioStream (CAudioContext& context, const std::string& filename); - CAudioStream (CAudioContext& context, const ReadStreamSharedPtr& buffer, uint32_t length); - CAudioStream (CAudioContext& audioContext, AVCodecContext* context); - ~CAudioStream (); + AudioStream (AudioContext& context, const std::string& filename); + AudioStream (AudioContext& context, const ReadStreamSharedPtr& buffer, uint32_t length); + AudioStream (AudioContext& audioContext, AVCodecContext* context); + ~AudioStream (); void queuePacket (AVPacket* pkt); @@ -57,7 +57,7 @@ class CAudioStream { /** * @return The audio context in use for this audio stream */ - [[nodiscard]] CAudioContext& getAudioContext () const; + [[nodiscard]] AudioContext& getAudioContext () const; /** * @return to the codec context, which provides information on the audio stream's format @@ -165,7 +165,7 @@ class CAudioStream { /** The SwrContext that handles resampling */ SwrContext* m_swrctx = nullptr; /** The audio context this stream will be played under */ - CAudioContext& m_audioContext; + AudioContext& m_audioContext; /** If this stream was properly initialized or not */ bool m_initialized = false; /** Repeat enabled? */ diff --git a/src/WallpaperEngine/Audio/CAudioContext.cpp b/src/WallpaperEngine/Audio/CAudioContext.cpp deleted file mode 100644 index 9af8103..0000000 --- a/src/WallpaperEngine/Audio/CAudioContext.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "CAudioContext.h" -#include "WallpaperEngine/Audio/Drivers/CAudioDriver.h" - -namespace WallpaperEngine::Audio { -CAudioContext::CAudioContext (Drivers::CAudioDriver& driver) : m_driver (driver) {} - -void CAudioContext::addStream (CAudioStream* stream) { - this->m_driver.addStream (stream); -} - -AVSampleFormat CAudioContext::getFormat () const { - return this->m_driver.getFormat (); -} - -int CAudioContext::getSampleRate () const { - return this->m_driver.getSampleRate (); -} - -int CAudioContext::getChannels () const { - return this->m_driver.getChannels (); -} - -Application::CApplicationContext& CAudioContext::getApplicationContext () { - return this->m_driver.getApplicationContext (); -} - -Drivers::Recorders::CPlaybackRecorder& CAudioContext::getRecorder () { - return this->m_driver.getRecorder (); -} -} // namespace WallpaperEngine::Audio \ No newline at end of file diff --git a/src/WallpaperEngine/Audio/Drivers/AudioDriver.cpp b/src/WallpaperEngine/Audio/Drivers/AudioDriver.cpp new file mode 100644 index 0000000..d5452b3 --- /dev/null +++ b/src/WallpaperEngine/Audio/Drivers/AudioDriver.cpp @@ -0,0 +1,28 @@ +#include "AudioDriver.h" + +namespace WallpaperEngine::Audio::Drivers { +AudioDriver::AudioDriver ( + Application::ApplicationContext& applicationContext, Detectors::AudioPlayingDetector& detector, + Recorders::PlaybackRecorder& recorder +) : + m_applicationContext (applicationContext), + m_detector (detector), + m_recorder (recorder) {} + +void AudioDriver::update () { + this->m_recorder.update (); + this->m_detector.update (); +} + +Application::ApplicationContext& AudioDriver::getApplicationContext () { + return this->m_applicationContext; +} + +Detectors::AudioPlayingDetector& AudioDriver::getAudioDetector () { + return this->m_detector; +} + +Recorders::PlaybackRecorder& AudioDriver::getRecorder () { + return this->m_recorder; +} +} // namespace WallpaperEngine::Audio::Drivers diff --git a/src/WallpaperEngine/Audio/Drivers/CAudioDriver.h b/src/WallpaperEngine/Audio/Drivers/AudioDriver.h similarity index 56% rename from src/WallpaperEngine/Audio/Drivers/CAudioDriver.h rename to src/WallpaperEngine/Audio/Drivers/AudioDriver.h index ab24d8f..a80a1b6 100644 --- a/src/WallpaperEngine/Audio/Drivers/CAudioDriver.h +++ b/src/WallpaperEngine/Audio/Drivers/AudioDriver.h @@ -2,44 +2,44 @@ #include -#include "WallpaperEngine/Application/CApplicationContext.h" -#include "WallpaperEngine/Audio/CAudioStream.h" -#include "WallpaperEngine/Audio/Drivers/Detectors/CAudioPlayingDetector.h" -#include "WallpaperEngine/Audio/Drivers/Recorders/CPlaybackRecorder.h" +#include "WallpaperEngine/Application/ApplicationContext.h" +#include "WallpaperEngine/Audio/AudioStream.h" +#include "WallpaperEngine/Audio/Drivers/Detectors/AudioPlayingDetector.h" +#include "WallpaperEngine/Audio/Drivers/Recorders/PlaybackRecorder.h" namespace WallpaperEngine { namespace Application { -class CApplicationContext; +class ApplicationContext; } namespace Audio { -class CAudioStream; +class AudioStream; namespace Drivers { namespace Detectors { -class CAudioPlayingDetector; +class AudioPlayingDetector; } namespace Recorders { -class CPulseAudioPlaybackRecorder; +class PulseAudioPlaybackRecorder; } /** * Base class for audio driver implementations */ -class CAudioDriver { +class AudioDriver { public: - explicit CAudioDriver ( - Application::CApplicationContext& applicationContext, Detectors::CAudioPlayingDetector& detector, - Recorders::CPlaybackRecorder& recorder); + explicit AudioDriver ( + Application::ApplicationContext& applicationContext, Detectors::AudioPlayingDetector& detector, + Recorders::PlaybackRecorder& recorder); - virtual ~CAudioDriver () = default; + virtual ~AudioDriver () = default; /** * Registers the given stream in the driver for playing * * @param stream */ - virtual void addStream (CAudioStream* stream) = 0; + virtual void addStream (AudioStream* stream) = 0; /** * Updates status of the different audio settings @@ -63,20 +63,20 @@ class CAudioDriver { /** * @return The application context under which the audio driver is initialized */ - Application::CApplicationContext& getApplicationContext (); + Application::ApplicationContext& getApplicationContext (); /** * @return The audio playing detector to use to stop playing sound when something else starts playing */ - [[nodiscard]] Detectors::CAudioPlayingDetector& getAudioDetector (); + [[nodiscard]] Detectors::AudioPlayingDetector& getAudioDetector (); /** * @return The audio recorder to use to capture stereo mix data */ - [[nodiscard]] Recorders::CPlaybackRecorder& getRecorder (); + [[nodiscard]] Recorders::PlaybackRecorder& getRecorder (); private: - Application::CApplicationContext& m_applicationContext; - Detectors::CAudioPlayingDetector& m_detector; - Recorders::CPlaybackRecorder& m_recorder; + Application::ApplicationContext& m_applicationContext; + Detectors::AudioPlayingDetector& m_detector; + Recorders::PlaybackRecorder& m_recorder; }; } // namespace Drivers } // namespace Audio diff --git a/src/WallpaperEngine/Audio/Drivers/CAudioDriver.cpp b/src/WallpaperEngine/Audio/Drivers/CAudioDriver.cpp deleted file mode 100644 index 2baa59f..0000000 --- a/src/WallpaperEngine/Audio/Drivers/CAudioDriver.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "CAudioDriver.h" - -namespace WallpaperEngine::Audio::Drivers { -CAudioDriver::CAudioDriver ( - Application::CApplicationContext& applicationContext, Detectors::CAudioPlayingDetector& detector, - Recorders::CPlaybackRecorder& recorder -) : - m_applicationContext (applicationContext), - m_detector (detector), - m_recorder (recorder) {} - -void CAudioDriver::update () { - this->m_recorder.update (); - this->m_detector.update (); -} - -Application::CApplicationContext& CAudioDriver::getApplicationContext () { - return this->m_applicationContext; -} - -Detectors::CAudioPlayingDetector& CAudioDriver::getAudioDetector () { - return this->m_detector; -} - -Recorders::CPlaybackRecorder& CAudioDriver::getRecorder () { - return this->m_recorder; -} -} // namespace WallpaperEngine::Audio::Drivers diff --git a/src/WallpaperEngine/Audio/Drivers/Detectors/AudioPlayingDetector.cpp b/src/WallpaperEngine/Audio/Drivers/Detectors/AudioPlayingDetector.cpp new file mode 100644 index 0000000..0974b0f --- /dev/null +++ b/src/WallpaperEngine/Audio/Drivers/Detectors/AudioPlayingDetector.cpp @@ -0,0 +1,28 @@ +#include "AudioPlayingDetector.h" + +namespace WallpaperEngine::Audio::Drivers::Detectors { +AudioPlayingDetector::AudioPlayingDetector ( + Application::ApplicationContext& appContext, + const Render::Drivers::Detectors::FullScreenDetector& fullscreenDetector) : + m_applicationContext (appContext), + m_fullscreenDetector (fullscreenDetector) {} + +bool AudioPlayingDetector::anythingPlaying () const { + return this->m_isPlaying; +} + +Application::ApplicationContext& AudioPlayingDetector::getApplicationContext () { + return this->m_applicationContext; +} + +const Render::Drivers::Detectors::FullScreenDetector& AudioPlayingDetector::getFullscreenDetector () const { + return this->m_fullscreenDetector; +} + +void AudioPlayingDetector::setIsPlaying (bool newState) { + this->m_isPlaying = newState; +} + +void AudioPlayingDetector::update () {} + +} // namespace WallpaperEngine::Audio::Drivers::Detectors \ No newline at end of file diff --git a/src/WallpaperEngine/Audio/Drivers/Detectors/CAudioPlayingDetector.h b/src/WallpaperEngine/Audio/Drivers/Detectors/AudioPlayingDetector.h similarity index 54% rename from src/WallpaperEngine/Audio/Drivers/Detectors/CAudioPlayingDetector.h rename to src/WallpaperEngine/Audio/Drivers/Detectors/AudioPlayingDetector.h index c620754..c808c38 100644 --- a/src/WallpaperEngine/Audio/Drivers/Detectors/CAudioPlayingDetector.h +++ b/src/WallpaperEngine/Audio/Drivers/Detectors/AudioPlayingDetector.h @@ -1,28 +1,28 @@ #pragma once -#include "WallpaperEngine/Application/CApplicationContext.h" -#include "WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h" +#include "WallpaperEngine/Application/ApplicationContext.h" +#include "WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.h" namespace WallpaperEngine { namespace Application { -class CApplicationContext; +class ApplicationContext; } namespace Render::Drivers::Detectors { -class CFullScreenDetector; +class FullScreenDetector; } namespace Audio::Drivers::Detectors { /** * Base class for any implementation of audio playing detection */ -class CAudioPlayingDetector { +class AudioPlayingDetector { public: - CAudioPlayingDetector ( - Application::CApplicationContext& appContext, - const Render::Drivers::Detectors::CFullScreenDetector& fullscreenDetector); + AudioPlayingDetector ( + Application::ApplicationContext& appContext, + const Render::Drivers::Detectors::FullScreenDetector& fullscreenDetector); - virtual ~CAudioPlayingDetector () = default; + virtual ~AudioPlayingDetector () = default; /** * @return If any kind of sound is currently playing on the default audio device @@ -45,17 +45,17 @@ class CAudioPlayingDetector { /** * @return The application context using this detector */ - [[nodiscard]] Application::CApplicationContext& getApplicationContext (); + [[nodiscard]] Application::ApplicationContext& getApplicationContext (); /** * @return The fullscreen detector used */ - [[nodiscard]] const Render::Drivers::Detectors::CFullScreenDetector& getFullscreenDetector () const; + [[nodiscard]] const Render::Drivers::Detectors::FullScreenDetector& getFullscreenDetector () const; private: bool m_isPlaying = false; - Application::CApplicationContext& m_applicationContext; - const Render::Drivers::Detectors::CFullScreenDetector& m_fullscreenDetector; + Application::ApplicationContext& m_applicationContext; + const Render::Drivers::Detectors::FullScreenDetector& m_fullscreenDetector; }; } // namespace Audio::Drivers::Detectors } // namespace WallpaperEngine diff --git a/src/WallpaperEngine/Audio/Drivers/Detectors/CAudioPlayingDetector.cpp b/src/WallpaperEngine/Audio/Drivers/Detectors/CAudioPlayingDetector.cpp deleted file mode 100644 index 5c18def..0000000 --- a/src/WallpaperEngine/Audio/Drivers/Detectors/CAudioPlayingDetector.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "CAudioPlayingDetector.h" - -namespace WallpaperEngine::Audio::Drivers::Detectors { -CAudioPlayingDetector::CAudioPlayingDetector ( - Application::CApplicationContext& appContext, - const Render::Drivers::Detectors::CFullScreenDetector& fullscreenDetector) : - m_applicationContext (appContext), - m_fullscreenDetector (fullscreenDetector) {} - -bool CAudioPlayingDetector::anythingPlaying () const { - return this->m_isPlaying; -} - -Application::CApplicationContext& CAudioPlayingDetector::getApplicationContext () { - return this->m_applicationContext; -} - -const Render::Drivers::Detectors::CFullScreenDetector& CAudioPlayingDetector::getFullscreenDetector () const { - return this->m_fullscreenDetector; -} - -void CAudioPlayingDetector::setIsPlaying (bool newState) { - this->m_isPlaying = newState; -} - -void CAudioPlayingDetector::update () {} - -} // namespace WallpaperEngine::Audio::Drivers::Detectors \ No newline at end of file diff --git a/src/WallpaperEngine/Audio/Drivers/Detectors/CPulseAudioPlayingDetector.cpp b/src/WallpaperEngine/Audio/Drivers/Detectors/PulseAudioPlayingDetector.cpp similarity index 80% rename from src/WallpaperEngine/Audio/Drivers/Detectors/CPulseAudioPlayingDetector.cpp rename to src/WallpaperEngine/Audio/Drivers/Detectors/PulseAudioPlayingDetector.cpp index aac9fb3..6c404a0 100644 --- a/src/WallpaperEngine/Audio/Drivers/Detectors/CPulseAudioPlayingDetector.cpp +++ b/src/WallpaperEngine/Audio/Drivers/Detectors/PulseAudioPlayingDetector.cpp @@ -1,11 +1,11 @@ -#include "CPulseAudioPlayingDetector.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "PulseAudioPlayingDetector.h" +#include "WallpaperEngine/Logging/Log.h" #include namespace WallpaperEngine::Audio::Drivers::Detectors { void sinkInputInfoCallback (pa_context* context, const pa_sink_input_info* info, int eol, void* userdata) { - auto* detector = static_cast (userdata); + auto* detector = static_cast (userdata); if (info == nullptr) return; @@ -29,10 +29,10 @@ void defaultSinkInfoCallback (pa_context* context, const pa_server_info* info, v pa_operation_unref (op); } -CPulseAudioPlayingDetector::CPulseAudioPlayingDetector ( - Application::CApplicationContext& appContext, - const Render::Drivers::Detectors::CFullScreenDetector& fullscreenDetector) : - CAudioPlayingDetector (appContext, fullscreenDetector) { +PulseAudioPlayingDetector::PulseAudioPlayingDetector ( + Application::ApplicationContext& appContext, + const Render::Drivers::Detectors::FullScreenDetector& fullscreenDetector) : + AudioPlayingDetector (appContext, fullscreenDetector) { this->m_mainloop = pa_mainloop_new (); this->m_mainloopApi = pa_mainloop_get_api (this->m_mainloop); this->m_context = pa_context_new (this->m_mainloopApi, "wallpaperengine"); @@ -44,7 +44,7 @@ CPulseAudioPlayingDetector::CPulseAudioPlayingDetector ( pa_mainloop_iterate (this->m_mainloop, 1, nullptr); } -CPulseAudioPlayingDetector::~CPulseAudioPlayingDetector () { +PulseAudioPlayingDetector::~PulseAudioPlayingDetector () { if (this->m_context) { pa_context_disconnect (this->m_context); pa_context_unref (this->m_context); @@ -54,7 +54,7 @@ CPulseAudioPlayingDetector::~CPulseAudioPlayingDetector () { pa_mainloop_free (this->m_mainloop); } -void CPulseAudioPlayingDetector::update () { +void PulseAudioPlayingDetector::update () { if (!this->getApplicationContext ().settings.audio.automute) return this->setIsPlaying (false); if (this->getFullscreenDetector ().anythingFullscreen ()) diff --git a/src/WallpaperEngine/Audio/Drivers/Detectors/CPulseAudioPlayingDetector.h b/src/WallpaperEngine/Audio/Drivers/Detectors/PulseAudioPlayingDetector.h similarity index 55% rename from src/WallpaperEngine/Audio/Drivers/Detectors/CPulseAudioPlayingDetector.h rename to src/WallpaperEngine/Audio/Drivers/Detectors/PulseAudioPlayingDetector.h index bb063c9..f614369 100644 --- a/src/WallpaperEngine/Audio/Drivers/Detectors/CPulseAudioPlayingDetector.h +++ b/src/WallpaperEngine/Audio/Drivers/Detectors/PulseAudioPlayingDetector.h @@ -1,16 +1,16 @@ #pragma once -#include "CAudioPlayingDetector.h" +#include "AudioPlayingDetector.h" #include #include #include namespace WallpaperEngine::Audio::Drivers::Detectors { -class CPulseAudioPlayingDetector final : public CAudioPlayingDetector { +class PulseAudioPlayingDetector final : public AudioPlayingDetector { public: - explicit CPulseAudioPlayingDetector ( - Application::CApplicationContext& appContext, const Render::Drivers::Detectors::CFullScreenDetector&); - ~CPulseAudioPlayingDetector () override; + explicit PulseAudioPlayingDetector ( + Application::ApplicationContext& appContext, const Render::Drivers::Detectors::FullScreenDetector&); + ~PulseAudioPlayingDetector () override; void update () override; diff --git a/src/WallpaperEngine/Audio/Drivers/Recorders/CPlaybackRecorder.cpp b/src/WallpaperEngine/Audio/Drivers/Recorders/PlaybackRecorder.cpp similarity index 62% rename from src/WallpaperEngine/Audio/Drivers/Recorders/CPlaybackRecorder.cpp rename to src/WallpaperEngine/Audio/Drivers/Recorders/PlaybackRecorder.cpp index a00fdde..40f0a7c 100644 --- a/src/WallpaperEngine/Audio/Drivers/Recorders/CPlaybackRecorder.cpp +++ b/src/WallpaperEngine/Audio/Drivers/Recorders/PlaybackRecorder.cpp @@ -1,6 +1,6 @@ -#include "CPlaybackRecorder.h" +#include "PlaybackRecorder.h" namespace WallpaperEngine::Audio::Drivers::Recorders { -void CPlaybackRecorder::update () {} +void PlaybackRecorder::update () {} } // namespace WallpaperEngine::Audio::Drivers::Recorders \ No newline at end of file diff --git a/src/WallpaperEngine/Audio/Drivers/Recorders/CPlaybackRecorder.h b/src/WallpaperEngine/Audio/Drivers/Recorders/PlaybackRecorder.h similarity index 78% rename from src/WallpaperEngine/Audio/Drivers/Recorders/CPlaybackRecorder.h rename to src/WallpaperEngine/Audio/Drivers/Recorders/PlaybackRecorder.h index 9d97d1c..657385b 100644 --- a/src/WallpaperEngine/Audio/Drivers/Recorders/CPlaybackRecorder.h +++ b/src/WallpaperEngine/Audio/Drivers/Recorders/PlaybackRecorder.h @@ -1,9 +1,9 @@ #pragma once namespace WallpaperEngine::Audio::Drivers::Recorders { -class CPlaybackRecorder { +class PlaybackRecorder { public: - virtual ~CPlaybackRecorder () = default; + virtual ~PlaybackRecorder () = default; virtual void update (); diff --git a/src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.cpp b/src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.cpp similarity index 95% rename from src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.cpp rename to src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.cpp index 9205a29..e7c22b0 100644 --- a/src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.cpp +++ b/src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.cpp @@ -1,5 +1,5 @@ -#include "CPulseAudioPlaybackRecorder.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "PulseAudioPlaybackRecorder.h" +#include "WallpaperEngine/Logging/Log.h" #include #include #include @@ -21,7 +21,7 @@ void pa_stream_notify_cb (pa_stream* stream, void* /*userdata*/) { } void pa_stream_read_cb (pa_stream* stream, const size_t /*nbytes*/, void* userdata) { - auto* recorder = static_cast (userdata); + auto* recorder = static_cast (userdata); // Careful when to pa_stream_peek() and pa_stream_drop()! // c.f. https://www.freedesktop.org/software/pulseaudio/doxygen/stream_8h.html#ac2838c449cde56e169224d7fe3d00824 @@ -86,7 +86,7 @@ void pa_stream_read_cb (pa_stream* stream, const size_t /*nbytes*/, void* userda } void pa_server_info_cb (pa_context* ctx, const pa_server_info* info, void* userdata) { - auto* recorder = static_cast (userdata); + auto* recorder = static_cast (userdata); pa_sample_spec spec; spec.format = PA_SAMPLE_U8; @@ -149,7 +149,7 @@ void pa_context_notify_cb (pa_context* ctx, void* userdata) { } } -CPulseAudioPlaybackRecorder::CPulseAudioPlaybackRecorder () : +PulseAudioPlaybackRecorder::PulseAudioPlaybackRecorder () : m_captureData({ .kisscfg = kiss_fftr_alloc (WAVE_BUFFER_SIZE, 0, nullptr, nullptr), .audioBuffer = new uint8_t [WAVE_BUFFER_SIZE], @@ -171,7 +171,7 @@ CPulseAudioPlaybackRecorder::CPulseAudioPlaybackRecorder () : pa_mainloop_iterate (this->m_mainloop, 1, nullptr); } -CPulseAudioPlaybackRecorder::~CPulseAudioPlaybackRecorder () { +PulseAudioPlaybackRecorder::~PulseAudioPlaybackRecorder () { if (m_captureData.captureStream) { pa_stream_unref (m_captureData.captureStream); } @@ -184,7 +184,7 @@ CPulseAudioPlaybackRecorder::~CPulseAudioPlaybackRecorder () { pa_mainloop_free (this->m_mainloop); } -void CPulseAudioPlaybackRecorder::update () { +void PulseAudioPlaybackRecorder::update () { pa_mainloop_iterate (this->m_mainloop, 0, nullptr); // interpolate current values to the destination diff --git a/src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.h b/src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.h similarity index 76% rename from src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.h rename to src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.h index aa576fe..3f2c109 100644 --- a/src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.h +++ b/src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.h @@ -1,20 +1,20 @@ #pragma once +#include "PlaybackRecorder.h" #include "kiss_fftr.h" -#include "CPlaybackRecorder.h" #include #define WAVE_BUFFER_SIZE 1024 namespace WallpaperEngine::Audio::Drivers::Recorders { -class CPlaybackRecorder; +class PlaybackRecorder; -class CPulseAudioPlaybackRecorder final : public CPlaybackRecorder { +class PulseAudioPlaybackRecorder final : public PlaybackRecorder { public: /** * Struct that contains all the required data for the PulseAudio callbacks */ - struct SPulseAudioData { + struct PulseAudioData { kiss_fftr_cfg kisscfg; uint8_t* audioBuffer; uint8_t* audioBufferTmp; @@ -23,8 +23,8 @@ class CPulseAudioPlaybackRecorder final : public CPlaybackRecorder { pa_stream* captureStream; }; - CPulseAudioPlaybackRecorder (); - ~CPulseAudioPlaybackRecorder () override; + PulseAudioPlaybackRecorder (); + ~PulseAudioPlaybackRecorder () override; void update () override; @@ -32,7 +32,7 @@ class CPulseAudioPlaybackRecorder final : public CPlaybackRecorder { pa_mainloop* m_mainloop; pa_mainloop_api* m_mainloopApi; pa_context* m_context; - SPulseAudioData m_captureData; + PulseAudioData m_captureData; float m_audioFFTbuffer [WAVE_BUFFER_SIZE] = {0.0f}; kiss_fft_cpx m_FFTinfo [WAVE_BUFFER_SIZE / 2 + 1] = {0}; diff --git a/src/WallpaperEngine/Audio/Drivers/CSDLAudioDriver.cpp b/src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.cpp similarity index 82% rename from src/WallpaperEngine/Audio/Drivers/CSDLAudioDriver.cpp rename to src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.cpp index fc948c7..679a020 100644 --- a/src/WallpaperEngine/Audio/Drivers/CSDLAudioDriver.cpp +++ b/src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.cpp @@ -1,5 +1,5 @@ -#include "CSDLAudioDriver.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "SDLAudioDriver.h" +#include "WallpaperEngine/Logging/Log.h" #define SDL_AUDIO_BUFFER_SIZE 4096 #define MAX_AUDIO_FRAME_SIZE 192000 @@ -8,7 +8,7 @@ using namespace WallpaperEngine::Audio; using namespace WallpaperEngine::Audio::Drivers; void audio_callback (void* userdata, uint8_t* streamData, int length) { - auto* driver = static_cast (userdata); + auto* driver = static_cast (userdata); memset (streamData, 0, length); @@ -64,11 +64,11 @@ void audio_callback (void* userdata, uint8_t* streamData, int length) { } } -CSDLAudioDriver::CSDLAudioDriver ( - Application::CApplicationContext& applicationContext, Detectors::CAudioPlayingDetector& detector, - Recorders::CPlaybackRecorder& recorder +SDLAudioDriver::SDLAudioDriver ( + Application::ApplicationContext& applicationContext, Detectors::AudioPlayingDetector& detector, + Recorders::PlaybackRecorder& recorder ) : - CAudioDriver (applicationContext, detector, recorder), + AudioDriver (applicationContext, detector, recorder), m_audioSpec () { if (SDL_InitSubSystem (SDL_INIT_AUDIO) < 0) { sLog.error ("Cannot initialize SDL audio system, SDL_GetError: ", SDL_GetError ()); @@ -99,7 +99,7 @@ CSDLAudioDriver::CSDLAudioDriver ( this->m_initialized = true; } -CSDLAudioDriver::~CSDLAudioDriver () { +SDLAudioDriver::~SDLAudioDriver () { if (!this->m_initialized) return; @@ -107,15 +107,15 @@ CSDLAudioDriver::~CSDLAudioDriver () { SDL_QuitSubSystem (SDL_INIT_AUDIO); } -void CSDLAudioDriver::addStream (CAudioStream* stream) { - this->m_streams.push_back (new CSDLAudioBuffer {stream}); +void SDLAudioDriver::addStream (AudioStream* stream) { + this->m_streams.push_back (new SDLAudioBuffer {stream}); } -const std::vector& CSDLAudioDriver::getStreams () { +const std::vector& SDLAudioDriver::getStreams () { return this->m_streams; } -AVSampleFormat CSDLAudioDriver::getFormat () const { +AVSampleFormat SDLAudioDriver::getFormat () const { switch (this->m_audioSpec.format) { case AUDIO_U8: case AUDIO_S8: return AV_SAMPLE_FMT_U8; @@ -132,14 +132,14 @@ AVSampleFormat CSDLAudioDriver::getFormat () const { sLog.exception ("Cannot convert from SDL format to ffmpeg format, aborting..."); } -int CSDLAudioDriver::getSampleRate () const { +int SDLAudioDriver::getSampleRate () const { return this->m_audioSpec.freq; } -int CSDLAudioDriver::getChannels () const { +int SDLAudioDriver::getChannels () const { return this->m_audioSpec.channels; } -const SDL_AudioSpec& CSDLAudioDriver::getSpec () const { +const SDL_AudioSpec& SDLAudioDriver::getSpec () const { return this->m_audioSpec; } \ No newline at end of file diff --git a/src/WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h b/src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.h similarity index 66% rename from src/WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h rename to src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.h index 3e441e7..68c3aef 100644 --- a/src/WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h +++ b/src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.h @@ -3,8 +3,8 @@ #include #include -#include "WallpaperEngine/Audio/CAudioStream.h" -#include "WallpaperEngine/Audio/Drivers/CAudioDriver.h" +#include "WallpaperEngine/Audio/AudioStream.h" +#include "WallpaperEngine/Audio/Drivers/AudioDriver.h" #include @@ -14,8 +14,8 @@ namespace WallpaperEngine::Audio::Drivers { /** * Audio output buffers for streams being played under SDL */ -struct CSDLAudioBuffer { - CAudioStream* stream = nullptr; +struct SDLAudioBuffer { + AudioStream* stream = nullptr; uint8_t audio_buf [(MAX_AUDIO_FRAME_SIZE * 3) / 2] = {0}; unsigned int audio_buf_size = 0; unsigned int audio_buf_index = 0; @@ -24,19 +24,19 @@ struct CSDLAudioBuffer { /** * SDL's audio driver implementation */ -class CSDLAudioDriver final : public CAudioDriver { +class SDLAudioDriver final : public AudioDriver { public: - CSDLAudioDriver ( - Application::CApplicationContext& applicationContext, Detectors::CAudioPlayingDetector& detector, - Recorders::CPlaybackRecorder& recorder); - ~CSDLAudioDriver () override; + SDLAudioDriver ( + Application::ApplicationContext& applicationContext, Detectors::AudioPlayingDetector& detector, + Recorders::PlaybackRecorder& recorder); + ~SDLAudioDriver () override; /** @inheritdoc */ - void addStream (CAudioStream* stream) override; + void addStream (AudioStream* stream) override; /** * @return All the registered audio streams */ - const std::vector& getStreams (); + const std::vector& getStreams (); /** @inheritdoc */ [[nodiscard]] AVSampleFormat getFormat () const override; @@ -57,6 +57,6 @@ class CSDLAudioDriver final : public CAudioDriver { /** The sound output configuration */ SDL_AudioSpec m_audioSpec {}; /** All the playable steams */ - std::vector m_streams {}; + std::vector m_streams {}; }; } // namespace WallpaperEngine::Audio::Drivers \ No newline at end of file diff --git a/src/WallpaperEngine/Data/Builders/VectorBuilder.h b/src/WallpaperEngine/Data/Builders/VectorBuilder.h index e1908c6..2a6a07c 100644 --- a/src/WallpaperEngine/Data/Builders/VectorBuilder.h +++ b/src/WallpaperEngine/Data/Builders/VectorBuilder.h @@ -5,8 +5,8 @@ #include #include -#include "WallpaperEngine/Logging/CLog.h" #include "WallpaperEngine/Data/Utils/SFINAE.h" +#include "WallpaperEngine/Logging/Log.h" namespace WallpaperEngine::Data::Builders { using namespace WallpaperEngine::Data::Utils::SFINAE; diff --git a/src/WallpaperEngine/Data/JSON.h b/src/WallpaperEngine/Data/JSON.h index 5341964..42c8019 100644 --- a/src/WallpaperEngine/Data/JSON.h +++ b/src/WallpaperEngine/Data/JSON.h @@ -9,9 +9,9 @@ #include "WallpaperEngine/Data/Builders/UserSettingBuilder.h" #include "WallpaperEngine/Data/Builders/VectorBuilder.h" -#include "WallpaperEngine/Data/Utils/SFINAE.h" #include "WallpaperEngine/Data/Model/Types.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Data/Utils/SFINAE.h" +#include "WallpaperEngine/Logging/Log.h" namespace WallpaperEngine::Data::JSON { using namespace WallpaperEngine::Data::Builders; diff --git a/src/WallpaperEngine/Data/Parsers/ObjectParser.cpp b/src/WallpaperEngine/Data/Parsers/ObjectParser.cpp index 5d617fb..158ced1 100644 --- a/src/WallpaperEngine/Data/Parsers/ObjectParser.cpp +++ b/src/WallpaperEngine/Data/Parsers/ObjectParser.cpp @@ -5,7 +5,7 @@ #include "ShaderConstantParser.h" #include "WallpaperEngine/Data/Model/Object.h" #include "WallpaperEngine/Data/Model/Project.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" using namespace WallpaperEngine::Data::Parsers; using namespace WallpaperEngine::Data::Model; diff --git a/src/WallpaperEngine/Data/Parsers/PackageParser.cpp b/src/WallpaperEngine/Data/Parsers/PackageParser.cpp index 751f22f..f627ac0 100644 --- a/src/WallpaperEngine/Data/Parsers/PackageParser.cpp +++ b/src/WallpaperEngine/Data/Parsers/PackageParser.cpp @@ -1,7 +1,7 @@ #include "PackageParser.h" #include "WallpaperEngine/Data/Utils/BinaryReader.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" #include "WallpaperEngine/Data/Assets/Package.h" diff --git a/src/WallpaperEngine/Data/Parsers/ProjectParser.cpp b/src/WallpaperEngine/Data/Parsers/ProjectParser.cpp index b76a13c..d087abd 100644 --- a/src/WallpaperEngine/Data/Parsers/ProjectParser.cpp +++ b/src/WallpaperEngine/Data/Parsers/ProjectParser.cpp @@ -1,7 +1,7 @@ #include #include "ProjectParser.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" #include "WallpaperParser.h" diff --git a/src/WallpaperEngine/Data/Parsers/TextureParser.cpp b/src/WallpaperEngine/Data/Parsers/TextureParser.cpp index 2360fca..998a13e 100644 --- a/src/WallpaperEngine/Data/Parsers/TextureParser.cpp +++ b/src/WallpaperEngine/Data/Parsers/TextureParser.cpp @@ -4,7 +4,7 @@ #include "TextureParser.h" #include "WallpaperEngine/Data/Assets/Texture.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" using namespace WallpaperEngine::Data::Assets; using namespace WallpaperEngine::Data::Parsers; diff --git a/src/WallpaperEngine/Data/Parsers/UserSettingParser.h b/src/WallpaperEngine/Data/Parsers/UserSettingParser.h index 758497b..7a15238 100644 --- a/src/WallpaperEngine/Data/Parsers/UserSettingParser.h +++ b/src/WallpaperEngine/Data/Parsers/UserSettingParser.h @@ -3,7 +3,7 @@ #include "WallpaperEngine/Data/JSON.h" #include "WallpaperEngine/Data/Model/Types.h" #include "WallpaperEngine/Data/Model/UserSetting.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" namespace WallpaperEngine::Data::Parsers { using json = WallpaperEngine::Data::JSON::JSON; diff --git a/src/WallpaperEngine/Data/Parsers/WallpaperParser.cpp b/src/WallpaperEngine/Data/Parsers/WallpaperParser.cpp index ad24bbd..edf1bbc 100644 --- a/src/WallpaperEngine/Data/Parsers/WallpaperParser.cpp +++ b/src/WallpaperEngine/Data/Parsers/WallpaperParser.cpp @@ -4,7 +4,7 @@ #include "WallpaperEngine/Data/Model/Project.h" #include "WallpaperEngine/Data/Model/Wallpaper.h" #include "WallpaperEngine/FileSystem/Container.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" using namespace WallpaperEngine::Data::Parsers; diff --git a/src/WallpaperEngine/FileSystem/Adapters/Directory.cpp b/src/WallpaperEngine/FileSystem/Adapters/Directory.cpp index c226ee7..91d09bc 100644 --- a/src/WallpaperEngine/FileSystem/Adapters/Directory.cpp +++ b/src/WallpaperEngine/FileSystem/Adapters/Directory.cpp @@ -4,7 +4,7 @@ #include "Directory.h" -#include "WallpaperEngine/Assets/CAssetLoadException.h" +#include "WallpaperEngine/Assets/AssetLoadException.h" using namespace WallpaperEngine::FileSystem; using namespace WallpaperEngine::FileSystem::Adapters; @@ -57,7 +57,7 @@ std::filesystem::path DirectoryAdapter::physicalPath (const std::filesystem::pat auto finalpath = std::filesystem::canonical(this->basepath / path); if (finalpath.string ().find (this->basepath.string ()) != 0) { - throw Assets::CAssetLoadException ("Cannot find file", path); + throw Render::AssetLoadException ("Cannot find file", path); } return finalpath; diff --git a/src/WallpaperEngine/FileSystem/Adapters/Package.cpp b/src/WallpaperEngine/FileSystem/Adapters/Package.cpp index 009ca36..cf3cdf5 100644 --- a/src/WallpaperEngine/FileSystem/Adapters/Package.cpp +++ b/src/WallpaperEngine/FileSystem/Adapters/Package.cpp @@ -3,7 +3,7 @@ #include "Package.h" -#include "WallpaperEngine/Assets/CAssetLoadException.h" +#include "WallpaperEngine/Assets/AssetLoadException.h" #include "WallpaperEngine/Data/Parsers/PackageParser.h" #include "WallpaperEngine/Data/Utils/BinaryReader.h" #include "WallpaperEngine/Data/Utils/MemoryStream.h" @@ -45,7 +45,7 @@ bool PackageAdapter::exists (const std::filesystem::path& path) const { } std::filesystem::path PackageAdapter::physicalPath (const std::filesystem::path& path) const { - throw Assets::CAssetLoadException ("Package adapter does not support realpath", path); + throw Render::AssetLoadException ("Package adapter does not support realpath", path); } bool PackageFactory::handlesMountpoint (const std::filesystem::path& path) const { diff --git a/src/WallpaperEngine/FileSystem/Adapters/Virtual.cpp b/src/WallpaperEngine/FileSystem/Adapters/Virtual.cpp index d8cc424..7363ec4 100644 --- a/src/WallpaperEngine/FileSystem/Adapters/Virtual.cpp +++ b/src/WallpaperEngine/FileSystem/Adapters/Virtual.cpp @@ -1,6 +1,6 @@ #include "Virtual.h" -#include "WallpaperEngine/Assets/CAssetLoadException.h" +#include "WallpaperEngine/Assets/AssetLoadException.h" #include @@ -22,7 +22,7 @@ bool VirtualAdapter::exists (const std::filesystem::path& path) const { } std::filesystem::path VirtualAdapter::physicalPath (const std::filesystem::path& path) const { - throw Assets::CAssetLoadException ("Virtual adapter does not support realpath", path); + throw Render::AssetLoadException ("Virtual adapter does not support realpath", path); } diff --git a/src/WallpaperEngine/FileSystem/Container.cpp b/src/WallpaperEngine/FileSystem/Container.cpp index f4f215e..0b03c5b 100644 --- a/src/WallpaperEngine/FileSystem/Container.cpp +++ b/src/WallpaperEngine/FileSystem/Container.cpp @@ -7,8 +7,8 @@ #include "Adapters/Package.h" #include "Adapters/Types.h" #include "Adapters/Virtual.h" -#include "WallpaperEngine/Assets/CAssetLoadException.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Assets/AssetLoadException.h" +#include "WallpaperEngine/Logging/Log.h" using namespace WallpaperEngine::FileSystem; using namespace WallpaperEngine::FileSystem::Adapters; @@ -56,7 +56,6 @@ Container::Container () { this->m_factories.push_back (std::make_unique ()); this->m_factories.push_back (std::make_unique ()); - // TODO: FIND A BETTER WAY OF MOUNTING THE VIRTUAL FILESYSTEM this->m_vfs = std::make_shared (); this->m_mountpoints.emplace_back ("/", this->m_vfs); // mount the current directory as root @@ -64,9 +63,9 @@ Container::Container () { } ReadStreamSharedPtr Container::read (const std::filesystem::path& path) const { - std::filesystem::path normalized = normalize_path (path); + const auto normalized = normalize_path (path); - return this->resolveAdapterForFile (path).open (normalized); + return this->resolveAdapterForFile (path).open (normalized); } std::string Container::readString (const std::filesystem::path& path) const { @@ -77,9 +76,9 @@ std::string Container::readString (const std::filesystem::path& path) const { } std::filesystem::path Container::physicalPath (const std::filesystem::path& path) const { - std::filesystem::path normalized = normalize_path (path); + const auto normalized = normalize_path (path); - return this->resolveAdapterForFile (path).physicalPath (normalized); + return this->resolveAdapterForFile (path).physicalPath (normalized); } @@ -101,16 +100,15 @@ VirtualAdapter& Container::getVFS () const { } Adapter& Container::resolveAdapterForFile (const std::filesystem::path& path) const { - std::filesystem::path normalized = normalize_path (path); + const auto normalized = normalize_path (path); for (const auto& [root, adapter] : this->m_mountpoints) { if (normalized.string().starts_with (root.string()) == false) { continue; } - std::filesystem::path relative = normalized.string().substr (root.string().length()); - - if (adapter->exists (relative) == false) { + if (const auto relative = normalized.string ().substr (root.string ().length ()); + adapter->exists (relative) == false) { continue; } @@ -122,5 +120,5 @@ Adapter& Container::resolveAdapterForFile (const std::filesystem::path& path) co return this->resolveAdapterForFile ("/" + normalized.string()); } - throw Assets::CAssetLoadException ("Cannot find requested file ", path); + throw Render::AssetLoadException ("Cannot find requested file ", path); } diff --git a/src/WallpaperEngine/Input/CInputContext.cpp b/src/WallpaperEngine/Input/CInputContext.cpp deleted file mode 100644 index 025b07e..0000000 --- a/src/WallpaperEngine/Input/CInputContext.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "CInputContext.h" - -using namespace WallpaperEngine::Input; -using namespace WallpaperEngine::Render::Drivers; - -CInputContext::CInputContext (CMouseInput& mouseInput) : m_mouse (mouseInput) {} - -void CInputContext::update () { - this->m_mouse.update (); -} - -const CMouseInput& CInputContext::getMouseInput () const { - return this->m_mouse; -} \ No newline at end of file diff --git a/src/WallpaperEngine/Input/CMouseInput.cpp b/src/WallpaperEngine/Input/CMouseInput.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.cpp b/src/WallpaperEngine/Input/Drivers/GLFWMouseInput.cpp similarity index 72% rename from src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.cpp rename to src/WallpaperEngine/Input/Drivers/GLFWMouseInput.cpp index 1d28bb4..8d00386 100644 --- a/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.cpp +++ b/src/WallpaperEngine/Input/Drivers/GLFWMouseInput.cpp @@ -1,14 +1,14 @@ -#include "CGLFWMouseInput.h" +#include "GLFWMouseInput.h" #include -#include "WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h" +#include "WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.h" using namespace WallpaperEngine::Input::Drivers; -CGLFWMouseInput::CGLFWMouseInput (const Render::Drivers::CGLFWOpenGLDriver& driver) : +GLFWMouseInput::GLFWMouseInput (const Render::Drivers::GLFWOpenGLDriver& driver) : m_driver (driver) {} -void CGLFWMouseInput::update () { +void GLFWMouseInput::update () { if (!this->m_driver.getApp ().getContext ().settings.mouse.enabled) { this->m_reportedPosition = {0, 0}; return; @@ -26,14 +26,14 @@ void CGLFWMouseInput::update () { this->m_reportedPosition = glm::mix (this->m_reportedPosition, this->m_mousePosition, 1.0); } -glm::dvec2 CGLFWMouseInput::position () const { +glm::dvec2 GLFWMouseInput::position () const { return this->m_reportedPosition; } -WallpaperEngine::Input::MouseClickStatus CGLFWMouseInput::leftClick () const { +WallpaperEngine::Input::MouseClickStatus GLFWMouseInput::leftClick () const { return m_leftClick; } -WallpaperEngine::Input::MouseClickStatus CGLFWMouseInput::rightClick () const { +WallpaperEngine::Input::MouseClickStatus GLFWMouseInput::rightClick () const { return m_rightClick; } \ No newline at end of file diff --git a/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.h b/src/WallpaperEngine/Input/Drivers/GLFWMouseInput.h similarity index 78% rename from src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.h rename to src/WallpaperEngine/Input/Drivers/GLFWMouseInput.h index 5bc2884..a496d2f 100644 --- a/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.h +++ b/src/WallpaperEngine/Input/Drivers/GLFWMouseInput.h @@ -1,20 +1,20 @@ #pragma once -#include "WallpaperEngine/Input/CMouseInput.h" +#include "WallpaperEngine/Input/MouseInput.h" #include namespace WallpaperEngine::Render::Drivers { -class CGLFWOpenGLDriver; +class GLFWOpenGLDriver; } namespace WallpaperEngine::Input::Drivers { /** * Handles mouse input for the background */ -class CGLFWMouseInput final : public CMouseInput { +class GLFWMouseInput final : public MouseInput { public: - explicit CGLFWMouseInput (const Render::Drivers::CGLFWOpenGLDriver& driver); + explicit GLFWMouseInput (const Render::Drivers::GLFWOpenGLDriver& driver); /** * Takes current mouse position and updates it @@ -37,7 +37,7 @@ class CGLFWMouseInput final : public CMouseInput { [[nodiscard]] MouseClickStatus rightClick () const override; private: - const Render::Drivers::CGLFWOpenGLDriver& m_driver; + const Render::Drivers::GLFWOpenGLDriver& m_driver; /** * The current mouse position diff --git a/src/WallpaperEngine/Input/Drivers/CWaylandMouseInput.cpp b/src/WallpaperEngine/Input/Drivers/WaylandMouseInput.cpp similarity index 63% rename from src/WallpaperEngine/Input/Drivers/CWaylandMouseInput.cpp rename to src/WallpaperEngine/Input/Drivers/WaylandMouseInput.cpp index b1a703e..4b837f4 100644 --- a/src/WallpaperEngine/Input/Drivers/CWaylandMouseInput.cpp +++ b/src/WallpaperEngine/Input/Drivers/WaylandMouseInput.cpp @@ -1,15 +1,15 @@ +#include "WaylandMouseInput.h" +#include "WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.h" #include -#include "CWaylandMouseInput.h" -#include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h" using namespace WallpaperEngine::Input::Drivers; -CWaylandMouseInput::CWaylandMouseInput (const WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver& driver) : +WaylandMouseInput::WaylandMouseInput (const WallpaperEngine::Render::Drivers::WaylandOpenGLDriver& driver) : m_waylandDriver (driver) {} -void CWaylandMouseInput::update () {} +void WaylandMouseInput::update () {} -glm::dvec2 CWaylandMouseInput::position () const { +glm::dvec2 WaylandMouseInput::position () const { if (!this->m_waylandDriver.getApp ().getContext ().settings.mouse.enabled) { return {0, 0}; } @@ -20,14 +20,14 @@ glm::dvec2 CWaylandMouseInput::position () const { return {0, 0}; } -WallpaperEngine::Input::MouseClickStatus CWaylandMouseInput::leftClick () const { +WallpaperEngine::Input::MouseClickStatus WaylandMouseInput::leftClick () const { if (m_waylandDriver.viewportInFocus && m_waylandDriver.viewportInFocus->rendering) return m_waylandDriver.viewportInFocus->leftClick; return MouseClickStatus::Released; } -WallpaperEngine::Input::MouseClickStatus CWaylandMouseInput::rightClick () const { +WallpaperEngine::Input::MouseClickStatus WaylandMouseInput::rightClick () const { if (m_waylandDriver.viewportInFocus && m_waylandDriver.viewportInFocus->rendering) return m_waylandDriver.viewportInFocus->rightClick; diff --git a/src/WallpaperEngine/Input/Drivers/CWaylandMouseInput.h b/src/WallpaperEngine/Input/Drivers/WaylandMouseInput.h similarity index 72% rename from src/WallpaperEngine/Input/Drivers/CWaylandMouseInput.h rename to src/WallpaperEngine/Input/Drivers/WaylandMouseInput.h index d3f3cd4..6f1ad89 100644 --- a/src/WallpaperEngine/Input/Drivers/CWaylandMouseInput.h +++ b/src/WallpaperEngine/Input/Drivers/WaylandMouseInput.h @@ -2,21 +2,21 @@ #ifdef ENABLE_WAYLAND -#include "WallpaperEngine/Input/CMouseInput.h" +#include "WallpaperEngine/Input/MouseInput.h" #include namespace WallpaperEngine::Render::Drivers { -class CWaylandOpenGLDriver; +class WaylandOpenGLDriver; }; namespace WallpaperEngine::Input::Drivers { /** * Handles mouse input for the background */ -class CWaylandMouseInput final : public CMouseInput { +class WaylandMouseInput final : public MouseInput { public: - explicit CWaylandMouseInput (const WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver& driver); + explicit WaylandMouseInput (const WallpaperEngine::Render::Drivers::WaylandOpenGLDriver& driver); /** * Takes current mouse position and updates it @@ -42,7 +42,7 @@ class CWaylandMouseInput final : public CMouseInput { /** * Wayland: Driver */ - const WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver& m_waylandDriver; + const WallpaperEngine::Render::Drivers::WaylandOpenGLDriver& m_waylandDriver; glm::dvec2 m_pos = {}; }; diff --git a/src/WallpaperEngine/Input/InputContext.cpp b/src/WallpaperEngine/Input/InputContext.cpp new file mode 100644 index 0000000..89f782e --- /dev/null +++ b/src/WallpaperEngine/Input/InputContext.cpp @@ -0,0 +1,14 @@ +#include "InputContext.h" + +using namespace WallpaperEngine::Input; +using namespace WallpaperEngine::Render::Drivers; + +InputContext::InputContext (MouseInput& mouseInput) : m_mouse (mouseInput) {} + +void InputContext::update () { + this->m_mouse.update (); +} + +const MouseInput& InputContext::getMouseInput () const { + return this->m_mouse; +} \ No newline at end of file diff --git a/src/WallpaperEngine/Input/CInputContext.h b/src/WallpaperEngine/Input/InputContext.h similarity index 52% rename from src/WallpaperEngine/Input/CInputContext.h rename to src/WallpaperEngine/Input/InputContext.h index 46eee81..4f6c1d3 100644 --- a/src/WallpaperEngine/Input/CInputContext.h +++ b/src/WallpaperEngine/Input/InputContext.h @@ -1,24 +1,24 @@ #pragma once -#include "CMouseInput.h" +#include "MouseInput.h" namespace WallpaperEngine::Render::Drivers { -class CVideoDriver; +class VideoDriver; } namespace WallpaperEngine::Input { -class CInputContext { +class InputContext { public: - explicit CInputContext (CMouseInput& mouseInput); + explicit InputContext (MouseInput& mouseInput); /** * Updates input information */ void update (); - [[nodiscard]] const CMouseInput& getMouseInput () const; + [[nodiscard]] const MouseInput& getMouseInput () const; private: - CMouseInput& m_mouse; + MouseInput& m_mouse; }; } // namespace WallpaperEngine::Input diff --git a/src/WallpaperEngine/Input/CMouseInput.h b/src/WallpaperEngine/Input/MouseInput.h similarity index 92% rename from src/WallpaperEngine/Input/CMouseInput.h rename to src/WallpaperEngine/Input/MouseInput.h index 9ab41b8..d13811c 100644 --- a/src/WallpaperEngine/Input/CMouseInput.h +++ b/src/WallpaperEngine/Input/MouseInput.h @@ -11,9 +11,9 @@ enum MouseClickStatus : int { /** * Handles mouse input for the background */ -class CMouseInput { +class MouseInput { public: - virtual ~CMouseInput () = default; + virtual ~MouseInput () = default; /** * Takes current mouse position and updates it */ diff --git a/src/WallpaperEngine/Logging/CLog.cpp b/src/WallpaperEngine/Logging/Log.cpp similarity index 53% rename from src/WallpaperEngine/Logging/CLog.cpp rename to src/WallpaperEngine/Logging/Log.cpp index 9be98c6..3699b85 100644 --- a/src/WallpaperEngine/Logging/CLog.cpp +++ b/src/WallpaperEngine/Logging/Log.cpp @@ -1,28 +1,28 @@ -#include "CLog.h" +#include "Log.h" #include #include using namespace WallpaperEngine::Logging; -CLog::CLog () { +Log::Log () { assert (this->sInstance == nullptr); } -CLog& CLog::get () { +Log& Log::get () { if (sInstance == nullptr) { - sInstance = std::make_unique (); + sInstance = std::make_unique (); } return *sInstance; } -void CLog::addOutput (std::ostream* stream) { +void Log::addOutput (std::ostream* stream) { this->mOutputs.push_back (stream); } -void CLog::addError (std::ostream* stream) { +void Log::addError (std::ostream* stream) { this->mErrors.push_back (stream); } -std::unique_ptr CLog::sInstance = nullptr; \ No newline at end of file +std::unique_ptr Log::sInstance = nullptr; \ No newline at end of file diff --git a/src/WallpaperEngine/Logging/CLog.h b/src/WallpaperEngine/Logging/Log.h similarity index 94% rename from src/WallpaperEngine/Logging/CLog.h rename to src/WallpaperEngine/Logging/Log.h index 9a86c91..1b659a4 100644 --- a/src/WallpaperEngine/Logging/CLog.h +++ b/src/WallpaperEngine/Logging/Log.h @@ -10,9 +10,9 @@ namespace WallpaperEngine::Logging { /** * Singleton class, simplifies logging for the whole app */ -class CLog { +class Log { public: - CLog (); + Log (); void addOutput (std::ostream* stream); void addError (std::ostream* stream); @@ -67,7 +67,7 @@ class CLog { this->exception (data...); } - static CLog& get (); + static Log& get (); private: template std::string buildBuffer (Data... data) { @@ -82,8 +82,8 @@ class CLog { std::vector mOutputs = {}; std::vector mErrors = {}; - static std::unique_ptr sInstance; + static std::unique_ptr sInstance; }; } // namespace WallpaperEngine::Logging -#define sLog (WallpaperEngine::Logging::CLog::get ()) \ No newline at end of file +#define sLog (WallpaperEngine::Logging::Log::get ()) \ No newline at end of file diff --git a/src/WallpaperEngine/Render/CFBO.cpp b/src/WallpaperEngine/Render/CFBO.cpp index 1605c1c..2e9d3a2 100644 --- a/src/WallpaperEngine/Render/CFBO.cpp +++ b/src/WallpaperEngine/Render/CFBO.cpp @@ -1,5 +1,5 @@ #include "CFBO.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" using namespace WallpaperEngine::Render; diff --git a/src/WallpaperEngine/Render/CFBO.h b/src/WallpaperEngine/Render/CFBO.h index 8463fc9..bffb5d1 100644 --- a/src/WallpaperEngine/Render/CFBO.h +++ b/src/WallpaperEngine/Render/CFBO.h @@ -2,12 +2,12 @@ #include -#include "ITexture.h" +#include "TextureProvider.h" -using namespace WallpaperEngine::Assets; +using namespace WallpaperEngine::Render; namespace WallpaperEngine::Render { -class CFBO final : public ITexture { +class CFBO final : public TextureProvider { public: CFBO (std::string name, TextureFormat format, uint32_t flags, float scale, uint32_t realWidth, uint32_t realHeight, uint32_t textureWidth, uint32_t textureHeight); diff --git a/src/WallpaperEngine/Render/CObject.cpp b/src/WallpaperEngine/Render/CObject.cpp index 2dd00de..e897a7f 100644 --- a/src/WallpaperEngine/Render/CObject.cpp +++ b/src/WallpaperEngine/Render/CObject.cpp @@ -7,7 +7,7 @@ using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Render::Wallpapers; CObject::CObject (Wallpapers::CScene& scene, const Object& object) : - Helpers::CContextAware (scene), + Helpers::ContextAware (scene), m_scene (scene), m_object (object) {} diff --git a/src/WallpaperEngine/Render/CObject.h b/src/WallpaperEngine/Render/CObject.h index 36e4f46..52c643d 100644 --- a/src/WallpaperEngine/Render/CObject.h +++ b/src/WallpaperEngine/Render/CObject.h @@ -2,7 +2,7 @@ #include -#include "WallpaperEngine/Render/Helpers/CContextAware.h" +#include "WallpaperEngine/Render/Helpers/ContextAware.h" #include "WallpaperEngine/Render/Wallpapers/CScene.h" @@ -11,7 +11,7 @@ class CScene; } namespace WallpaperEngine::Render { -class CObject : public Helpers::CContextAware { +class CObject : public Helpers::ContextAware { public: template [[nodiscard]] const T* as () const { if (is ()) { diff --git a/src/WallpaperEngine/Render/CRenderContext.h b/src/WallpaperEngine/Render/CRenderContext.h deleted file mode 100644 index 97fc6f3..0000000 --- a/src/WallpaperEngine/Render/CRenderContext.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "CTextureCache.h" -#include "WallpaperEngine/Application/CWallpaperApplication.h" -#include "WallpaperEngine/Input/CInputContext.h" -#include "WallpaperEngine/Input/CMouseInput.h" -#include "WallpaperEngine/Render/Drivers/CVideoDriver.h" -#include "WallpaperEngine/Render/Drivers/Output/COutput.h" -#include "WallpaperEngine/Render/Drivers/Output/COutputViewport.h" - -namespace WallpaperEngine { -namespace Application { -class CWallpaperApplication; -} - -namespace Render { -namespace Drivers { -class CVideoDriver; - -namespace Output { -class COutput; -class COutputViewport; -} // namespace Output -} // namespace Drivers - -class CWallpaper; -class CTextureCache; - -class CRenderContext { - public: - CRenderContext (Drivers::CVideoDriver& driver, CWallpaperApplication& app); - - void render (Drivers::Output::COutputViewport* viewport); - void setWallpaper (const std::string& display, std::shared_ptr wallpaper); - void setPause (bool newState); - [[nodiscard]] Input::CInputContext& getInputContext () const; - [[nodiscard]] const CWallpaperApplication& getApp () const; - [[nodiscard]] const Drivers::CVideoDriver& getDriver () const; - [[nodiscard]] const Drivers::Output::COutput& getOutput () const; - std::shared_ptr resolveTexture (const std::string& name); - [[nodiscard]] const std::map>& getWallpapers () const; - - private: - /** Video driver in use */ - Drivers::CVideoDriver& m_driver; - /** Maps screen -> wallpaper list */ - std::map> m_wallpapers = {}; - /** App that holds the render context */ - CWallpaperApplication& m_app; - /** Texture cache for the render */ - CTextureCache* m_textureCache = nullptr; -}; -} // namespace Render -} // namespace WallpaperEngine diff --git a/src/WallpaperEngine/Render/CTexture.cpp b/src/WallpaperEngine/Render/CTexture.cpp index 642afe8..40dc111 100644 --- a/src/WallpaperEngine/Render/CTexture.cpp +++ b/src/WallpaperEngine/Render/CTexture.cpp @@ -1,5 +1,5 @@ #include "CTexture.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" #include #include @@ -8,7 +8,7 @@ #define STB_IMAGE_IMPLEMENTATION #include -using namespace WallpaperEngine::Assets; +using namespace WallpaperEngine::Render; CTexture::CTexture (TextureUniquePtr header) : m_header (std::move(header)) { // ensure the header is parsed diff --git a/src/WallpaperEngine/Render/CTexture.h b/src/WallpaperEngine/Render/CTexture.h index e8fd86b..c2cb45d 100644 --- a/src/WallpaperEngine/Render/CTexture.h +++ b/src/WallpaperEngine/Render/CTexture.h @@ -1,6 +1,6 @@ #pragma once -#include "ITexture.h" +#include "TextureProvider.h" #include "WallpaperEngine/Data/Assets/Texture.h" #include @@ -8,13 +8,13 @@ #include #include -namespace WallpaperEngine::Assets { +namespace WallpaperEngine::Render { using namespace WallpaperEngine::Data::Assets; /** * A normal texture file in WallpaperEngine's format */ -class CTexture final : public ITexture { +class CTexture final : public TextureProvider { public: explicit CTexture (TextureUniquePtr header); diff --git a/src/WallpaperEngine/Render/CTextureCache.h b/src/WallpaperEngine/Render/CTextureCache.h deleted file mode 100644 index 5d8c406..0000000 --- a/src/WallpaperEngine/Render/CTextureCache.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "ITexture.h" -#include "WallpaperEngine/Render/CRenderContext.h" -#include "WallpaperEngine/Render/Helpers/CContextAware.h" - -using namespace WallpaperEngine::Assets; - -namespace WallpaperEngine::Render { -namespace Helpers { -class CContextAware; -} - -class CRenderContext; - -class CTextureCache final : Helpers::CContextAware { - public: - explicit CTextureCache (CRenderContext& context); - - /** - * Checks if the given texture was already loaded and returns it - * If the texture was not loaded yet, it tries to load it from the container - * - * @param filename - * @return - */ - std::shared_ptr resolve (const std::string& filename); - - /** - * Registers a texture in the cache - * - * @param name - * @param texture - */ - void store (const std::string& name, std::shared_ptr texture); - - private: - /** Cached textures */ - std::map> m_textureCache = {}; -}; -} // namespace WallpaperEngine::Render diff --git a/src/WallpaperEngine/Render/CWallpaper.cpp b/src/WallpaperEngine/Render/CWallpaper.cpp index be1059a..fe74109 100644 --- a/src/WallpaperEngine/Render/CWallpaper.cpp +++ b/src/WallpaperEngine/Render/CWallpaper.cpp @@ -1,5 +1,5 @@ #include "CWallpaper.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" #include "WallpaperEngine/Render/Wallpapers/CScene.h" #include "WallpaperEngine/Render/Wallpapers/CVideo.h" #include "WallpaperEngine/Render/Wallpapers/CWeb.h" @@ -13,12 +13,12 @@ using namespace WallpaperEngine::Render; CWallpaper::CWallpaper ( - const Wallpaper& wallpaperData, CRenderContext& context,CAudioContext& audioContext, - const CWallpaperState::TextureUVsScaling& scalingMode, + const Wallpaper& wallpaperData, RenderContext& context,AudioContext& audioContext, + const WallpaperState::TextureUVsScaling& scalingMode, const uint32_t& clampMode ) : - CContextAware (context), - CFBOProvider (nullptr), + ContextAware (context), + FBOProvider (nullptr), m_wallpaperData (wallpaperData), m_audioContext (audioContext), m_state (scalingMode, clampMode) { @@ -255,7 +255,7 @@ void CWallpaper::setupFramebuffers () { this->alias ("_rt_MipMappedFrameBuffer", "_rt_FullFrameBuffer"); } -CAudioContext& CWallpaper::getAudioContext () { +AudioContext& CWallpaper::getAudioContext () { return this->m_audioContext; } @@ -273,8 +273,8 @@ std::shared_ptr CWallpaper::getFBO () const { } std::unique_ptr CWallpaper::fromWallpaper ( - const Wallpaper& wallpaper, CRenderContext& context, CAudioContext& audioContext, - WebBrowser::CWebBrowserContext* browserContext, const CWallpaperState::TextureUVsScaling& scalingMode, + const Wallpaper& wallpaper, RenderContext& context, AudioContext& audioContext, + WebBrowser::WebBrowserContext* browserContext, const WallpaperState::TextureUVsScaling& scalingMode, const uint32_t& clampMode ) { if (wallpaper.is ()) { diff --git a/src/WallpaperEngine/Render/CWallpaper.h b/src/WallpaperEngine/Render/CWallpaper.h index 78b40bd..0dd7270 100644 --- a/src/WallpaperEngine/Render/CWallpaper.h +++ b/src/WallpaperEngine/Render/CWallpaper.h @@ -3,32 +3,32 @@ #include #include -#include "WallpaperEngine/Audio/CAudioContext.h" +#include "WallpaperEngine/Audio/AudioContext.h" #include "WallpaperEngine/Render/CFBO.h" -#include "WallpaperEngine/Render/CRenderContext.h" -#include "WallpaperEngine/Render/Helpers/CContextAware.h" +#include "WallpaperEngine/Render/Helpers/ContextAware.h" +#include "WallpaperEngine/Render/RenderContext.h" #include "WallpaperEngine/Data/Model/Wallpaper.h" -#include "CFBOProvider.h" -#include "CWallpaperState.h" +#include "FBOProvider.h" +#include "WallpaperState.h" namespace WallpaperEngine::WebBrowser { -class CWebBrowserContext; +class WebBrowserContext; } namespace WallpaperEngine::Render { namespace Helpers { -class CContextAware; +class ContextAware; } -using namespace WallpaperEngine::Assets; +using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Audio; using namespace WallpaperEngine::Data::Model; using namespace WallpaperEngine::FileSystem; -class CWallpaper : public Helpers::CContextAware, public CFBOProvider { +class CWallpaper : public Helpers::ContextAware, public FBOProvider { public: template [[nodiscard]] const T* as () const { if (is ()) { @@ -70,7 +70,7 @@ class CWallpaper : public Helpers::CContextAware, public CFBOProvider { /** * @return The current audio context for this wallpaper */ - CAudioContext& getAudioContext (); + AudioContext& getAudioContext (); /** * @return The scene's framebuffer @@ -126,14 +126,14 @@ class CWallpaper : public Helpers::CContextAware, public CFBOProvider { * @return */ static std::unique_ptr fromWallpaper ( - const Wallpaper& wallpaper, CRenderContext& context, CAudioContext& audioContext, - WebBrowser::CWebBrowserContext* browserContext, const CWallpaperState::TextureUVsScaling& scalingMode, + const Wallpaper& wallpaper, RenderContext& context, AudioContext& audioContext, + WebBrowser::WebBrowserContext* browserContext, const WallpaperState::TextureUVsScaling& scalingMode, const uint32_t& clampMode); protected: CWallpaper ( - const Wallpaper& wallpaperData, CRenderContext& context, - CAudioContext& audioContext, const CWallpaperState::TextureUVsScaling& scalingMode, + const Wallpaper& wallpaperData, RenderContext& context, + AudioContext& audioContext, const WallpaperState::TextureUVsScaling& scalingMode, const uint32_t& clampMode); /** @@ -170,8 +170,8 @@ class CWallpaper : public Helpers::CContextAware, public CFBOProvider { /** List of FBOs registered for this wallpaper */ std::map> m_fbos = {}; /** Audio context that is using this wallpaper */ - CAudioContext& m_audioContext; + AudioContext& m_audioContext; /** Current Wallpaper state */ - CWallpaperState m_state; + WallpaperState m_state; }; } // namespace WallpaperEngine::Render diff --git a/src/WallpaperEngine/Render/CCamera.cpp b/src/WallpaperEngine/Render/Camera.cpp similarity index 68% rename from src/WallpaperEngine/Render/CCamera.cpp rename to src/WallpaperEngine/Render/Camera.cpp index afe481f..808adb1 100644 --- a/src/WallpaperEngine/Render/CCamera.cpp +++ b/src/WallpaperEngine/Render/Camera.cpp @@ -1,12 +1,12 @@ #include #include -#include "CCamera.h" +#include "Camera.h" using namespace WallpaperEngine; using namespace WallpaperEngine::Render; -CCamera::CCamera (Wallpapers::CScene& scene, const SceneData::Camera& camera) : +Camera::Camera (Wallpapers::CScene& scene, const SceneData::Camera& camera) : m_width (0), m_height (0), m_camera (camera), @@ -16,45 +16,45 @@ CCamera::CCamera (Wallpapers::CScene& scene, const SceneData::Camera& camera) : this->m_lookat = glm::lookAt (this->getEye (), this->getCenter (), this->getUp ()); } -CCamera::~CCamera () = default; +Camera::~Camera () = default; -const glm::vec3& CCamera::getCenter () const { +const glm::vec3& Camera::getCenter () const { return this->m_camera.configuration.center; } -const glm::vec3& CCamera::getEye () const { +const glm::vec3& Camera::getEye () const { return this->m_camera.configuration.eye; } -const glm::vec3& CCamera::getUp () const { +const glm::vec3& Camera::getUp () const { return this->m_camera.configuration.up; } -const glm::mat4& CCamera::getProjection () const { +const glm::mat4& Camera::getProjection () const { return this->m_projection; } -const glm::mat4& CCamera::getLookAt () const { +const glm::mat4& Camera::getLookAt () const { return this->m_lookat; } -bool CCamera::isOrthogonal () const { +bool Camera::isOrthogonal () const { return this->m_isOrthogonal; } -Wallpapers::CScene& CCamera::getScene () const { +Wallpapers::CScene& Camera::getScene () const { return this->m_scene; } -float CCamera::getWidth () const { +float Camera::getWidth () const { return this->m_width; } -float CCamera::getHeight () const { +float Camera::getHeight () const { return this->m_height; } -void CCamera::setOrthogonalProjection (float width, float height) { +void Camera::setOrthogonalProjection (float width, float height) { this->m_width = width; this->m_height = height; diff --git a/src/WallpaperEngine/Render/CCamera.h b/src/WallpaperEngine/Render/Camera.h similarity index 91% rename from src/WallpaperEngine/Render/CCamera.h rename to src/WallpaperEngine/Render/Camera.h index da290ad..4982d64 100644 --- a/src/WallpaperEngine/Render/CCamera.h +++ b/src/WallpaperEngine/Render/Camera.h @@ -14,10 +14,10 @@ class CScene; namespace WallpaperEngine::Render { using namespace WallpaperEngine::Data::Model; -class CCamera { +class Camera { public: - CCamera (Wallpapers::CScene& scene, const SceneData::Camera& camera); - ~CCamera (); + Camera (Wallpapers::CScene& scene, const SceneData::Camera& camera); + ~Camera (); void setOrthogonalProjection (float width, float height); diff --git a/src/WallpaperEngine/Render/Drivers/CVideoDriver.cpp b/src/WallpaperEngine/Render/Drivers/CVideoDriver.cpp deleted file mode 100644 index c278914..0000000 --- a/src/WallpaperEngine/Render/Drivers/CVideoDriver.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "CVideoDriver.h" - -using namespace WallpaperEngine::Input; -using namespace WallpaperEngine::Render::Drivers; - -CVideoDriver::CVideoDriver (CWallpaperApplication& app, CMouseInput& mouseInput) : - m_app (app), - m_inputContext (mouseInput) {} - -CWallpaperApplication& CVideoDriver::getApp () const { - return this->m_app; -} - -CInputContext& CVideoDriver::getInputContext () { - return this->m_inputContext; -} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.cpp b/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.cpp deleted file mode 100644 index 3ac070f..0000000 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "CFullScreenDetector.h" - -using namespace WallpaperEngine; -using namespace WallpaperEngine::Render::Drivers::Detectors; - -CFullScreenDetector::CFullScreenDetector (Application::CApplicationContext& appContext) : - m_applicationContext (appContext) {} - -Application::CApplicationContext& CFullScreenDetector::getApplicationContext () const { - return this->m_applicationContext; -} - -bool CFullScreenDetector::anythingFullscreen () const { - return false; -} - -void CFullScreenDetector::reset () {} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.cpp b/src/WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.cpp new file mode 100644 index 0000000..706edbc --- /dev/null +++ b/src/WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.cpp @@ -0,0 +1,17 @@ +#include "FullScreenDetector.h" + +using namespace WallpaperEngine; +using namespace WallpaperEngine::Render::Drivers::Detectors; + +FullScreenDetector::FullScreenDetector (Application::ApplicationContext& appContext) : + m_applicationContext (appContext) {} + +Application::ApplicationContext& FullScreenDetector::getApplicationContext () const { + return this->m_applicationContext; +} + +bool FullScreenDetector::anythingFullscreen () const { + return false; +} + +void FullScreenDetector::reset () {} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h b/src/WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.h similarity index 58% rename from src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h rename to src/WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.h index 0a89088..a572656 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h +++ b/src/WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.h @@ -1,12 +1,12 @@ #pragma once -#include "WallpaperEngine/Application/CApplicationContext.h" +#include "WallpaperEngine/Application/ApplicationContext.h" namespace WallpaperEngine::Render::Drivers::Detectors { -class CFullScreenDetector { +class FullScreenDetector { public: - explicit CFullScreenDetector (Application::CApplicationContext& appContext); - virtual ~CFullScreenDetector () = default; + explicit FullScreenDetector (Application::ApplicationContext& appContext); + virtual ~FullScreenDetector () = default; /** * @return If anything is fullscreen @@ -19,9 +19,9 @@ class CFullScreenDetector { /** * @return The application context using this detector */ - [[nodiscard]] Application::CApplicationContext& getApplicationContext () const; + [[nodiscard]] Application::ApplicationContext& getApplicationContext () const; private: - Application::CApplicationContext& m_applicationContext; + Application::ApplicationContext& m_applicationContext; }; } // namespace WallpaperEngine::Render::Drivers::Detectors \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.cpp b/src/WallpaperEngine/Render/Drivers/Detectors/WaylandFullScreenDetector.cpp similarity index 87% rename from src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.cpp rename to src/WallpaperEngine/Render/Drivers/Detectors/WaylandFullScreenDetector.cpp index cd34d89..f6677f9 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.cpp +++ b/src/WallpaperEngine/Render/Drivers/Detectors/WaylandFullScreenDetector.cpp @@ -1,7 +1,7 @@ -#include "CWaylandFullScreenDetector.h" +#include "WaylandFullScreenDetector.h" -#include "WallpaperEngine/Logging/CLog.h" -#include "WallpaperEngine/Render/Drivers/CVideoFactories.h" +#include "WallpaperEngine/Logging/Log.h" +#include "WallpaperEngine/Render/Drivers/VideoFactories.h" #include "wlr-foreign-toplevel-management-unstable-v1-protocol.h" #include @@ -97,7 +97,7 @@ zwlr_foreign_toplevel_manager_v1_listener toplevelManagerListener = { }; // anonymous namespace void handleGlobal (void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version) { - const auto detector = static_cast (data); + const auto detector = static_cast (data); if (strcmp (interface, zwlr_foreign_toplevel_manager_v1_interface.name) == 0) { detector->m_toplevelManager = static_cast ( wl_registry_bind (registry, name, &zwlr_foreign_toplevel_manager_v1_interface, 3)); @@ -117,8 +117,8 @@ constexpr struct wl_registry_listener registryListener = { .global_remove = handleGlobalRemoved, }; -CWaylandFullScreenDetector::CWaylandFullScreenDetector (Application::CApplicationContext& appContext) : - CFullScreenDetector (appContext) { +WaylandFullScreenDetector::WaylandFullScreenDetector (Application::ApplicationContext& appContext) : + FullScreenDetector (appContext) { m_display = wl_display_connect (nullptr); if (!m_display) sLog.exception ("Failed to query wayland display"); @@ -133,12 +133,12 @@ CWaylandFullScreenDetector::CWaylandFullScreenDetector (Application::CApplicatio } } -CWaylandFullScreenDetector::~CWaylandFullScreenDetector () { +WaylandFullScreenDetector::~WaylandFullScreenDetector () { if (m_display) wl_display_disconnect (m_display); } -bool CWaylandFullScreenDetector::anythingFullscreen () const { +bool WaylandFullScreenDetector::anythingFullscreen () const { if (!m_toplevelManager) { return false; } @@ -146,14 +146,14 @@ bool CWaylandFullScreenDetector::anythingFullscreen () const { return m_fullscreenCount > 0; } -void CWaylandFullScreenDetector::reset () {} +void WaylandFullScreenDetector::reset () {} __attribute__((constructor)) void registerWaylandFullscreenDetector () { sVideoFactories.registerFullscreenDetector( "wayland", - [](CApplicationContext& context, CVideoDriver& driver) -> std::unique_ptr { - return std::make_unique (context); + [](ApplicationContext& context, VideoDriver& driver) -> std::unique_ptr { + return std::make_unique (context); } ); } diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h b/src/WallpaperEngine/Render/Drivers/Detectors/WaylandFullScreenDetector.h similarity index 74% rename from src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h rename to src/WallpaperEngine/Render/Drivers/Detectors/WaylandFullScreenDetector.h index e081f9e..caeff03 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h +++ b/src/WallpaperEngine/Render/Drivers/Detectors/WaylandFullScreenDetector.h @@ -4,17 +4,17 @@ #include -#include "CFullScreenDetector.h" +#include "FullScreenDetector.h" struct wl_display; struct wl_registry; struct zwlr_foreign_toplevel_manager_v1; namespace WallpaperEngine::Render::Drivers::Detectors { -class CWaylandFullScreenDetector final : public CFullScreenDetector { +class WaylandFullScreenDetector final : public FullScreenDetector { public: - explicit CWaylandFullScreenDetector (Application::CApplicationContext& appContext); - ~CWaylandFullScreenDetector () override; + explicit WaylandFullScreenDetector (Application::ApplicationContext& appContext); + ~WaylandFullScreenDetector () override; [[nodiscard]] bool anythingFullscreen () const override; void reset () override; diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp b/src/WallpaperEngine/Render/Drivers/Detectors/X11FullScreenDetector.cpp similarity index 82% rename from src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp rename to src/WallpaperEngine/Render/Drivers/Detectors/X11FullScreenDetector.cpp index 8947a69..9c55ebe 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp +++ b/src/WallpaperEngine/Render/Drivers/Detectors/X11FullScreenDetector.cpp @@ -1,15 +1,15 @@ -#include "CX11FullScreenDetector.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" +#include "X11FullScreenDetector.h" #include #include -#include "WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h" -#include "WallpaperEngine/Render/Drivers/CVideoFactories.h" +#include "WallpaperEngine/Render/Drivers/VideoFactories.h" +#include "WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.h" namespace WallpaperEngine::Render::Drivers::Detectors { void CustomXIOErrorExitHandler (Display* dsp, void* userdata) { - const auto context = static_cast (userdata); + const auto context = static_cast (userdata); sLog.debugerror ("Critical XServer error detected. Attempting to recover..."); @@ -29,17 +29,17 @@ int CustomXIOErrorHandler (Display* dsp) { return 0; } -CX11FullScreenDetector::CX11FullScreenDetector ( - Application::CApplicationContext& appContext, CVideoDriver& driver +X11FullScreenDetector::X11FullScreenDetector ( + Application::ApplicationContext& appContext, VideoDriver& driver ) : - CFullScreenDetector (appContext), + FullScreenDetector (appContext), m_display (nullptr), m_root (0), m_driver (driver) { try { // attempt casting to CGLFWOpenGLDriver, this will throw if it's not possible // so we can gracely handle the error - dynamic_cast (this->m_driver); + dynamic_cast (this->m_driver); } catch (std::exception&) { sLog.exception ("X11 FullScreen Detector initialized with the wrong video driver... This is a bug..."); } @@ -54,11 +54,11 @@ CX11FullScreenDetector::CX11FullScreenDetector ( this->initialize (); } -CX11FullScreenDetector::~CX11FullScreenDetector () { +X11FullScreenDetector::~X11FullScreenDetector () { this->stop (); } -bool CX11FullScreenDetector::anythingFullscreen () const { +bool X11FullScreenDetector::anythingFullscreen () const { // stop rendering if anything is fullscreen bool isFullscreen = false; XWindowAttributes attribs; @@ -69,7 +69,7 @@ bool CX11FullScreenDetector::anythingFullscreen () const { if (!XQueryTree (this->m_display, this->m_root, &_, &_, &children, &nchildren)) return false; - const auto ourWindow = reinterpret_cast (dynamic_cast (this->m_driver).getWindow ()); + const auto ourWindow = reinterpret_cast (dynamic_cast (this->m_driver).getWindow ()); Window parentWindow; { @@ -109,12 +109,12 @@ bool CX11FullScreenDetector::anythingFullscreen () const { return isFullscreen; } -void CX11FullScreenDetector::reset () { +void X11FullScreenDetector::reset () { this->stop (); this->initialize (); } -void CX11FullScreenDetector::initialize () { +void X11FullScreenDetector::initialize () { this->m_display = XOpenDisplay (nullptr); // set the error handling to try and recover from X disconnections @@ -159,7 +159,7 @@ void CX11FullScreenDetector::initialize () { XRRFreeScreenResources (screenResources); } -void CX11FullScreenDetector::stop () { +void X11FullScreenDetector::stop () { if (this->m_display == nullptr) return; @@ -170,8 +170,8 @@ void CX11FullScreenDetector::stop () { __attribute__((constructor)) void registerX11FullscreenDetector () { sVideoFactories.registerFullscreenDetector( "x11", - [](CApplicationContext& context, CVideoDriver& driver) -> std::unique_ptr { - return std::make_unique (context, driver); + [](ApplicationContext& context, VideoDriver& driver) -> std::unique_ptr { + return std::make_unique (context, driver); } ); } diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h b/src/WallpaperEngine/Render/Drivers/Detectors/X11FullScreenDetector.h similarity index 59% rename from src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h rename to src/WallpaperEngine/Render/Drivers/Detectors/X11FullScreenDetector.h index 85bceb4..2f5316b 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h +++ b/src/WallpaperEngine/Render/Drivers/Detectors/X11FullScreenDetector.h @@ -4,18 +4,18 @@ #include #include -#include "CFullScreenDetector.h" -#include "WallpaperEngine/Render/Drivers/CVideoDriver.h" +#include "FullScreenDetector.h" +#include "WallpaperEngine/Render/Drivers/VideoDriver.h" #include namespace WallpaperEngine::Render::Drivers { -class CGLFWOpenGLDriver; +class GLFWOpenGLDriver; namespace Detectors { -class CX11FullScreenDetector final : public CFullScreenDetector { +class X11FullScreenDetector final : public FullScreenDetector { public: - CX11FullScreenDetector (Application::CApplicationContext& appContext, CVideoDriver& driver); - ~CX11FullScreenDetector () override; + X11FullScreenDetector (Application::ApplicationContext& appContext, VideoDriver& driver); + ~X11FullScreenDetector () override; [[nodiscard]] bool anythingFullscreen () const override; void reset () override; @@ -27,7 +27,7 @@ class CX11FullScreenDetector final : public CFullScreenDetector { Display* m_display = nullptr; Window m_root; std::map m_screens = {}; - CVideoDriver& m_driver; + VideoDriver& m_driver; }; } // namespace Detectors } // namespace WallpaperEngine::Render::Drivers \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp b/src/WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.cpp similarity index 70% rename from src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp rename to src/WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.cpp index 42adeb6..a94903d 100644 --- a/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp +++ b/src/WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.cpp @@ -1,9 +1,9 @@ -#include "CGLFWOpenGLDriver.h" -#include "CVideoFactories.h" -#include "WallpaperEngine/Logging/CLog.h" -#include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h" +#include "GLFWOpenGLDriver.h" +#include "VideoFactories.h" +#include "WallpaperEngine/Logging/Log.h" +#include "WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.h" #ifdef ENABLE_X11 -#include "WallpaperEngine/Render/Drivers/Output/CX11Output.h" +#include "WallpaperEngine/Render/Drivers/Output/X11Output.h" #endif #define GLFW_EXPOSE_NATIVE_X11 @@ -17,10 +17,10 @@ void CustomGLFWErrorHandler (int errorCode, const char* reason) { sLog.error ("GLFW error ", errorCode, ": ", reason); } -CGLFWOpenGLDriver::CGLFWOpenGLDriver ( - const char* windowTitle, CApplicationContext& context, CWallpaperApplication& app +GLFWOpenGLDriver::GLFWOpenGLDriver ( + const char* windowTitle, ApplicationContext& context, WallpaperApplication& app ) : - CVideoDriver (app, m_mouseInput), + VideoDriver (app, m_mouseInput), m_context (context), m_mouseInput (*this) { glfwSetErrorCallback (CustomGLFWErrorHandler); @@ -40,7 +40,7 @@ CGLFWOpenGLDriver::CGLFWOpenGLDriver ( glfwWindowHintString (GLFW_X11_INSTANCE_NAME, "linux-wallpaperengine"); // for forced window mode, we can set some hints that'll help position the window - if (context.settings.render.mode == Application::CApplicationContext::EXPLICIT_WINDOW) { + if (context.settings.render.mode == Application::ApplicationContext::EXPLICIT_WINDOW) { glfwWindowHint (GLFW_RESIZABLE, GLFW_FALSE); glfwWindowHint (GLFW_DECORATED, GLFW_FALSE); glfwWindowHint (GLFW_FLOATING, GLFW_TRUE); @@ -66,13 +66,13 @@ CGLFWOpenGLDriver::CGLFWOpenGLDriver ( sLog.error ("Failed to initialize GLEW: ", glewGetErrorString (result)); // setup output - if (context.settings.render.mode == CApplicationContext::EXPLICIT_WINDOW || - context.settings.render.mode == CApplicationContext::NORMAL_WINDOW) { - m_output = new WallpaperEngine::Render::Drivers::Output::CGLFWWindowOutput (context, *this); + if (context.settings.render.mode == ApplicationContext::EXPLICIT_WINDOW || + context.settings.render.mode == ApplicationContext::NORMAL_WINDOW) { + m_output = new WallpaperEngine::Render::Drivers::Output::GLFWWindowOutput (context, *this); } #ifdef ENABLE_X11 else { - m_output = new WallpaperEngine::Render::Drivers::Output::CX11Output (context, *this); + m_output = new WallpaperEngine::Render::Drivers::Output::X11Output (context, *this); } #else else { @@ -81,40 +81,40 @@ CGLFWOpenGLDriver::CGLFWOpenGLDriver ( #endif } -CGLFWOpenGLDriver::~CGLFWOpenGLDriver () { +GLFWOpenGLDriver::~GLFWOpenGLDriver () { glfwTerminate (); } -Output::COutput& CGLFWOpenGLDriver::getOutput () { +Output::Output& GLFWOpenGLDriver::getOutput () { return *this->m_output; } -float CGLFWOpenGLDriver::getRenderTime () const { +float GLFWOpenGLDriver::getRenderTime () const { return static_cast (glfwGetTime ()); } -bool CGLFWOpenGLDriver::closeRequested () { +bool GLFWOpenGLDriver::closeRequested () { return glfwWindowShouldClose (this->m_window); } -void CGLFWOpenGLDriver::resizeWindow (glm::ivec2 size) { +void GLFWOpenGLDriver::resizeWindow (glm::ivec2 size) { glfwSetWindowSize (this->m_window, size.x, size.y); } -void CGLFWOpenGLDriver::resizeWindow (glm::ivec4 sizeandpos) { +void GLFWOpenGLDriver::resizeWindow (glm::ivec4 sizeandpos) { glfwSetWindowPos (this->m_window, sizeandpos.x, sizeandpos.y); glfwSetWindowSize (this->m_window, sizeandpos.z, sizeandpos.w); } -void CGLFWOpenGLDriver::showWindow () { +void GLFWOpenGLDriver::showWindow () { glfwShowWindow (this->m_window); } -void CGLFWOpenGLDriver::hideWindow () { +void GLFWOpenGLDriver::hideWindow () { glfwHideWindow (this->m_window); } -glm::ivec2 CGLFWOpenGLDriver::getFramebufferSize () const { +glm::ivec2 GLFWOpenGLDriver::getFramebufferSize () const { glm::ivec2 size; glfwGetFramebufferSize (this->m_window, &size.x, &size.y); @@ -122,11 +122,11 @@ glm::ivec2 CGLFWOpenGLDriver::getFramebufferSize () const { return size; } -uint32_t CGLFWOpenGLDriver::getFrameCounter () const { +uint32_t GLFWOpenGLDriver::getFrameCounter () const { return this->m_frameCounter; } -void CGLFWOpenGLDriver::dispatchEventQueue () { +void GLFWOpenGLDriver::dispatchEventQueue () { static float startTime, endTime, minimumTime = 1.0f / this->m_context.settings.render.maximumFPS; // get the start time of the frame startTime = this->getRenderTime (); @@ -172,35 +172,35 @@ void CGLFWOpenGLDriver::dispatchEventQueue () { usleep ((minimumTime - (endTime - startTime)) * CLOCKS_PER_SEC); } -void* CGLFWOpenGLDriver::getProcAddress (const char* name) const { +void* GLFWOpenGLDriver::getProcAddress (const char* name) const { return reinterpret_cast (glfwGetProcAddress (name)); } -GLFWwindow* CGLFWOpenGLDriver::getWindow () const { +GLFWwindow* GLFWOpenGLDriver::getWindow () const { return this->m_window; } __attribute__((constructor)) void registerGLFWOpenGLDriver () { sVideoFactories.registerDriver ( - CApplicationContext::DESKTOP_BACKGROUND, + ApplicationContext::DESKTOP_BACKGROUND, "x11", - [](CApplicationContext& context, CWallpaperApplication& application) -> std::unique_ptr { - return std::make_unique ("wallpaperengine", context, application); + [](ApplicationContext& context, WallpaperApplication& application) -> std::unique_ptr { + return std::make_unique ("wallpaperengine", context, application); } ); sVideoFactories.registerDriver ( - CApplicationContext::EXPLICIT_WINDOW, + ApplicationContext::EXPLICIT_WINDOW, DEFAULT_WINDOW_NAME, - [](CApplicationContext& context, CWallpaperApplication& application) -> std::unique_ptr { - return std::make_unique ("wallpaperengine", context, application); + [](ApplicationContext& context, WallpaperApplication& application) -> std::unique_ptr { + return std::make_unique ("wallpaperengine", context, application); } ); sVideoFactories.registerDriver ( - CApplicationContext::NORMAL_WINDOW, + ApplicationContext::NORMAL_WINDOW, DEFAULT_WINDOW_NAME, - [](CApplicationContext& context, CWallpaperApplication& application) -> std::unique_ptr { - return std::make_unique ("wallpaperengine", context, application); + [](ApplicationContext& context, WallpaperApplication& application) -> std::unique_ptr { + return std::make_unique ("wallpaperengine", context, application); } ); } \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h b/src/WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.h similarity index 54% rename from src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h rename to src/WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.h index b332d1b..007945c 100644 --- a/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h +++ b/src/WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.h @@ -1,27 +1,27 @@ #pragma once -#include "WallpaperEngine/Application/CApplicationContext.h" -#include "WallpaperEngine/Application/CWallpaperApplication.h" -#include "WallpaperEngine/Input/Drivers/CGLFWMouseInput.h" -#include "WallpaperEngine/Render/Drivers/CVideoDriver.h" -#include "WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h" +#include "WallpaperEngine/Application/ApplicationContext.h" +#include "WallpaperEngine/Application/WallpaperApplication.h" +#include "WallpaperEngine/Input/Drivers/GLFWMouseInput.h" +#include "WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.h" +#include "WallpaperEngine/Render/Drivers/VideoDriver.h" #include #include namespace WallpaperEngine::Application { -class CApplicationContext; -class CWallpaperApplication; +class ApplicationContext; +class WallpaperApplication; } // namespace WallpaperEngine::Application namespace WallpaperEngine::Render::Drivers { using namespace WallpaperEngine::Application; -class CGLFWOpenGLDriver final : public CVideoDriver { +class GLFWOpenGLDriver final : public VideoDriver { public: - explicit CGLFWOpenGLDriver (const char* windowTitle, CApplicationContext& context, CWallpaperApplication& app); - ~CGLFWOpenGLDriver () override; + explicit GLFWOpenGLDriver (const char* windowTitle, ApplicationContext& context, WallpaperApplication& app); + ~GLFWOpenGLDriver () override; - [[nodiscard]] Output::COutput& getOutput () override; + [[nodiscard]] Output::Output& getOutput () override; [[nodiscard]] float getRenderTime () const override; bool closeRequested () override; void resizeWindow (glm::ivec2 size) override; @@ -36,9 +36,9 @@ class CGLFWOpenGLDriver final : public CVideoDriver { GLFWwindow* getWindow () const; private: - CApplicationContext& m_context; - Input::Drivers::CGLFWMouseInput m_mouseInput; - Output::COutput* m_output = nullptr; + ApplicationContext& m_context; + Input::Drivers::GLFWMouseInput m_mouseInput; + Output::Output* m_output = nullptr; GLFWwindow* m_window = nullptr; uint32_t m_frameCounter = 0; }; diff --git a/src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.cpp b/src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.cpp deleted file mode 100644 index 4d0ae3b..0000000 --- a/src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "CGLFWOutputViewport.h" - -#include - -using namespace WallpaperEngine::Render::Drivers::Output; - -CGLFWOutputViewport::CGLFWOutputViewport (glm::ivec4 viewport, std::string name) : - COutputViewport (viewport, std::move (name)) {} - -void CGLFWOutputViewport::makeCurrent () {} - -void CGLFWOutputViewport::swapOutput () {} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Output/COutput.cpp b/src/WallpaperEngine/Render/Drivers/Output/COutput.cpp deleted file mode 100644 index 8948c0f..0000000 --- a/src/WallpaperEngine/Render/Drivers/Output/COutput.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "COutput.h" - -using namespace WallpaperEngine::Render::Drivers::Output; - -COutput::COutput (CApplicationContext& context, CVideoDriver& driver) : - m_context (context), - m_driver (driver) {} - -const std::map& COutput::getViewports () const { - return this->m_viewports; -} - -int COutput::getFullWidth () const { - return this->m_fullWidth; -} - -int COutput::getFullHeight () const { - return this->m_fullHeight; -} diff --git a/src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.cpp b/src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.cpp deleted file mode 100644 index 49942fd..0000000 --- a/src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "CWaylandOutput.h" -#include "../CWaylandOpenGLDriver.h" -#include "WallpaperEngine/Application/CWallpaperApplication.h" - -using namespace WallpaperEngine::Render::Drivers::Output; - -CWaylandOutput::CWaylandOutput (CApplicationContext& context, CWaylandOpenGLDriver& driver) : - COutput (context, driver) { - updateViewports (); -} - -void CWaylandOutput::updateViewports () { - m_viewports.clear (); - const auto PDRIVER = dynamic_cast (&m_driver); - glm::ivec2 fullw = {0, 0}; - for (const auto& o : PDRIVER->m_screens) { - if (!o->layerSurface) - continue; - - m_viewports [o->name] = o; - - fullw = fullw + glm::ivec2 {o->size.x * o->scale, 0}; - if (o->size.y > fullw.y) - fullw.y = o->size.y; - } - - m_fullWidth = fullw.x; - m_fullHeight = fullw.y; -} - -void CWaylandOutput::reset () { - updateViewports (); -} - -bool CWaylandOutput::renderVFlip () const { - return true; -} - -bool CWaylandOutput::renderMultiple () const { - return false; // todo -} - -bool CWaylandOutput::haveImageBuffer () const { - return false; -} - -void* CWaylandOutput::getImageBuffer () const { - return nullptr; -} - -uint32_t CWaylandOutput::getImageBufferSize () const { - return 0; -} - -void CWaylandOutput::updateRender () const {} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Output/GLFWOutputViewport.cpp b/src/WallpaperEngine/Render/Drivers/Output/GLFWOutputViewport.cpp new file mode 100644 index 0000000..a836070 --- /dev/null +++ b/src/WallpaperEngine/Render/Drivers/Output/GLFWOutputViewport.cpp @@ -0,0 +1,12 @@ +#include "GLFWOutputViewport.h" + +#include + +using namespace WallpaperEngine::Render::Drivers::Output; + +GLFWOutputViewport::GLFWOutputViewport (glm::ivec4 viewport, std::string name) : + OutputViewport (viewport, std::move (name)) {} + +void GLFWOutputViewport::makeCurrent () {} + +void GLFWOutputViewport::swapOutput () {} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.h b/src/WallpaperEngine/Render/Drivers/Output/GLFWOutputViewport.h similarity index 57% rename from src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.h rename to src/WallpaperEngine/Render/Drivers/Output/GLFWOutputViewport.h index 0eb60ac..2f46581 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.h +++ b/src/WallpaperEngine/Render/Drivers/Output/GLFWOutputViewport.h @@ -1,11 +1,11 @@ #pragma once -#include "COutputViewport.h" +#include "OutputViewport.h" namespace WallpaperEngine::Render::Drivers::Output { -class CGLFWOutputViewport final : public COutputViewport { +class GLFWOutputViewport final : public OutputViewport { public: - CGLFWOutputViewport (glm::ivec4 viewport, std::string name); + GLFWOutputViewport (glm::ivec4 viewport, std::string name); void makeCurrent () override; void swapOutput () override; diff --git a/src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.cpp b/src/WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.cpp similarity index 52% rename from src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.cpp rename to src/WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.cpp index f4b116d..5e18dcb 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.cpp +++ b/src/WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.cpp @@ -1,6 +1,6 @@ -#include "CGLFWWindowOutput.h" -#include "CGLFWOutputViewport.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "GLFWOutputViewport.h" +#include "GLFWWindowOutput.h" +#include "WallpaperEngine/Logging/Log.h" #include #include @@ -8,15 +8,15 @@ using namespace WallpaperEngine::Render::Drivers::Output; -CGLFWWindowOutput::CGLFWWindowOutput (CApplicationContext& context, CVideoDriver& driver) : COutput (context, driver) { - if (this->m_context.settings.render.mode != Application::CApplicationContext::NORMAL_WINDOW && - this->m_context.settings.render.mode != Application::CApplicationContext::EXPLICIT_WINDOW) +GLFWWindowOutput::GLFWWindowOutput (ApplicationContext& context, VideoDriver& driver) : Output (context, driver) { + if (this->m_context.settings.render.mode != Application::ApplicationContext::NORMAL_WINDOW && + this->m_context.settings.render.mode != Application::ApplicationContext::EXPLICIT_WINDOW) sLog.exception ("Initializing window output when not in output mode, how did you get here?!"); // window should be visible driver.showWindow (); - if (this->m_context.settings.render.mode == Application::CApplicationContext::EXPLICIT_WINDOW) { + if (this->m_context.settings.render.mode == Application::ApplicationContext::EXPLICIT_WINDOW) { this->m_fullWidth = this->m_context.settings.render.window.geometry.z; this->m_fullHeight = this->m_context.settings.render.window.geometry.w; this->repositionWindow (); @@ -27,41 +27,41 @@ CGLFWWindowOutput::CGLFWWindowOutput (CApplicationContext& context, CVideoDriver } // register the default viewport - this->m_viewports ["default"] = new CGLFWOutputViewport {{0, 0, this->m_fullWidth, this->m_fullHeight}, "default"}; + this->m_viewports ["default"] = new GLFWOutputViewport {{0, 0, this->m_fullWidth, this->m_fullHeight}, "default"}; } -void CGLFWWindowOutput::repositionWindow () { +void GLFWWindowOutput::repositionWindow () { // reposition the window this->m_driver.resizeWindow (this->m_context.settings.render.window.geometry); } -void CGLFWWindowOutput::reset () { - if (this->m_context.settings.render.mode == Application::CApplicationContext::EXPLICIT_WINDOW) +void GLFWWindowOutput::reset () { + if (this->m_context.settings.render.mode == Application::ApplicationContext::EXPLICIT_WINDOW) this->repositionWindow (); } -bool CGLFWWindowOutput::renderVFlip () const { +bool GLFWWindowOutput::renderVFlip () const { return true; } -bool CGLFWWindowOutput::renderMultiple () const { +bool GLFWWindowOutput::renderMultiple () const { return false; } -bool CGLFWWindowOutput::haveImageBuffer () const { +bool GLFWWindowOutput::haveImageBuffer () const { return false; } -void* CGLFWWindowOutput::getImageBuffer () const { +void* GLFWWindowOutput::getImageBuffer () const { return nullptr; } -uint32_t CGLFWWindowOutput::getImageBufferSize () const { +uint32_t GLFWWindowOutput::getImageBufferSize () const { return 0; } -void CGLFWWindowOutput::updateRender () const { - if (this->m_context.settings.render.mode != Application::CApplicationContext::NORMAL_WINDOW) +void GLFWWindowOutput::updateRender () const { + if (this->m_context.settings.render.mode != Application::ApplicationContext::NORMAL_WINDOW) return; // take the size from the driver (default window size) diff --git a/src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h b/src/WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.h similarity index 69% rename from src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h rename to src/WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.h index b8817f5..e3eeae9 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h +++ b/src/WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.h @@ -1,12 +1,12 @@ #pragma once -#include "COutput.h" -#include "WallpaperEngine/Render/Drivers/CVideoDriver.h" +#include "Output.h" +#include "WallpaperEngine/Render/Drivers/VideoDriver.h" namespace WallpaperEngine::Render::Drivers::Output { -class CGLFWWindowOutput final : public COutput { +class GLFWWindowOutput final : public Output { public: - CGLFWWindowOutput (CApplicationContext& context, CVideoDriver& driver); + GLFWWindowOutput (ApplicationContext& context, VideoDriver& driver); void reset () override; bool renderVFlip () const override; diff --git a/src/WallpaperEngine/Render/Drivers/Output/Output.cpp b/src/WallpaperEngine/Render/Drivers/Output/Output.cpp new file mode 100644 index 0000000..2fe27bc --- /dev/null +++ b/src/WallpaperEngine/Render/Drivers/Output/Output.cpp @@ -0,0 +1,19 @@ +#include "Output.h" + +using namespace WallpaperEngine::Render::Drivers::Output; + +Output::Output (ApplicationContext& context, VideoDriver& driver) : + m_context (context), + m_driver (driver) {} + +const std::map& Output::getViewports () const { + return this->m_viewports; +} + +int Output::getFullWidth () const { + return this->m_fullWidth; +} + +int Output::getFullHeight () const { + return this->m_fullHeight; +} diff --git a/src/WallpaperEngine/Render/Drivers/Output/COutput.h b/src/WallpaperEngine/Render/Drivers/Output/Output.h similarity index 58% rename from src/WallpaperEngine/Render/Drivers/Output/COutput.h rename to src/WallpaperEngine/Render/Drivers/Output/Output.h index 26e64e9..fe69765 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/COutput.h +++ b/src/WallpaperEngine/Render/Drivers/Output/Output.h @@ -4,29 +4,29 @@ #include #include -#include "WallpaperEngine/Application/CApplicationContext.h" -#include "WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h" +#include "WallpaperEngine/Application/ApplicationContext.h" +#include "WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.h" using namespace WallpaperEngine::Application; namespace WallpaperEngine::Application { -class CApplicationContext; +class ApplicationContext; } namespace WallpaperEngine::Render::Drivers { -class CVideoDriver; +class VideoDriver; namespace Detectors { -class CFullScreenDetector; +class FullScreenDetector; } namespace Output { -class COutputViewport; +class OutputViewport; -class COutput { +class Output { public: - COutput (CApplicationContext& context, CVideoDriver& driver); - virtual ~COutput () = default; + Output (ApplicationContext& context, VideoDriver& driver); + virtual ~Output () = default; virtual void reset () = 0; @@ -36,7 +36,7 @@ class COutput { virtual bool renderVFlip () const = 0; virtual bool renderMultiple () const = 0; virtual bool haveImageBuffer () const = 0; - const std::map& getViewports () const; + const std::map& getViewports () const; virtual void* getImageBuffer () const = 0; virtual uint32_t getImageBufferSize () const = 0; virtual void updateRender () const = 0; @@ -44,9 +44,9 @@ class COutput { protected: mutable int m_fullWidth = 0; mutable int m_fullHeight = 0; - mutable std::map m_viewports = {}; - CApplicationContext& m_context; - CVideoDriver& m_driver; + mutable std::map m_viewports = {}; + ApplicationContext& m_context; + VideoDriver& m_driver; }; } // namespace Output } // namespace WallpaperEngine::Render::Drivers \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Output/COutputViewport.cpp b/src/WallpaperEngine/Render/Drivers/Output/OutputViewport.cpp similarity index 57% rename from src/WallpaperEngine/Render/Drivers/Output/COutputViewport.cpp rename to src/WallpaperEngine/Render/Drivers/Output/OutputViewport.cpp index 5040118..ba7e342 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/COutputViewport.cpp +++ b/src/WallpaperEngine/Render/Drivers/Output/OutputViewport.cpp @@ -1,10 +1,10 @@ -#include "COutputViewport.h" +#include "OutputViewport.h" #include using namespace WallpaperEngine::Render::Drivers::Output; -COutputViewport::COutputViewport (glm::ivec4 viewport, std::string name, bool single) : +OutputViewport::OutputViewport (glm::ivec4 viewport, std::string name, bool single) : viewport (viewport), name (std::move (name)), single (single) {} diff --git a/src/WallpaperEngine/Render/Drivers/Output/COutputViewport.h b/src/WallpaperEngine/Render/Drivers/Output/OutputViewport.h similarity index 78% rename from src/WallpaperEngine/Render/Drivers/Output/COutputViewport.h rename to src/WallpaperEngine/Render/Drivers/Output/OutputViewport.h index ec11d34..74232ac 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/COutputViewport.h +++ b/src/WallpaperEngine/Render/Drivers/Output/OutputViewport.h @@ -4,10 +4,10 @@ #include namespace WallpaperEngine::Render::Drivers::Output { -class COutputViewport { +class OutputViewport { public: - COutputViewport (glm::ivec4 viewport, std::string name, bool single = false); - virtual ~COutputViewport () = default; + OutputViewport (glm::ivec4 viewport, std::string name, bool single = false); + virtual ~OutputViewport () = default; glm::ivec4 viewport; std::string name; diff --git a/src/WallpaperEngine/Render/Drivers/Output/WaylandOutput.cpp b/src/WallpaperEngine/Render/Drivers/Output/WaylandOutput.cpp new file mode 100644 index 0000000..4488e06 --- /dev/null +++ b/src/WallpaperEngine/Render/Drivers/Output/WaylandOutput.cpp @@ -0,0 +1,55 @@ +#include "WaylandOutput.h" +#include "../WaylandOpenGLDriver.h" +#include "WallpaperEngine/Application/WallpaperApplication.h" + +using namespace WallpaperEngine::Render::Drivers::Output; + +WaylandOutput::WaylandOutput (ApplicationContext& context, WaylandOpenGLDriver& driver) : + Output (context, driver) { + updateViewports (); +} + +void WaylandOutput::updateViewports () { + m_viewports.clear (); + const auto PDRIVER = dynamic_cast (&m_driver); + glm::ivec2 fullw = {0, 0}; + for (const auto& o : PDRIVER->m_screens) { + if (!o->layerSurface) + continue; + + m_viewports [o->name] = o; + + fullw = fullw + glm::ivec2 {o->size.x * o->scale, 0}; + if (o->size.y > fullw.y) + fullw.y = o->size.y; + } + + m_fullWidth = fullw.x; + m_fullHeight = fullw.y; +} + +void WaylandOutput::reset () { + updateViewports (); +} + +bool WaylandOutput::renderVFlip () const { + return true; +} + +bool WaylandOutput::renderMultiple () const { + return false; // todo +} + +bool WaylandOutput::haveImageBuffer () const { + return false; +} + +void* WaylandOutput::getImageBuffer () const { + return nullptr; +} + +uint32_t WaylandOutput::getImageBufferSize () const { + return 0; +} + +void WaylandOutput::updateRender () const {} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h b/src/WallpaperEngine/Render/Drivers/Output/WaylandOutput.h similarity index 68% rename from src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h rename to src/WallpaperEngine/Render/Drivers/Output/WaylandOutput.h index fc6f44f..52ca6ba 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h +++ b/src/WallpaperEngine/Render/Drivers/Output/WaylandOutput.h @@ -6,17 +6,17 @@ #include #include -#include "COutput.h" -#include "WallpaperEngine/Render/Drivers/CVideoDriver.h" +#include "Output.h" +#include "WallpaperEngine/Render/Drivers/VideoDriver.h" namespace WallpaperEngine::Render::Drivers { -class CWaylandOpenGLDriver; +class WaylandOpenGLDriver; namespace Output { -class CWaylandOutput final : public COutput { +class WaylandOutput final : public Output { public: - CWaylandOutput (CApplicationContext& context, CWaylandOpenGLDriver& driver); - ~CWaylandOutput () override = default; + WaylandOutput (ApplicationContext& context, WaylandOpenGLDriver& driver); + ~WaylandOutput () override = default; void reset () override; diff --git a/src/WallpaperEngine/Render/Drivers/Output/CWaylandOutputViewport.cpp b/src/WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.cpp similarity index 87% rename from src/WallpaperEngine/Render/Drivers/Output/CWaylandOutputViewport.cpp rename to src/WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.cpp index 398cade..45a513f 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CWaylandOutputViewport.cpp +++ b/src/WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.cpp @@ -1,5 +1,5 @@ -#include "CWaylandOutputViewport.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" +#include "WaylandOutputViewport.h" #define class _class #define namespace _namespace @@ -17,7 +17,7 @@ using namespace WallpaperEngine::Render::Drivers; using namespace WallpaperEngine::Render::Drivers::Output; static void handleLSConfigure (void* data, zwlr_layer_surface_v1* surface, uint32_t serial, uint32_t w, uint32_t h) { - const auto viewport = static_cast (data); + const auto viewport = static_cast (data); viewport->size = {w, h}; viewport->viewport = {0, 0, viewport->size.x * viewport->scale, viewport->size.y * viewport->scale}; viewport->resize (); @@ -26,7 +26,7 @@ static void handleLSConfigure (void* data, zwlr_layer_surface_v1* surface, uint3 } static void handleLSClosed (void* data, zwlr_layer_surface_v1* surface) { - const auto viewport = static_cast (data); + const auto viewport = static_cast (data); viewport->getDriver ()->onLayerClose (viewport); } @@ -37,7 +37,7 @@ static void geometry (void* data, wl_output* output, int32_t x, int32_t y, int32 } static void mode (void* data, wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refresh) { - const auto viewport = static_cast (data); + const auto viewport = static_cast (data); // update viewport size too viewport->size = {width, height}; @@ -51,11 +51,11 @@ static void mode (void* data, wl_output* output, uint32_t flags, int32_t width, } static void done (void* data, wl_output* wl_output) { - static_cast (data)->initialized = true; + static_cast (data)->initialized = true; } static void scale (void* data, wl_output* wl_output, int32_t scale) { - const auto viewport = static_cast (data); + const auto viewport = static_cast (data); viewport->scale = scale; @@ -67,7 +67,7 @@ static void scale (void* data, wl_output* wl_output, int32_t scale) { } static void name (void* data, wl_output* wl_output, const char* name) { - const auto viewport = static_cast (data); + const auto viewport = static_cast (data); if (name) viewport->name = name; @@ -81,7 +81,7 @@ static void description (void* data, wl_output* wl_output, const char* descripti } static void surfaceFrameCallback (void* data, struct wl_callback* cb, uint32_t time) { - const auto viewport = static_cast (data); + const auto viewport = static_cast (data); wl_callback_destroy (cb); @@ -101,9 +101,9 @@ constexpr struct zwlr_layer_surface_v1_listener layerSurfaceListener = { .closed = handleLSClosed, }; -CWaylandOutputViewport::CWaylandOutputViewport (CWaylandOpenGLDriver* driver, uint32_t waylandName, +WaylandOutputViewport::WaylandOutputViewport (WaylandOpenGLDriver* driver, uint32_t waylandName, struct wl_registry* registry) : - COutputViewport ({0, 0, 0, 0}, "", true), + OutputViewport ({0, 0, 0, 0}, "", true), size ({0, 0}), waylandName (waylandName), m_driver (driver) { @@ -112,7 +112,7 @@ CWaylandOutputViewport::CWaylandOutputViewport (CWaylandOpenGLDriver* driver, ui wl_output_add_listener (output, &outputListener, this); } -void CWaylandOutputViewport::setupLS () { +void WaylandOutputViewport::setupLS () { surface = wl_compositor_create_surface (m_driver->getWaylandContext ()->compositor); layerSurface = zwlr_layer_shell_v1_get_layer_surface (m_driver->getWaylandContext ()->layerShell, surface, output, @@ -162,11 +162,11 @@ void CWaylandOutputViewport::setupLS () { this->m_driver->getOutput ().reset (); } -CWaylandOpenGLDriver* CWaylandOutputViewport::getDriver () { +WaylandOpenGLDriver* WaylandOutputViewport::getDriver () { return this->m_driver; } -void CWaylandOutputViewport::makeCurrent () { +void WaylandOutputViewport::makeCurrent () { const EGLBoolean result = eglMakeCurrent (m_driver->getEGLContext ()->display, eglSurface, eglSurface, m_driver->getEGLContext ()->context); @@ -174,7 +174,7 @@ void CWaylandOutputViewport::makeCurrent () { sLog.error ("Couldn't make egl current"); } -void CWaylandOutputViewport::swapOutput () { +void WaylandOutputViewport::swapOutput () { this->callbackInitialized = true; this->makeCurrent (); @@ -186,7 +186,7 @@ void CWaylandOutputViewport::swapOutput () { wl_surface_commit (surface); } -void CWaylandOutputViewport::resize () { +void WaylandOutputViewport::resize () { if (!this->eglWindow) return; diff --git a/src/WallpaperEngine/Render/Drivers/Output/CWaylandOutputViewport.h b/src/WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.h similarity index 78% rename from src/WallpaperEngine/Render/Drivers/Output/CWaylandOutputViewport.h rename to src/WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.h index d091347..451f50f 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CWaylandOutputViewport.h +++ b/src/WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.h @@ -9,28 +9,28 @@ #include #include -#include "../CWaylandOpenGLDriver.h" -#include -#include "COutputViewport.h" +#include "../WaylandOpenGLDriver.h" +#include "OutputViewport.h" +#include #include struct zwlr_layer_shell_v1; struct zwlr_layer_surface_v1; namespace WallpaperEngine::Render::Drivers { -class CWaylandOpenGLDriver; +class WaylandOpenGLDriver; namespace Output { -class COutputViewport; +class OutputViewport; -class CWaylandOutputViewport final : public COutputViewport { +class WaylandOutputViewport final : public OutputViewport { public: - CWaylandOutputViewport (CWaylandOpenGLDriver* driver, uint32_t waylandName, struct wl_registry* registry); + WaylandOutputViewport (WaylandOpenGLDriver* driver, uint32_t waylandName, struct wl_registry* registry); /** * @return The wayland driver */ - CWaylandOpenGLDriver* getDriver (); + WaylandOpenGLDriver* getDriver (); wl_output* output = nullptr; glm::ivec2 size = {}; @@ -69,7 +69,7 @@ class CWaylandOutputViewport final : public COutputViewport { void resize (); private: - CWaylandOpenGLDriver* m_driver = nullptr; + WaylandOpenGLDriver* m_driver = nullptr; }; } // namespace Output } // namespace WallpaperEngine::Render::Drivers diff --git a/src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp b/src/WallpaperEngine/Render/Drivers/Output/X11Output.cpp similarity index 87% rename from src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp rename to src/WallpaperEngine/Render/Drivers/Output/X11Output.cpp index 05a13d9..e4a295e 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp +++ b/src/WallpaperEngine/Render/Drivers/Output/X11Output.cpp @@ -1,6 +1,6 @@ -#include "CX11Output.h" -#include "CGLFWOutputViewport.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "GLFWOutputViewport.h" +#include "WallpaperEngine/Logging/Log.h" +#include "X11Output.h" #include #include @@ -9,7 +9,7 @@ using namespace WallpaperEngine::Render::Drivers::Output; void CustomXIOErrorExitHandler (Display* dsp, void* userdata) { - const auto context = static_cast (userdata); + const auto context = static_cast (userdata); sLog.debugerror ("Critical XServer error detected. Attempting to recover..."); @@ -29,7 +29,7 @@ int CustomXIOErrorHandler (Display* dsp) { return 0; } -CX11Output::CX11Output (CApplicationContext& context, CVideoDriver& driver) : COutput (context, driver), +X11Output::X11Output (ApplicationContext& context, VideoDriver& driver) : Output (context, driver), m_display (nullptr), m_pixmap (None), m_root (None), @@ -44,11 +44,11 @@ CX11Output::CX11Output (CApplicationContext& context, CVideoDriver& driver) : CO this->loadScreenInfo (); } -CX11Output::~CX11Output () { +X11Output::~X11Output () { this->free (); } -void CX11Output::reset () { +void X11Output::reset () { // first free whatever we have right now this->free (); // re-load screen info @@ -58,7 +58,7 @@ void CX11Output::reset () { // this->m_driver.getFullscreenDetector ().reset (); } -void CX11Output::free () { +void X11Output::free () { // go through all the viewports and free them for (const auto& [screen, viewport] : this->m_viewports) delete viewport; @@ -73,27 +73,27 @@ void CX11Output::free () { XCloseDisplay (this->m_display); } -void* CX11Output::getImageBuffer () const { +void* X11Output::getImageBuffer () const { return this->m_imageData; } -bool CX11Output::renderVFlip () const { +bool X11Output::renderVFlip () const { return false; } -bool CX11Output::renderMultiple () const { +bool X11Output::renderMultiple () const { return this->m_viewports.size () > 1; } -bool CX11Output::haveImageBuffer () const { +bool X11Output::haveImageBuffer () const { return true; } -uint32_t CX11Output::getImageBufferSize () const { +uint32_t X11Output::getImageBufferSize () const { return this->m_imageSize; } -void CX11Output::loadScreenInfo () { +void X11Output::loadScreenInfo () { this->m_display = XOpenDisplay (nullptr); // set the error handling to try and recover from X disconnections #ifdef HAVE_XSETIOERROREXITHANDLER @@ -131,7 +131,7 @@ void CX11Output::loadScreenInfo () { continue; // add the screen to the list of screens - this->m_screens.push_back (new CGLFWOutputViewport {{crtc->x, crtc->y, crtc->width, crtc->height}, info->name}); + this->m_screens.push_back (new GLFWOutputViewport {{crtc->x, crtc->y, crtc->width, crtc->height}, info->name}); // only keep info of registered screens if (this->m_context.settings.general.screenBackgrounds.find (info->name) != @@ -140,7 +140,7 @@ void CX11Output::loadScreenInfo () { crtc->height); this->m_viewports [info->name] = - new CGLFWOutputViewport {{crtc->x, crtc->y, crtc->width, crtc->height}, info->name}; + new GLFWOutputViewport {{crtc->x, crtc->y, crtc->width, crtc->height}, info->name}; } XRRFreeCrtcInfo (crtc); @@ -179,7 +179,7 @@ void CX11Output::loadScreenInfo () { this->m_driver.resizeWindow ({this->m_fullWidth, this->m_fullHeight}); } -void CX11Output::updateRender () const { +void X11Output::updateRender () const { // put the image back into the screen XPutImage (this->m_display, this->m_pixmap, this->m_gc, this->m_image, 0, 0, 0, 0, this->m_fullWidth, this->m_fullHeight); diff --git a/src/WallpaperEngine/Render/Drivers/Output/CX11Output.h b/src/WallpaperEngine/Render/Drivers/Output/X11Output.h similarity index 73% rename from src/WallpaperEngine/Render/Drivers/Output/CX11Output.h rename to src/WallpaperEngine/Render/Drivers/Output/X11Output.h index eb479fd..972a5e6 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CX11Output.h +++ b/src/WallpaperEngine/Render/Drivers/Output/X11Output.h @@ -6,14 +6,14 @@ #include -#include "COutput.h" -#include "WallpaperEngine/Render/Drivers/CVideoDriver.h" +#include "Output.h" +#include "WallpaperEngine/Render/Drivers/VideoDriver.h" namespace WallpaperEngine::Render::Drivers::Output { -class CX11Output final : public COutput { +class X11Output final : public Output { public: - CX11Output (CApplicationContext& context, CVideoDriver& driver); - ~CX11Output () override; + X11Output (ApplicationContext& context, VideoDriver& driver); + ~X11Output () override; void reset () override; @@ -35,6 +35,6 @@ class CX11Output final : public COutput { char* m_imageData = nullptr; uint32_t m_imageSize = 0; XImage* m_image = nullptr; - std::vector m_screens = {}; + std::vector m_screens = {}; }; } // namespace WallpaperEngine::Render::Drivers::Output \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/VideoDriver.cpp b/src/WallpaperEngine/Render/Drivers/VideoDriver.cpp new file mode 100644 index 0000000..6bba86f --- /dev/null +++ b/src/WallpaperEngine/Render/Drivers/VideoDriver.cpp @@ -0,0 +1,16 @@ +#include "VideoDriver.h" + +using namespace WallpaperEngine::Input; +using namespace WallpaperEngine::Render::Drivers; + +VideoDriver::VideoDriver (WallpaperApplication& app, MouseInput& mouseInput) : + m_app (app), + m_inputContext (mouseInput) {} + +WallpaperApplication& VideoDriver::getApp () const { + return this->m_app; +} + +InputContext& VideoDriver::getInputContext () { + return this->m_inputContext; +} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/CVideoDriver.h b/src/WallpaperEngine/Render/Drivers/VideoDriver.h similarity index 74% rename from src/WallpaperEngine/Render/Drivers/CVideoDriver.h rename to src/WallpaperEngine/Render/Drivers/VideoDriver.h index b02afe3..f0e7cd2 100644 --- a/src/WallpaperEngine/Render/Drivers/CVideoDriver.h +++ b/src/WallpaperEngine/Render/Drivers/VideoDriver.h @@ -1,35 +1,35 @@ #pragma once -#include "WallpaperEngine/Render/Drivers/Output/COutput.h" -#include "WallpaperEngine/Input/CMouseInput.h" -#include "WallpaperEngine/Input/CInputContext.h" +#include "WallpaperEngine/Input/InputContext.h" +#include "WallpaperEngine/Input/MouseInput.h" +#include "WallpaperEngine/Render/Drivers/Output/Output.h" #include #include #include namespace WallpaperEngine::Application { -class CWallpaperApplication; +class WallpaperApplication; } namespace WallpaperEngine::Input { -class CInputContext; +class InputContext; class CWaylandMouseInput; } namespace WallpaperEngine::Render::Drivers { namespace Detectors { -class CFullScreenDetector; +class FullScreenDetector; } -class CVideoDriver { +class VideoDriver { public: - explicit CVideoDriver (CWallpaperApplication& app, Input::CMouseInput& mouseInput); - virtual ~CVideoDriver () = default; + explicit VideoDriver (WallpaperApplication& app, Input::MouseInput& mouseInput); + virtual ~VideoDriver () = default; /** * @return The current output in use */ - [[nodiscard]] virtual Output::COutput& getOutput () = 0; + [[nodiscard]] virtual Output::Output& getOutput () = 0; /** * @return The time that has passed since the driver started */ @@ -74,16 +74,16 @@ class CVideoDriver { /** * @return The app that owns this driver */ - [[nodiscard]] CWallpaperApplication& getApp () const; + [[nodiscard]] WallpaperApplication& getApp () const; /** * @return The input context in use by this driver */ - [[nodiscard]] Input::CInputContext& getInputContext (); + [[nodiscard]] Input::InputContext& getInputContext (); private: /** App that owns this driver */ - CWallpaperApplication& m_app; - Input::CInputContext m_inputContext; + WallpaperApplication& m_app; + Input::InputContext m_inputContext; }; } // namespace WallpaperEngine::Render::Drivers \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/CVideoFactories.cpp b/src/WallpaperEngine/Render/Drivers/VideoFactories.cpp similarity index 62% rename from src/WallpaperEngine/Render/Drivers/CVideoFactories.cpp rename to src/WallpaperEngine/Render/Drivers/VideoFactories.cpp index bf9df0f..2aafe3d 100644 --- a/src/WallpaperEngine/Render/Drivers/CVideoFactories.cpp +++ b/src/WallpaperEngine/Render/Drivers/VideoFactories.cpp @@ -1,26 +1,26 @@ #include -#include "CVideoFactories.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "VideoFactories.h" +#include "WallpaperEngine/Logging/Log.h" #include using namespace WallpaperEngine::Render::Drivers; -CVideoFactories::CVideoFactories () { +VideoFactories::VideoFactories () { assert (this->sInstance == nullptr); } -CVideoFactories& CVideoFactories::get () { +VideoFactories& VideoFactories::get () { if (sInstance == nullptr) { - sInstance = std::make_unique (); + sInstance = std::make_unique (); } return *sInstance; } -void CVideoFactories::registerDriver ( - CApplicationContext::WINDOW_MODE forMode, std::string xdgSessionType, - WallpaperEngine::Render::Drivers::CVideoFactories::DriverConstructionFunc factory) { +void VideoFactories::registerDriver ( + ApplicationContext::WINDOW_MODE forMode, std::string xdgSessionType, + WallpaperEngine::Render::Drivers::VideoFactories::DriverConstructionFunc factory) { const auto cur = this->m_driverFactories.find (forMode); if (cur == this->m_driverFactories.end ()) { @@ -33,11 +33,11 @@ void CVideoFactories::registerDriver ( } } -void CVideoFactories::registerFullscreenDetector (std::string xdgSessionType, FullscreenDetectorConstructionFunc factory) { +void VideoFactories::registerFullscreenDetector (std::string xdgSessionType, FullscreenDetectorConstructionFunc factory) { this->m_fullscreenFactories.emplace (xdgSessionType, factory); } -std::vector CVideoFactories::getRegisteredDrivers () const { +std::vector VideoFactories::getRegisteredDrivers () const { std::vector result; for (const auto& [windowMode, sessionTypeToFactory] : this->m_driverFactories) { @@ -53,9 +53,9 @@ std::vector CVideoFactories::getRegisteredDrivers () const { return result; } -std::unique_ptr CVideoFactories::createVideoDriver ( - CApplicationContext::WINDOW_MODE mode, const std::string& xdgSessionType, - CApplicationContext& context, CWallpaperApplication& application +std::unique_ptr VideoFactories::createVideoDriver ( + ApplicationContext::WINDOW_MODE mode, const std::string& xdgSessionType, + ApplicationContext& context, WallpaperApplication& application ) { const auto sessionTypeToFactory = this->m_driverFactories.find (mode); @@ -67,7 +67,7 @@ std::unique_ptr CVideoFactories::createVideoDriver ( // and it's not like the current map properly allows for storing this // so hijacking the detection is probably best for now const auto factory = - mode != Application::CApplicationContext::DESKTOP_BACKGROUND + mode != Application::ApplicationContext::DESKTOP_BACKGROUND ? sessionTypeToFactory->second.find (DEFAULT_WINDOW_NAME) : sessionTypeToFactory->second.find (xdgSessionType); @@ -78,16 +78,16 @@ std::unique_ptr CVideoFactories::createVideoDriver ( return factory->second (context, application); } -std::unique_ptr CVideoFactories::createFullscreenDetector ( - std::string xdgSessionType, CApplicationContext& context, CVideoDriver& driver +std::unique_ptr VideoFactories::createFullscreenDetector ( + std::string xdgSessionType, ApplicationContext& context, VideoDriver& driver ) { const auto it = this->m_fullscreenFactories.find (xdgSessionType); if (it == this->m_fullscreenFactories.end () || !context.settings.render.pauseOnFullscreen) { - return std::make_unique (context); + return std::make_unique (context); } return it->second (context, driver); } -std::unique_ptr CVideoFactories::sInstance = nullptr; \ No newline at end of file +std::unique_ptr VideoFactories::sInstance = nullptr; \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/CVideoFactories.h b/src/WallpaperEngine/Render/Drivers/VideoFactories.h similarity index 58% rename from src/WallpaperEngine/Render/Drivers/CVideoFactories.h rename to src/WallpaperEngine/Render/Drivers/VideoFactories.h index af2951b..7b9410c 100644 --- a/src/WallpaperEngine/Render/Drivers/CVideoFactories.h +++ b/src/WallpaperEngine/Render/Drivers/VideoFactories.h @@ -4,27 +4,28 @@ #include #include -#include "CVideoDriver.h" +#include "VideoDriver.h" #define DEFAULT_WINDOW_NAME "default" namespace WallpaperEngine::Render::Drivers { -class CVideoFactories { +class VideoFactories { public: - using DriverConstructionFunc = std::function(CApplicationContext&, CWallpaperApplication&)>; - using FullscreenDetectorConstructionFunc = std::function(CApplicationContext&, CVideoDriver&)>; - CVideoFactories (); + using DriverConstructionFunc = std::function(ApplicationContext&, WallpaperApplication&)>; + using FullscreenDetectorConstructionFunc = std::function(ApplicationContext&, VideoDriver&)>; + VideoFactories (); - static CVideoFactories& get (); + static VideoFactories& get (); /** * Adds a new handler for the given window mode and XDG_SESSION_TYPE * * @param forMode + * @param xdgSessionType * @param factory */ void registerDriver ( - CApplicationContext::WINDOW_MODE forMode, std::string xdgSessionType, DriverConstructionFunc factory); + ApplicationContext::WINDOW_MODE forMode, std::string xdgSessionType, DriverConstructionFunc factory); /** * Adds a new handler for the given XDG_SESSION_TYPE @@ -44,29 +45,31 @@ class CVideoFactories { * * @param mode * @param xdgSessionType + * @param context + * @param application * @return */ - [[nodiscard]] std::unique_ptr createVideoDriver ( - CApplicationContext::WINDOW_MODE mode, const std::string& xdgSessionType, - CApplicationContext& context, CWallpaperApplication& application); + [[nodiscard]] std::unique_ptr createVideoDriver ( + ApplicationContext::WINDOW_MODE mode, const std::string& xdgSessionType, + ApplicationContext& context, WallpaperApplication& application); /** * Calls the factory and builds the requested fullscreen detector or provides a stub if not possible * * @return */ - [[nodiscard]] std::unique_ptr createFullscreenDetector ( - std::string xdgSessionType, CApplicationContext& context, CVideoDriver& driver); + [[nodiscard]] std::unique_ptr createFullscreenDetector ( + std::string xdgSessionType, ApplicationContext& context, VideoDriver& driver); private: using SessionTypeToFullscreenDetectorType = std::map ; using SessionTypeToFactoryType = std::map ; - using WindowModeToSessionType = std::map ; + using WindowModeToSessionType = std::map ; SessionTypeToFullscreenDetectorType m_fullscreenFactories = {}; WindowModeToSessionType m_driverFactories = {}; - static std::unique_ptr sInstance; + static std::unique_ptr sInstance; }; } // namespace WallpaperEngine::Render::Drivers -#define sVideoFactories (WallpaperEngine::Render::Drivers::CVideoFactories::get ()) \ No newline at end of file +#define sVideoFactories (WallpaperEngine::Render::Drivers::VideoFactories::get ()) \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp b/src/WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.cpp similarity index 86% rename from src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp rename to src/WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.cpp index bcf0255..b301fb6 100644 --- a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp +++ b/src/WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.cpp @@ -1,7 +1,7 @@ -#include "CWaylandOpenGLDriver.h" -#include "CVideoFactories.h" -#include "WallpaperEngine/Application/CWallpaperApplication.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WaylandOpenGLDriver.h" +#include "VideoFactories.h" +#include "WallpaperEngine/Application/WallpaperApplication.h" +#include "WallpaperEngine/Logging/Log.h" #define class _class #define namespace _namespace @@ -22,7 +22,7 @@ using namespace WallpaperEngine::Render::Drivers; static void handlePointerEnter (void* data, struct wl_pointer* wl_pointer, uint32_t serial, struct wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { - const auto driver = static_cast (data); + const auto driver = static_cast (data); const auto viewport = driver->surfaceToViewport (surface); driver->viewportInFocus = viewport; wl_surface_set_buffer_scale (viewport->cursorSurface, viewport->scale); @@ -39,7 +39,7 @@ static void handlePointerAxis (void* data, wl_pointer* wl_pointer, uint32_t time static void handlePointerMotion (void* data, struct wl_pointer* wl_pointer, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) { - const auto driver = static_cast (data); + const auto driver = static_cast (data); const auto x = wl_fixed_to_double (surface_x); const auto y = wl_fixed_to_double (surface_y); @@ -52,7 +52,7 @@ static void handlePointerMotion (void* data, struct wl_pointer* wl_pointer, uint static void handlePointerButton (void* data, struct wl_pointer* wl_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t button_state) { - const auto driver = static_cast (data); + const auto driver = static_cast (data); if (!driver->viewportInFocus) return; @@ -87,7 +87,7 @@ constexpr struct wl_seat_listener seatListener = {.capabilities = handleCapabili static void handleGlobal (void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version) { - const auto driver = static_cast (data); + const auto driver = static_cast (data); if (strcmp (interface, wl_compositor_interface.name) == 0) { driver->getWaylandContext ()->compositor = @@ -97,7 +97,7 @@ static void handleGlobal (void* data, struct wl_registry* registry, uint32_t nam static_cast (wl_registry_bind (registry, name, &wl_shm_interface, 1)); } else if (strcmp (interface, wl_output_interface.name) == 0) { driver->m_screens.emplace_back ( - new WallpaperEngine::Render::Drivers::Output::CWaylandOutputViewport (driver, name, registry)); + new WallpaperEngine::Render::Drivers::Output::WaylandOutputViewport (driver, name, registry)); } else if (strcmp (interface, zwlr_layer_shell_v1_interface.name) == 0) { driver->getWaylandContext ()->layerShell = static_cast (wl_registry_bind (registry, name, &zwlr_layer_shell_v1_interface, 1)); @@ -117,7 +117,7 @@ constexpr struct wl_registry_listener registryListener = { .global_remove = handleGlobalRemoved, }; -void CWaylandOpenGLDriver::initEGL () { +void WaylandOpenGLDriver::initEGL () { const char* CLIENT_EXTENSIONS = eglQueryString (EGL_NO_DISPLAY, EGL_EXTENSIONS); if (!CLIENT_EXTENSIONS) sLog.exception ("Failed to query EGL Extensions"); @@ -198,14 +198,14 @@ void CWaylandOpenGLDriver::initEGL () { } } -void CWaylandOpenGLDriver::finishEGL () const { +void WaylandOpenGLDriver::finishEGL () const { eglMakeCurrent (EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (m_eglContext.display) eglTerminate (m_eglContext.display); eglReleaseThread (); } -void CWaylandOpenGLDriver::onLayerClose (Output::CWaylandOutputViewport* viewport) { +void WaylandOpenGLDriver::onLayerClose (Output::WaylandOutputViewport* viewport) { sLog.error ("Compositor closed our LS, freeing data..."); if (viewport->eglSurface) @@ -231,8 +231,8 @@ void CWaylandOpenGLDriver::onLayerClose (Output::CWaylandOutputViewport* viewpor delete viewport; } -CWaylandOpenGLDriver::CWaylandOpenGLDriver (CApplicationContext& context, CWallpaperApplication& app) : - CVideoDriver (app, m_mouseInput), +WaylandOpenGLDriver::WaylandOpenGLDriver (ApplicationContext& context, WallpaperApplication& app) : + VideoDriver (app, m_mouseInput), m_output (context, *this), m_requestedExit (false), m_frameCounter (0), @@ -276,7 +276,7 @@ CWaylandOpenGLDriver::CWaylandOpenGLDriver (CApplicationContext& context, CWallp sLog.error ("Failed to initialize GLEW: ", glewGetErrorString (result)); } -CWaylandOpenGLDriver::~CWaylandOpenGLDriver () { +WaylandOpenGLDriver::~WaylandOpenGLDriver () { // stop EGL eglMakeCurrent (EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); @@ -291,7 +291,7 @@ CWaylandOpenGLDriver::~CWaylandOpenGLDriver () { wl_display_disconnect (this->m_waylandContext.display); } -void CWaylandOpenGLDriver::dispatchEventQueue () { +void WaylandOpenGLDriver::dispatchEventQueue () { static bool initialized = false; if (!initialized) { @@ -322,50 +322,50 @@ void CWaylandOpenGLDriver::dispatchEventQueue () { usleep ((minimumTime - (endTime - startTime)) * CLOCKS_PER_SEC); } -Output::COutput& CWaylandOpenGLDriver::getOutput () { +Output::Output& WaylandOpenGLDriver::getOutput () { return this->m_output; } -float CWaylandOpenGLDriver::getRenderTime () const { +float WaylandOpenGLDriver::getRenderTime () const { return static_cast (std::chrono::duration_cast ( std::chrono::high_resolution_clock::now () - renderStart) .count ()) / 1000000.0; } -bool CWaylandOpenGLDriver::closeRequested () { +bool WaylandOpenGLDriver::closeRequested () { return this->m_requestedExit; } -void CWaylandOpenGLDriver::resizeWindow (glm::ivec2 size) {} +void WaylandOpenGLDriver::resizeWindow (glm::ivec2 size) {} -void CWaylandOpenGLDriver::resizeWindow (glm::ivec4 sizeandpos) {} +void WaylandOpenGLDriver::resizeWindow (glm::ivec4 sizeandpos) {} -void CWaylandOpenGLDriver::showWindow () {} +void WaylandOpenGLDriver::showWindow () {} -void CWaylandOpenGLDriver::hideWindow () {} +void WaylandOpenGLDriver::hideWindow () {} -glm::ivec2 CWaylandOpenGLDriver::getFramebufferSize () const { +glm::ivec2 WaylandOpenGLDriver::getFramebufferSize () const { return glm::ivec2 {0, 0}; } -uint32_t CWaylandOpenGLDriver::getFrameCounter () const { +uint32_t WaylandOpenGLDriver::getFrameCounter () const { return m_frameCounter; } -CWaylandOpenGLDriver::SEGLContext* CWaylandOpenGLDriver::getEGLContext () { +WaylandOpenGLDriver::SEGLContext* WaylandOpenGLDriver::getEGLContext () { return &this->m_eglContext; } -void* CWaylandOpenGLDriver::getProcAddress (const char* name) const { +void* WaylandOpenGLDriver::getProcAddress (const char* name) const { return reinterpret_cast (eglGetProcAddress (name)); } -CWaylandOpenGLDriver::SWaylandContext* CWaylandOpenGLDriver::getWaylandContext () { +WaylandOpenGLDriver::WaylandContext* WaylandOpenGLDriver::getWaylandContext () { return &this->m_waylandContext; } -Output::CWaylandOutputViewport* CWaylandOpenGLDriver::surfaceToViewport (const wl_surface* surface) { +Output::WaylandOutputViewport* WaylandOpenGLDriver::surfaceToViewport (const wl_surface* surface) { for (const auto& o : m_screens) { if (o->surface == surface) return o; @@ -376,10 +376,10 @@ Output::CWaylandOutputViewport* CWaylandOpenGLDriver::surfaceToViewport (const w __attribute__((constructor)) void registerWaylandOpenGL () { sVideoFactories.registerDriver ( - CApplicationContext::DESKTOP_BACKGROUND, + ApplicationContext::DESKTOP_BACKGROUND, "wayland", - [](CApplicationContext& context, CWallpaperApplication& application) -> std::unique_ptr { - return std::make_unique (context, application); + [](ApplicationContext& context, WallpaperApplication& application) -> std::unique_ptr { + return std::make_unique (context, application); } ); } \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h b/src/WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.h similarity index 60% rename from src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h rename to src/WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.h index 41082ac..8f66f8c 100644 --- a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h +++ b/src/WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.h @@ -9,17 +9,17 @@ #include #include -#include "WallpaperEngine/Application/CApplicationContext.h" -#include "WallpaperEngine/Application/CWallpaperApplication.h" -#include "WallpaperEngine/Input/Drivers/CWaylandMouseInput.h" -#include "WallpaperEngine/Render/Drivers/CVideoDriver.h" -#include "WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h" -#include "WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h" -#include "WallpaperEngine/Render/Drivers/Output/CWaylandOutputViewport.h" +#include "WallpaperEngine/Application/ApplicationContext.h" +#include "WallpaperEngine/Application/WallpaperApplication.h" +#include "WallpaperEngine/Input/Drivers/WaylandMouseInput.h" +#include "WallpaperEngine/Render/Drivers/Detectors/WaylandFullScreenDetector.h" +#include "WallpaperEngine/Render/Drivers/Output/WaylandOutput.h" +#include "WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.h" +#include "WallpaperEngine/Render/Drivers/VideoDriver.h" namespace WallpaperEngine::Application { -class CApplicationContext; -class CWallpaperApplication; +class ApplicationContext; +class WallpaperApplication; } // namespace WallpaperEngine::Application struct zwlr_layer_shell_v1; @@ -28,15 +28,15 @@ struct zwlr_layer_surface_v1; namespace WallpaperEngine::Render::Drivers { using namespace WallpaperEngine::Application; using namespace WallpaperEngine::Input::Drivers; -class CWaylandOpenGLDriver; +class WaylandOpenGLDriver; namespace Output { -class CWaylandOutputViewport; -class CWaylandOutput; +class WaylandOutputViewport; +class WaylandOutput; } // namespace Output -class CWaylandOpenGLDriver final : public CVideoDriver { - friend class Output::CWaylandOutput; +class WaylandOpenGLDriver final : public VideoDriver { + friend class Output::WaylandOutput; friend class CWaylandMouseInput; public: @@ -47,7 +47,7 @@ class CWaylandOpenGLDriver final : public CVideoDriver { PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC eglCreatePlatformWindowSurfaceEXT = nullptr; }; - struct SWaylandContext { + struct WaylandContext { wl_display* display = nullptr; wl_registry* registry = nullptr; wl_compositor* compositor = nullptr; @@ -56,10 +56,10 @@ class CWaylandOpenGLDriver final : public CVideoDriver { wl_seat* seat = nullptr; }; - explicit CWaylandOpenGLDriver (CApplicationContext& context, CWallpaperApplication& app); - ~CWaylandOpenGLDriver (); + explicit WaylandOpenGLDriver (ApplicationContext& context, WallpaperApplication& app); + ~WaylandOpenGLDriver (); - [[nodiscard]] Output::COutput& getOutput () override; + [[nodiscard]] Output::Output& getOutput () override; float getRenderTime () const override; bool closeRequested () override; void resizeWindow (glm::ivec2 size) override; @@ -71,32 +71,32 @@ class CWaylandOpenGLDriver final : public CVideoDriver { void dispatchEventQueue () override; [[nodiscard]] void* getProcAddress (const char* name) const override; - void onLayerClose (Output::CWaylandOutputViewport*); - Output::CWaylandOutputViewport* surfaceToViewport (const wl_surface*); + void onLayerClose (Output::WaylandOutputViewport*); + Output::WaylandOutputViewport* surfaceToViewport (const wl_surface*); - Output::CWaylandOutputViewport* viewportInFocus = nullptr; + Output::WaylandOutputViewport* viewportInFocus = nullptr; [[nodiscard]] SEGLContext* getEGLContext (); - [[nodiscard]] SWaylandContext* getWaylandContext (); + [[nodiscard]] WaylandContext* getWaylandContext (); /** List of available screens */ - std::vector m_screens = {}; + std::vector m_screens = {}; private: /** The output used by the driver */ - Output::CWaylandOutput m_output; + Output::WaylandOutput m_output; /** The EGL context in use */ SEGLContext m_eglContext = {}; /** The Wayland context in use */ - SWaylandContext m_waylandContext = {}; + WaylandContext m_waylandContext = {}; mutable bool m_requestedExit; void initEGL (); void finishEGL () const; uint32_t m_frameCounter = 0; - CApplicationContext& m_context; - CWaylandMouseInput m_mouseInput; + ApplicationContext& m_context; + WaylandMouseInput m_mouseInput; std::chrono::high_resolution_clock::time_point renderStart = std::chrono::high_resolution_clock::now (); }; diff --git a/src/WallpaperEngine/Render/CFBOProvider.cpp b/src/WallpaperEngine/Render/FBOProvider.cpp similarity index 73% rename from src/WallpaperEngine/Render/CFBOProvider.cpp rename to src/WallpaperEngine/Render/FBOProvider.cpp index 4de1990..77d97be 100644 --- a/src/WallpaperEngine/Render/CFBOProvider.cpp +++ b/src/WallpaperEngine/Render/FBOProvider.cpp @@ -1,15 +1,15 @@ -#include "CFBOProvider.h" +#include "FBOProvider.h" #include using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Data::Model; -CFBOProvider::CFBOProvider (const CFBOProvider* parent) : +FBOProvider::FBOProvider (const FBOProvider* parent) : m_parent (parent) {} -std::shared_ptr CFBOProvider::create(const FBO& base, uint32_t flags, glm::vec2 size) { +std::shared_ptr FBOProvider::create(const FBO& base, uint32_t flags, glm::vec2 size) { return this->m_fbos[base.name] = std::make_shared ( base.name, // TODO: PROPERLY DETERMINE FBO FORMAT BASED ON THE STRING @@ -23,7 +23,7 @@ std::shared_ptr CFBOProvider::create(const FBO& base, uint32_t flags, glm: ); } -std::shared_ptr CFBOProvider::create ( +std::shared_ptr FBOProvider::create ( const std::string& name, TextureFormat format, uint32_t flags, float scale, glm::vec2 realSize, glm::vec2 textureSize ) { @@ -39,11 +39,11 @@ std::shared_ptr CFBOProvider::create ( ); } -std::shared_ptr CFBOProvider::alias (const std::string& newName, const std::string& original) { +std::shared_ptr FBOProvider::alias (const std::string& newName, const std::string& original) { return this->m_fbos[newName] = this->m_fbos[original]; } -std::shared_ptr CFBOProvider::find (const std::string& name) const { +std::shared_ptr FBOProvider::find (const std::string& name) const { const auto it = this->m_fbos.find (name); if (it != this->m_fbos.end ()) diff --git a/src/WallpaperEngine/Render/CFBOProvider.h b/src/WallpaperEngine/Render/FBOProvider.h similarity index 86% rename from src/WallpaperEngine/Render/CFBOProvider.h rename to src/WallpaperEngine/Render/FBOProvider.h index e65eb97..454e5b9 100644 --- a/src/WallpaperEngine/Render/CFBOProvider.h +++ b/src/WallpaperEngine/Render/FBOProvider.h @@ -8,9 +8,9 @@ namespace WallpaperEngine::Render { using namespace WallpaperEngine::Data::Model; -class CFBOProvider { +class FBOProvider { public: - CFBOProvider (const CFBOProvider* parent); + explicit FBOProvider (const FBOProvider* parent); std::shared_ptr create (const FBO& base, uint32_t flags, glm::vec2 size); std::shared_ptr create ( @@ -20,7 +20,7 @@ class CFBOProvider { [[nodiscard]] std::shared_ptr find (const std::string& name) const; private: - const CFBOProvider* m_parent; + const FBOProvider* m_parent; std::map > m_fbos = {}; }; } diff --git a/src/WallpaperEngine/Render/Helpers/CContextAware.cpp b/src/WallpaperEngine/Render/Helpers/CContextAware.cpp deleted file mode 100644 index 8eeab7b..0000000 --- a/src/WallpaperEngine/Render/Helpers/CContextAware.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "CContextAware.h" - -namespace WallpaperEngine::Render::Helpers { -CContextAware::CContextAware (const CContextAware& from) : CContextAware (from.getContext ()) {} - -CContextAware::CContextAware (const CContextAware* from) : CContextAware (from->getContext ()) {} - -CContextAware::CContextAware (CRenderContext& context) : m_context (context) {} - -CRenderContext& CContextAware::getContext () const { - return this->m_context; -} -} // namespace WallpaperEngine::Render::Helpers \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Helpers/ContextAware.cpp b/src/WallpaperEngine/Render/Helpers/ContextAware.cpp new file mode 100644 index 0000000..9919aed --- /dev/null +++ b/src/WallpaperEngine/Render/Helpers/ContextAware.cpp @@ -0,0 +1,13 @@ +#include "ContextAware.h" + +namespace WallpaperEngine::Render::Helpers { +ContextAware::ContextAware (const ContextAware& from) : ContextAware (from.getContext ()) {} + +ContextAware::ContextAware (const ContextAware* from) : ContextAware (from->getContext ()) {} + +ContextAware::ContextAware (RenderContext& context) : m_context (context) {} + +RenderContext& ContextAware::getContext () const { + return this->m_context; +} +} // namespace WallpaperEngine::Render::Helpers \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Helpers/CContextAware.h b/src/WallpaperEngine/Render/Helpers/ContextAware.h similarity index 58% rename from src/WallpaperEngine/Render/Helpers/CContextAware.h rename to src/WallpaperEngine/Render/Helpers/ContextAware.h index 352f923..d434778 100644 --- a/src/WallpaperEngine/Render/Helpers/CContextAware.h +++ b/src/WallpaperEngine/Render/Helpers/ContextAware.h @@ -1,33 +1,33 @@ #pragma once namespace WallpaperEngine::Render { -class CRenderContext; +class RenderContext; namespace Helpers { /** * Small helper class that provides access to the CRenderContext * in use currently */ -class CContextAware { +class ContextAware { public: - virtual ~CContextAware () = default; + virtual ~ContextAware () = default; /** * @param from Object to get the render context from */ - CContextAware (const CContextAware& from); + ContextAware (const ContextAware& from); /** * @param from Object to get the render context from */ - explicit CContextAware (const CContextAware* from); - explicit CContextAware (CRenderContext& context); + explicit ContextAware (const ContextAware* from); + explicit ContextAware (RenderContext& context); /** * @return The CRenderContext in use right now */ - [[nodiscard]] CRenderContext& getContext () const; + [[nodiscard]] RenderContext& getContext () const; private: - CRenderContext& m_context; + RenderContext& m_context; }; } // namespace Helpers } // namespace WallpaperEngine::Render \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Objects/CImage.cpp b/src/WallpaperEngine/Render/Objects/CImage.cpp index fbf6f8d..a9fb4a0 100644 --- a/src/WallpaperEngine/Render/Objects/CImage.cpp +++ b/src/WallpaperEngine/Render/Objects/CImage.cpp @@ -13,7 +13,7 @@ using namespace WallpaperEngine::Data::Builders; CImage::CImage (Wallpapers::CScene& scene, const Image& image) : Render::CObject (scene, image), - Render::CFBOProvider (&scene), + Render::FBOProvider (&scene), m_texture (nullptr), m_sceneSpacePosition (GL_NONE), m_copySpacePosition (GL_NONE), @@ -243,11 +243,11 @@ void CImage::setup () { // copy pass to the composite layer for (const auto& cur : this->getImage ().model->material->passes) { this->m_passes.push_back ( - new CPass (*this, std::make_shared (this), *cur, std::nullopt, std::nullopt, std::nullopt) + new CPass (*this, std::make_shared (this), *cur, std::nullopt, std::nullopt, std::nullopt) ); } - auto fboProvider = std::make_shared (this); + auto fboProvider = std::make_shared (this); // prepare the passes list if (!this->getImage ().effects.empty ()) { @@ -348,7 +348,7 @@ void CImage::setup () { this->m_passes.push_back ( new CPass ( *this, - std::make_shared (this), + std::make_shared (this), **this->m_materials.colorBlending.material->passes.begin (), *this->m_materials.colorBlending.override, std::nullopt, @@ -380,7 +380,7 @@ void CImage::setup () { void CImage::setupPasses () { // do a pass on everything and setup proper inputs and values std::shared_ptr drawTo = this->m_currentMainFBO; - std::shared_ptr asInput = this->getTexture (); + std::shared_ptr asInput = this->getTexture (); GLuint texcoord = this->getTexCoordCopy (); auto cur = this->m_passes.begin (); @@ -440,7 +440,7 @@ void CImage::setupPasses () { } } -void CImage::pinpongFramebuffer (std::shared_ptr* drawTo, std::shared_ptr* asInput) { +void CImage::pinpongFramebuffer (std::shared_ptr* drawTo, std::shared_ptr* asInput) { // temporarily store FBOs used std::shared_ptr currentMainFBO = this->m_currentMainFBO; std::shared_ptr currentSubFBO = this->m_currentSubFBO; @@ -516,7 +516,7 @@ void CImage::updateScreenSpacePosition () { ); } -std::shared_ptr CImage::getTexture () const { +std::shared_ptr CImage::getTexture () const { return this->m_texture; } diff --git a/src/WallpaperEngine/Render/Objects/CImage.h b/src/WallpaperEngine/Render/Objects/CImage.h index 0a97fe7..65abd9c 100644 --- a/src/WallpaperEngine/Render/Objects/CImage.h +++ b/src/WallpaperEngine/Render/Objects/CImage.h @@ -4,14 +4,14 @@ #include "WallpaperEngine/Render/Objects/Effects/CPass.h" #include "WallpaperEngine/Render/Wallpapers/CScene.h" -#include "WallpaperEngine/Render/Shaders/CShader.h" +#include "WallpaperEngine/Render/Shaders/Shader.h" -#include "../ITexture.h" +#include "../TextureProvider.h" #include using namespace WallpaperEngine; -using namespace WallpaperEngine::Assets; +using namespace WallpaperEngine::Render; namespace WallpaperEngine::Render::Objects::Effects { class CMaterial; @@ -21,7 +21,7 @@ class CPass; namespace WallpaperEngine::Render::Objects { class CEffect; -class CImage final : public CObject, public CFBOProvider { +class CImage final : public CObject, public FBOProvider { friend CObject; public: @@ -40,7 +40,7 @@ class CImage final : public CObject, public CFBOProvider { [[nodiscard]] GLuint getPassSpacePosition () const; [[nodiscard]] GLuint getTexCoordCopy () const; [[nodiscard]] GLuint getTexCoordPass () const; - [[nodiscard]] std::shared_ptr getTexture () const; + [[nodiscard]] std::shared_ptr getTexture () const; [[nodiscard]] double getAnimationTime () const; /** @@ -49,7 +49,7 @@ class CImage final : public CObject, public CFBOProvider { * @param drawTo The framebuffer to use * @param asInput The last texture used as output (if needed) */ - void pinpongFramebuffer (std::shared_ptr* drawTo, std::shared_ptr* asInput); + void pinpongFramebuffer (std::shared_ptr* drawTo, std::shared_ptr* asInput); protected: void setupPasses (); @@ -57,7 +57,7 @@ class CImage final : public CObject, public CFBOProvider { void updateScreenSpacePosition (); private: - std::shared_ptr m_texture = nullptr; + std::shared_ptr m_texture = nullptr; GLuint m_sceneSpacePosition; GLuint m_copySpacePosition; GLuint m_passSpacePosition; diff --git a/src/WallpaperEngine/Render/Objects/CSound.cpp b/src/WallpaperEngine/Render/Objects/CSound.cpp index 04c3927..814a8a4 100644 --- a/src/WallpaperEngine/Render/Objects/CSound.cpp +++ b/src/WallpaperEngine/Render/Objects/CSound.cpp @@ -24,7 +24,7 @@ void CSound::load () { for (const auto& cur : this->m_sound.sounds) { uint32_t filesize = 0; auto filebuffer = this->getContainer ().read (cur); - auto stream = new Audio::CAudioStream (this->getScene ().getAudioContext (), filebuffer, filesize); + auto stream = new Audio::AudioStream (this->getScene ().getAudioContext (), filebuffer, filesize); stream->setRepeat (this->m_sound.playbackmode.has_value() && this->m_sound.playbackmode == "loop"); diff --git a/src/WallpaperEngine/Render/Objects/CSound.h b/src/WallpaperEngine/Render/Objects/CSound.h index b63f167..3692e09 100644 --- a/src/WallpaperEngine/Render/Objects/CSound.h +++ b/src/WallpaperEngine/Render/Objects/CSound.h @@ -1,6 +1,6 @@ #pragma once -#include "WallpaperEngine/Audio/CAudioStream.h" +#include "WallpaperEngine/Audio/AudioStream.h" #include "WallpaperEngine/Render/CObject.h" using namespace WallpaperEngine; @@ -23,7 +23,7 @@ class CSound final : public CObject { void load (); private: - std::vector m_audioStreams = {}; + std::vector m_audioStreams = {}; const Sound& m_sound; }; diff --git a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp index eef6e22..0e23322 100644 --- a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp +++ b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp @@ -2,7 +2,7 @@ #include #include -#include "WallpaperEngine/Render/Helpers/CContextAware.h" +#include "WallpaperEngine/Render/Helpers/ContextAware.h" #include "WallpaperEngine/Data/Model/Effect.h" #include "WallpaperEngine/Data/Model/Material.h" @@ -10,14 +10,14 @@ #include "WallpaperEngine/Render/Objects/CImage.h" #include "WallpaperEngine/Render/CFBO.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariableFloat.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariableInteger.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector2.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector3.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector4.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" using namespace WallpaperEngine; using namespace WallpaperEngine::Render; @@ -33,12 +33,12 @@ const TextureMap DEFAULT_BINDS = {}; const ImageEffectPassOverride DEFAULT_OVERRIDE = {}; CPass::CPass ( - CImage& image, std::shared_ptr fboProvider, const MaterialPass& pass, + CImage& image, std::shared_ptr fboProvider, const MaterialPass& pass, std::optional> override, std::optional> binds, std::optional> target ) : - Helpers::CContextAware (image), + Helpers::ContextAware (image), m_image (image), m_fboProvider (std::move(fboProvider)), m_pass (pass), @@ -49,7 +49,7 @@ CPass::CPass ( this->setupShaders (); } -std::shared_ptr CPass::resolveTexture (std::shared_ptr expected, int index, std::shared_ptr previous) { +std::shared_ptr CPass::resolveTexture (std::shared_ptr expected, int index, std::shared_ptr previous) { if (expected == nullptr) { const auto it = this->m_fbos.find (index); @@ -145,7 +145,7 @@ void CPass::setupRenderTexture () { glUseProgram (this->m_programID); // maybe we can do this when setting the texture? - std::shared_ptr texture = this->resolveTexture (this->m_input, 0, this->m_input); + std::shared_ptr texture = this->resolveTexture (this->m_input, 0, this->m_input); uint32_t currentTexture = 0; glm::vec2 translation = {0.0f, 0.0f}; @@ -308,7 +308,7 @@ void CPass::render () { this->cleanupRenderSetup (); } -std::shared_ptr CPass::getFBOProvider () const { +std::shared_ptr CPass::getFBOProvider () const { return this->m_fboProvider; } @@ -320,7 +320,7 @@ void CPass::setDestination (std::shared_ptr drawTo) { this->m_drawTo = std::move(drawTo); } -void CPass::setInput (std::shared_ptr input) { +void CPass::setInput (std::shared_ptr input) { this->m_input = std::move(input); } @@ -364,7 +364,7 @@ std::optional> CPass::getTarget () const { return this->m_target; } -Render::Shaders::CShader* CPass::getShader () const { +Render::Shaders::Shader* CPass::getShader () const { return this->m_shader; } @@ -408,7 +408,7 @@ GLuint CPass::compileShader (const char* shader, GLuint type) { void CPass::setupShaders () { // ensure the constants are defined - std::shared_ptr texture0 = this->m_image.getTexture (); + std::shared_ptr texture0 = this->m_image.getTexture (); // copy the combos from the pass this->m_combos.insert (this->m_pass.combos.begin (), this->m_pass.combos.end ()); @@ -426,12 +426,12 @@ void CPass::setupShaders () { // TODO: REVIEW THE SHADER TEXTURES HERE, THE ONES PASSED ON TO THE SHADER SHOULD NOT BE IN THE LIST // TODO: USED TO BUILD THE TEXTURES LATER // use the combos copied from the pass so it includes the texture format - this->m_shader = new Render::Shaders::CShader ( + this->m_shader = new Render::Shaders::Shader ( this->m_image.getContainer (), this->m_pass.shader, this->m_combos, this->m_override.combos, this->m_pass.textures, this->m_override.textures, this->m_override.constants ); - const auto shaders = Shaders::CGLSLContext::get ().toGlsl ( + const auto shaders = Shaders::GLSLContext::get ().toGlsl ( this->m_shader->vertex (), this->m_shader->fragment ()); // compile the shaders @@ -574,7 +574,7 @@ void CPass::setupTextureUniforms () { } // resolve the main texture - std::shared_ptr texture = this->resolveTexture (this->m_image.getTexture (), 0); + std::shared_ptr texture = this->resolveTexture (this->m_image.getTexture (), 0); // register all the texture uniforms with correct values this->addUniform ("g_Texture0", 0); this->addUniform ("g_Texture1", 1); @@ -725,7 +725,7 @@ void CPass::setupShaderVariables () { continue; // get one instance of it - CShaderVariable* var = parameters.vertex == nullptr ? parameters.fragment : parameters.vertex; + ShaderVariable* var = parameters.vertex == nullptr ? parameters.fragment : parameters.vertex; // this takes care of all possible casts, even invalid ones, which will use whatever default behaviour // of the underlying CDynamicValue used for the value @@ -734,22 +734,22 @@ void CPass::setupShaderVariables () { } // define some basic methods for the template -void CPass::addUniform (CShaderVariable* value) { +void CPass::addUniform (ShaderVariable* value) { // no need to re-implement this, call the version that takes a CDynamicValue as second parameter // and that handles casting and everything this->addUniform (value, value); } -void CPass::addUniform (CShaderVariable* value, const DynamicValue* setting) { - if (value->is ()) { +void CPass::addUniform (ShaderVariable* value, const DynamicValue* setting) { + if (value->is ()) { this->addUniform (value->getName (), setting->getFloat ()); - } else if (value->is ()) { + } else if (value->is ()) { this->addUniform (value->getName (), setting->getInt ()); - } else if (value->is ()) { + } else if (value->is ()) { this->addUniform (value->getName (), setting->getVec2 ()); - } else if (value->is ()) { + } else if (value->is ()) { this->addUniform (value->getName (), setting->getVec3 ()); - } else if (value->is ()) { + } else if (value->is ()) { this->addUniform (value->getName (), setting->getVec4 ()); } else { sLog.error ("Cannot convert setting dynamic value to ", value->getName (), ". Using default value"); diff --git a/src/WallpaperEngine/Render/Objects/Effects/CPass.h b/src/WallpaperEngine/Render/Objects/Effects/CPass.h index d64ee02..20fccbc 100644 --- a/src/WallpaperEngine/Render/Objects/Effects/CPass.h +++ b/src/WallpaperEngine/Render/Objects/Effects/CPass.h @@ -3,27 +3,27 @@ #include #include -#include "../../ITexture.h" +#include "../../TextureProvider.h" #include "WallpaperEngine/Data/Model/Material.h" #include "WallpaperEngine/Render/CFBO.h" -#include "WallpaperEngine/Render/CFBOProvider.h" -#include "WallpaperEngine/Render/Helpers/CContextAware.h" -#include "WallpaperEngine/Render/Shaders/CShader.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h" +#include "WallpaperEngine/Render/FBOProvider.h" +#include "WallpaperEngine/Render/Helpers/ContextAware.h" +#include "WallpaperEngine/Render/Shaders/Shader.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h" namespace WallpaperEngine::Render::Objects { class CImage; } namespace WallpaperEngine::Render::Objects::Effects { -using namespace WallpaperEngine::Assets; +using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Render::Shaders::Variables; using namespace WallpaperEngine::Data::Model; -class CPass final : public Helpers::CContextAware { +class CPass final : public Helpers::ContextAware { public: CPass ( - CImage& image, std::shared_ptr fboProvider, const MaterialPass& pass, + CImage& image, std::shared_ptr fboProvider, const MaterialPass& pass, std::optional> override, std::optional> binds, std::optional> target); @@ -31,7 +31,7 @@ class CPass final : public Helpers::CContextAware { void render (); void setDestination (std::shared_ptr drawTo); - void setInput (std::shared_ptr input); + void setInput (std::shared_ptr input); void setTexCoord (GLuint texcoord); void setPosition (GLuint position); void setModelViewProjectionMatrix (const glm::mat4* projection); @@ -42,11 +42,11 @@ class CPass final : public Helpers::CContextAware { [[nodiscard]] BlendingMode getBlendingMode () const; [[nodiscard]] std::shared_ptr resolveFBO (const std::string& name) const; - [[nodiscard]] std::shared_ptr getFBOProvider () const; + [[nodiscard]] std::shared_ptr getFBOProvider () const; [[nodiscard]] const CImage& getImage () const; [[nodiscard]] const MaterialPass& getPass () const; [[nodiscard]] std::optional> getTarget () const; - [[nodiscard]] Render::Shaders::CShader* getShader () const; + [[nodiscard]] Render::Shaders::Shader* getShader () const; private: enum UniformType { @@ -113,8 +113,8 @@ class CPass final : public Helpers::CContextAware { void setupTextureUniforms (); void setupAttributes (); void addAttribute (const std::string& name, GLint type, GLint elements, const GLuint* value); - void addUniform (CShaderVariable* value); - void addUniform (CShaderVariable* value, const DynamicValue* setting); + void addUniform (ShaderVariable* value); + void addUniform (ShaderVariable* value, const DynamicValue* setting); void addUniform (const std::string& name, int value); void addUniform (const std::string& name, double value); void addUniform (const std::string& name, float value); @@ -151,10 +151,10 @@ class CPass final : public Helpers::CContextAware { void renderGeometry () const; void cleanupRenderSetup (); - std::shared_ptr resolveTexture (std::shared_ptr expected, int index, std::shared_ptr previous = nullptr); + std::shared_ptr resolveTexture (std::shared_ptr expected, int index, std::shared_ptr previous = nullptr); CImage& m_image; - std::shared_ptr m_fboProvider; + std::shared_ptr m_fboProvider; const MaterialPass& m_pass; const TextureMap& m_binds; const ImageEffectPassOverride& m_override; @@ -173,12 +173,12 @@ class CPass final : public Helpers::CContextAware { /** * Contains the final map of textures to be used */ - std::map> m_textures = {}; + std::map> m_textures = {}; - Render::Shaders::CShader* m_shader = nullptr; + Render::Shaders::Shader* m_shader = nullptr; std::shared_ptr m_drawTo = nullptr; - std::shared_ptr m_input = nullptr; + std::shared_ptr m_input = nullptr; GLuint m_programID; diff --git a/src/WallpaperEngine/Render/CRenderContext.cpp b/src/WallpaperEngine/Render/RenderContext.cpp similarity index 58% rename from src/WallpaperEngine/Render/CRenderContext.cpp rename to src/WallpaperEngine/Render/RenderContext.cpp index d70059b..1348d61 100644 --- a/src/WallpaperEngine/Render/CRenderContext.cpp +++ b/src/WallpaperEngine/Render/RenderContext.cpp @@ -2,18 +2,18 @@ #include -#include "CRenderContext.h" #include "CWallpaper.h" +#include "RenderContext.h" #include "WallpaperEngine/Data/Model/Project.h" namespace WallpaperEngine::Render { -CRenderContext::CRenderContext (Drivers::CVideoDriver& driver, CWallpaperApplication& app) : +RenderContext::RenderContext (Drivers::VideoDriver& driver, WallpaperApplication& app) : m_driver (driver), m_app (app), - m_textureCache (new CTextureCache (*this)) {} + m_textureCache (new TextureCache (*this)) {} -void CRenderContext::render (Drivers::Output::COutputViewport* viewport) { +void RenderContext::render (Drivers::Output::OutputViewport* viewport) { viewport->makeCurrent (); #if !NDEBUG @@ -36,36 +36,36 @@ void CRenderContext::render (Drivers::Output::COutputViewport* viewport) { viewport->swapOutput (); } -void CRenderContext::setWallpaper (const std::string& display, std::shared_ptr wallpaper) { +void RenderContext::setWallpaper (const std::string& display, std::shared_ptr wallpaper) { this->m_wallpapers.insert_or_assign (display, wallpaper); } -void CRenderContext::setPause (bool newState) { +void RenderContext::setPause (bool newState) { for (auto&& wallpaper : this->m_wallpapers) wallpaper.second->setPause (newState); } -Input::CInputContext& CRenderContext::getInputContext () const { +Input::InputContext& RenderContext::getInputContext () const { return this->m_driver.getInputContext (); } -const CWallpaperApplication& CRenderContext::getApp () const { +const WallpaperApplication& RenderContext::getApp () const { return this->m_app; } -const Drivers::CVideoDriver& CRenderContext::getDriver () const { +const Drivers::VideoDriver& RenderContext::getDriver () const { return this->m_driver; } -const Drivers::Output::COutput& CRenderContext::getOutput () const { +const Drivers::Output::Output& RenderContext::getOutput () const { return this->m_driver.getOutput (); } -std::shared_ptr CRenderContext::resolveTexture (const std::string& name) { +std::shared_ptr RenderContext::resolveTexture (const std::string& name) { return this->m_textureCache->resolve (name); } -const std::map>& CRenderContext::getWallpapers () const { +const std::map>& RenderContext::getWallpapers () const { return this->m_wallpapers; } } // namespace WallpaperEngine::Render diff --git a/src/WallpaperEngine/Render/RenderContext.h b/src/WallpaperEngine/Render/RenderContext.h new file mode 100644 index 0000000..cd56522 --- /dev/null +++ b/src/WallpaperEngine/Render/RenderContext.h @@ -0,0 +1,58 @@ +#pragma once + +#include +#include +#include + +#include "TextureCache.h" +#include "WallpaperEngine/Application/WallpaperApplication.h" +#include "WallpaperEngine/Input/InputContext.h" +#include "WallpaperEngine/Input/MouseInput.h" +#include "WallpaperEngine/Render/Drivers/Output/Output.h" +#include "WallpaperEngine/Render/Drivers/Output/OutputViewport.h" +#include "WallpaperEngine/Render/Drivers/VideoDriver.h" + +namespace WallpaperEngine { +namespace Application { +class WallpaperApplication; +} + +namespace Render { +namespace Drivers { +class VideoDriver; + +namespace Output { +class Output; +class OutputViewport; +} // namespace Output +} // namespace Drivers + +class CWallpaper; +class TextureCache; + +class RenderContext { + public: + RenderContext (Drivers::VideoDriver& driver, WallpaperApplication& app); + + void render (Drivers::Output::OutputViewport* viewport); + void setWallpaper (const std::string& display, std::shared_ptr wallpaper); + void setPause (bool newState); + [[nodiscard]] Input::InputContext& getInputContext () const; + [[nodiscard]] const WallpaperApplication& getApp () const; + [[nodiscard]] const Drivers::VideoDriver& getDriver () const; + [[nodiscard]] const Drivers::Output::Output& getOutput () const; + [[nodiscard]] std::shared_ptr resolveTexture (const std::string& name); + [[nodiscard]] const std::map>& getWallpapers () const; + + private: + /** Video driver in use */ + Drivers::VideoDriver& m_driver; + /** Maps screen -> wallpaper list */ + std::map> m_wallpapers = {}; + /** App that holds the render context */ + WallpaperApplication& m_app; + /** Texture cache for the render */ + TextureCache* m_textureCache = nullptr; +}; +} // namespace Render +} // namespace WallpaperEngine diff --git a/src/WallpaperEngine/Render/Shaders/CGLSLContext.cpp b/src/WallpaperEngine/Render/Shaders/GLSLContext.cpp similarity index 94% rename from src/WallpaperEngine/Render/Shaders/CGLSLContext.cpp rename to src/WallpaperEngine/Render/Shaders/GLSLContext.cpp index 4892f53..1111a60 100644 --- a/src/WallpaperEngine/Render/Shaders/CGLSLContext.cpp +++ b/src/WallpaperEngine/Render/Shaders/GLSLContext.cpp @@ -1,5 +1,5 @@ -#include "CGLSLContext.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "GLSLContext.h" +#include "WallpaperEngine/Logging/Log.h" #include #include @@ -117,24 +117,24 @@ TBuiltInResource BuiltInResource = { } }; -CGLSLContext::CGLSLContext () { +GLSLContext::GLSLContext () { assert (this->sInstance == nullptr); glslang::InitializeProcess(); } -CGLSLContext::~CGLSLContext () { +GLSLContext::~GLSLContext () { glslang::FinalizeProcess(); } -CGLSLContext& CGLSLContext::get () { +GLSLContext& GLSLContext::get () { if (sInstance == nullptr) - sInstance = std::make_unique (); + sInstance = std::make_unique (); return *sInstance; } -std::pair CGLSLContext::toGlsl (const std::string& vertex, const std::string& fragment) { +std::pair GLSLContext::toGlsl (const std::string& vertex, const std::string& fragment) { glslang::TShader vertexShader (EShLangVertex); const char* vertexSource = vertex.c_str(); @@ -195,4 +195,4 @@ std::pair CGLSLContext::toGlsl (const std::string& ver } -std::unique_ptr CGLSLContext::sInstance = nullptr; \ No newline at end of file +std::unique_ptr GLSLContext::sInstance = nullptr; \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Shaders/CGLSLContext.h b/src/WallpaperEngine/Render/Shaders/GLSLContext.h similarity index 74% rename from src/WallpaperEngine/Render/Shaders/CGLSLContext.h rename to src/WallpaperEngine/Render/Shaders/GLSLContext.h index e4cd893..649f019 100644 --- a/src/WallpaperEngine/Render/Shaders/CGLSLContext.h +++ b/src/WallpaperEngine/Render/Shaders/GLSLContext.h @@ -7,7 +7,7 @@ #include namespace WallpaperEngine::Render::Shaders { -class CGLSLContext { +class GLSLContext { public: /** * Types of shaders @@ -17,14 +17,14 @@ class CGLSLContext { UnitType_Fragment = 1 }; - CGLSLContext (); - ~CGLSLContext (); + GLSLContext (); + ~GLSLContext (); [[nodiscard]] std::pair toGlsl (const std::string& vertex, const std::string& fragment); - [[nodiscard]] static CGLSLContext& get (); + [[nodiscard]] static GLSLContext& get (); private: - static std::unique_ptr sInstance; + static std::unique_ptr sInstance; }; } // namespace WallpaperEngine::Render::Shaders \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Shaders/CShader.cpp b/src/WallpaperEngine/Render/Shaders/Shader.cpp similarity index 76% rename from src/WallpaperEngine/Render/Shaders/CShader.cpp rename to src/WallpaperEngine/Render/Shaders/Shader.cpp index b4cd5d7..e833290 100644 --- a/src/WallpaperEngine/Render/Shaders/CShader.cpp +++ b/src/WallpaperEngine/Render/Shaders/Shader.cpp @@ -3,16 +3,16 @@ #include // shader compiler -#include +#include #include -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h" -#include "CGLSLContext.h" -#include "WallpaperEngine/Assets/CAssetLoadException.h" +#include "GLSLContext.h" +#include "WallpaperEngine/Assets/AssetLoadException.h" #include "WallpaperEngine/FileSystem/Container.h" -using namespace WallpaperEngine::Assets; +using namespace WallpaperEngine::Render; namespace WallpaperEngine::Render::Shaders { // TODO: MOVE THIS INTO AN ASSET RESOLVER OR SOMETHING SIMILAR AS IT DOESN'T REALLY BELONG HERE BUT GETS THE CHANGESET OUT @@ -35,7 +35,7 @@ std::string readShader (const std::filesystem::path& filename, const Container& sLog.out ("Replaced ", filename, " with compat ", shader); return contents; - } catch (CAssetLoadException&) { } + } catch (AssetLoadException&) { } } } @@ -54,17 +54,17 @@ std::string readFragment (const std::filesystem::path& filename, const Container return readShader (shader, container); } -CShader::CShader ( +Shader::Shader ( const Container& container, std::string filename, const ComboMap& combos, const ComboMap& overrideCombos, const TextureMap& textures, const TextureMap& overrideTextures, const ShaderConstantMap& constants ) : m_vertex ( - CGLSLContext::UnitType_Vertex, filename, readVertex (filename, container), + GLSLContext::UnitType_Vertex, filename, readVertex (filename, container), container, constants, textures, overrideTextures, combos, overrideCombos), m_fragment ( - CGLSLContext::UnitType_Fragment, filename, readFragment (filename, container), + GLSLContext::UnitType_Fragment, filename, readFragment (filename, container), container, constants, textures, overrideTextures, combos, overrideCombos), m_file (std::move (filename)), m_combos (combos), @@ -77,29 +77,29 @@ CShader::CShader ( } -const std::string& CShader::vertex () { +const std::string& Shader::vertex () { return this->m_vertex.compile (); } -const std::string& CShader::fragment () { +const std::string& Shader::fragment () { return this->m_fragment.compile (); } -const CShaderUnit& CShader::getVertex () const { +const ShaderUnit& Shader::getVertex () const { return this->m_vertex; } -const CShaderUnit& CShader::getFragment () const { +const ShaderUnit& Shader::getFragment () const { return this->m_fragment; } -const std::map& CShader::getCombos () const { +const std::map& Shader::getCombos () const { return this->m_combos; } -CShader::ParameterSearchResult CShader::findParameter (const std::string& name) { - Variables::CShaderVariable* vertex = nullptr; - Variables::CShaderVariable* fragment = nullptr; +Shader::ParameterSearchResult Shader::findParameter (const std::string& name) { + Variables::ShaderVariable* vertex = nullptr; + Variables::ShaderVariable* fragment = nullptr; for (const auto& cur : this->m_vertex.getParameters ()) { if (cur->getIdentifierName () == name) { diff --git a/src/WallpaperEngine/Render/Shaders/CShader.h b/src/WallpaperEngine/Render/Shaders/Shader.h similarity index 77% rename from src/WallpaperEngine/Render/Shaders/CShader.h rename to src/WallpaperEngine/Render/Shaders/Shader.h index 563f2f6..0411c2a 100644 --- a/src/WallpaperEngine/Render/Shaders/CShader.h +++ b/src/WallpaperEngine/Render/Shaders/Shader.h @@ -4,27 +4,27 @@ #include #include -#include "../ITexture.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h" +#include "../TextureProvider.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h" -#include "CShaderUnit.h" -#include "CGLSLContext.h" +#include "ShaderUnit.h" +#include "GLSLContext.h" #include "WallpaperEngine/Data/Model/Types.h" namespace WallpaperEngine::Render::Shaders { using json = nlohmann::json; -using namespace WallpaperEngine::Assets; +using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Data::Model; /** * A basic shader loader that adds basic function definitions to every loaded shader */ -class CShader { +class Shader { public: struct ParameterSearchResult { - Variables::CShaderVariable* vertex; - Variables::CShaderVariable* fragment; + Variables::ShaderVariable* vertex; + Variables::ShaderVariable* fragment; }; /** * Compiler constructor, loads the given shader file and prepares @@ -33,14 +33,13 @@ class CShader { * * @param container The container to use for file lookup * @param filename The file to load - * @param type The type of shader * @param combos Settings for the shader - * @param foundCombos The list of currently defined combos + * @param overrideCombos List of override combos to use * @param textures The list of available textures for the shader + * @param overrideTextures List of override textures to use * @param constants Default values for shader variables - * @param recursive Whether the compiler should add base definitions or not */ - CShader ( + Shader ( const Container& container, std::string filename, const ComboMap& combos, const ComboMap& overrideCombos, const TextureMap& textures, const TextureMap& overrideTextures, @@ -56,11 +55,11 @@ class CShader { /** * @return The vertex shader unit */ - [[nodiscard]] const CShaderUnit& getVertex () const; + [[nodiscard]] const ShaderUnit& getVertex () const; /** * @return The fragment shader unit */ - [[nodiscard]] const CShaderUnit& getFragment () const; + [[nodiscard]] const ShaderUnit& getFragment () const; /** * @return The list of combos available for this shader after compilation */ @@ -77,19 +76,19 @@ class CShader { /** * The vertex shader unit used in this shader */ - CShaderUnit m_vertex; + ShaderUnit m_vertex; /** * The fragment shader unit used in this shader */ - CShaderUnit m_fragment; + ShaderUnit m_fragment; /** * The shader file this instance is loading */ - std::string m_file = ""; + std::string m_file; /** * The parameters the shader needs */ - std::vector m_parameters = {}; + std::vector m_parameters = {}; /** * The combos the shader should be generated with */ diff --git a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp b/src/WallpaperEngine/Render/Shaders/ShaderUnit.cpp similarity index 90% rename from src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp rename to src/WallpaperEngine/Render/Shaders/ShaderUnit.cpp index 23920d3..62272fd 100644 --- a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp +++ b/src/WallpaperEngine/Render/Shaders/ShaderUnit.cpp @@ -1,19 +1,19 @@ -#include "CShaderUnit.h" +#include "ShaderUnit.h" -#include +#include "WallpaperEngine/Logging/Log.h" #include #include +#include #include -#include "WallpaperEngine/Logging/CLog.h" -#include "CGLSLContext.h" -#include "WallpaperEngine/Assets/CAssetLoadException.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h" +#include "GLSLContext.h" +#include "WallpaperEngine/Assets/AssetLoadException.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariableFloat.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariableInteger.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector2.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector3.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector4.h" #include "WallpaperEngine/Data/Builders/VectorBuilder.h" #include "WallpaperEngine/FileSystem/Container.h" @@ -48,12 +48,12 @@ "#define varying out\n" #define DEFINE_COMBO(name, value) "#define " + name + " " + std::to_string (value) + "\n"; -using namespace WallpaperEngine::Assets; +using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Data::Builders; using namespace WallpaperEngine::Render::Shaders; -CShaderUnit::CShaderUnit ( - CGLSLContext::UnitType type, std::string file, std::string content, const Container& container, +ShaderUnit::ShaderUnit ( + GLSLContext::UnitType type, std::string file, std::string content, const Container& container, const ShaderConstantMap& constants, const TextureMap& passTextures, const TextureMap& overrideTextures, const ComboMap& combos, const ComboMap& overrideCombos ) : @@ -71,7 +71,7 @@ CShaderUnit::CShaderUnit ( this->preprocess (); } -void CShaderUnit::preprocess () { +void ShaderUnit::preprocess () { this->m_preprocessed = this->m_content; this->m_includes = ""; @@ -90,7 +90,7 @@ void CShaderUnit::preprocess () { } } -void CShaderUnit::preprocessVariables () { +void ShaderUnit::preprocessVariables () { this->m_preprocessed = this->m_content; this->m_includes = ""; @@ -134,7 +134,7 @@ void CShaderUnit::preprocessVariables () { } } -void CShaderUnit::preprocessIncludes () { +void ShaderUnit::preprocessIncludes () { size_t start = 0, end = 0; // prepare the include content while((start = this->m_preprocessed.find("#include", end)) != std::string::npos) { @@ -157,7 +157,7 @@ void CShaderUnit::preprocessIncludes () { content += "\n// end of included from file "; content += filename; content += "\n"; - } catch (CAssetLoadException&) { + } catch (AssetLoadException&) { content += "// tried including file "; content += filename; content += " but was not found\n"; @@ -197,7 +197,7 @@ void CShaderUnit::preprocessIncludes () { content += "\n// end of included from file "; content += filename; content += "\n"; - } catch (CAssetLoadException&) { + } catch (AssetLoadException&) { content = "// tried including file "; content += filename; content += " but was not found\n"; @@ -308,7 +308,7 @@ void CShaderUnit::preprocessIncludes () { } } -void CShaderUnit::preprocessRequires () { +void ShaderUnit::preprocessRequires () { size_t start = 0, end = 0; // comment out requires while((start = this->m_preprocessed.find("#require", end)) != std::string::npos) { @@ -323,7 +323,7 @@ void CShaderUnit::preprocessRequires () { } } -void CShaderUnit::parseComboConfiguration (const std::string& content, int defaultValue) { +void ShaderUnit::parseComboConfiguration (const std::string& content, int defaultValue) { // TODO: SUPPORT REQUIRES SO WE PROPERLY FOLLOW THE REQUIRED CHAIN const auto data = JSON::parse (content); const auto combo = data.require ("combo", "cannot parse combo information"); @@ -357,7 +357,7 @@ void CShaderUnit::parseComboConfiguration (const std::string& content, int defau } } -void CShaderUnit::parseParameterConfiguration ( +void ShaderUnit::parseParameterConfiguration ( const std::string& type, const std::string& name, const std::string& content ) { const auto data = JSON::parse (content); @@ -377,25 +377,25 @@ void CShaderUnit::parseParameterConfiguration ( sLog.exception ("Cannot parse parameter data for ", name, " in shader ", this->m_file); } - Variables::CShaderVariable* parameter = nullptr; + Variables::ShaderVariable* parameter = nullptr; if (type == "vec4") { - parameter = new Variables::CShaderVariableVector4 (VectorBuilder::parse (defvalue->get ())); + parameter = new Variables::ShaderVariableVector4 (VectorBuilder::parse (defvalue->get ())); } else if (type == "vec3") { - parameter = new Variables::CShaderVariableVector3 (VectorBuilder::parse (*defvalue)); + parameter = new Variables::ShaderVariableVector3 (VectorBuilder::parse (*defvalue)); } else if (type == "vec2") { - parameter = new Variables::CShaderVariableVector2 (VectorBuilder::parse (*defvalue)); + parameter = new Variables::ShaderVariableVector2 (VectorBuilder::parse (*defvalue)); } else if (type == "float") { if (defvalue->is_string ()) { - parameter = new Variables::CShaderVariableFloat (std::stoi (defvalue->get ())); + parameter = new Variables::ShaderVariableFloat (std::stoi (defvalue->get ())); } else { - parameter = new Variables::CShaderVariableFloat (defvalue->get ()); + parameter = new Variables::ShaderVariableFloat (defvalue->get ()); } } else if (type == "int") { if (defvalue->is_string ()) { - parameter = new Variables::CShaderVariableInteger (std::stoi(defvalue->get ())); + parameter = new Variables::ShaderVariableInteger (std::stoi(defvalue->get ())); } else { - parameter = new Variables::CShaderVariableInteger (defvalue->get ()); + parameter = new Variables::ShaderVariableInteger (defvalue->get ()); } } else if (type == "sampler2D" || type == "sampler2DComparison") { // samplers can have special requirements, check what sampler we're working with and create definitions @@ -505,30 +505,30 @@ void CShaderUnit::parseParameterConfiguration ( } } -const ComboMap& CShaderUnit::getCombos () const { +const ComboMap& ShaderUnit::getCombos () const { return this->m_combos; } -const ComboMap& CShaderUnit::getDiscoveredCombos () const { +const ComboMap& ShaderUnit::getDiscoveredCombos () const { return this->m_discoveredCombos; } -void CShaderUnit::linkToUnit (const CShaderUnit* unit) { +void ShaderUnit::linkToUnit (const ShaderUnit* unit) { this->m_link = unit; } -const CShaderUnit* CShaderUnit::getLinkedUnit () const { +const ShaderUnit* ShaderUnit::getLinkedUnit () const { return this->m_link; } -const std::string& CShaderUnit::compile () { +const std::string& ShaderUnit::compile () { if (!this->m_final.empty ()) { return this->m_final; } this->m_final = SHADER_HEADER(this->m_file); - if (this->m_type == CGLSLContext::UnitType_Fragment) { + if (this->m_type == GLSLContext::UnitType_Fragment) { this->m_final += FRAGMENT_SHADER_DEFINES; } else { this->m_final += VERTEX_SHADER_DEFINES; @@ -597,9 +597,9 @@ const std::string& CShaderUnit::compile () { return this->m_final; } -const std::vector& CShaderUnit::getParameters () const { +const std::vector& ShaderUnit::getParameters () const { return this->m_parameters; } -const TextureMap& CShaderUnit::getTextures () const { +const TextureMap& ShaderUnit::getTextures () const { return this->m_defaultTextures; } \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Shaders/CShaderUnit.h b/src/WallpaperEngine/Render/Shaders/ShaderUnit.h similarity index 84% rename from src/WallpaperEngine/Render/Shaders/CShaderUnit.h rename to src/WallpaperEngine/Render/Shaders/ShaderUnit.h index 7c84613..00ed412 100644 --- a/src/WallpaperEngine/Render/Shaders/CShaderUnit.h +++ b/src/WallpaperEngine/Render/Shaders/ShaderUnit.h @@ -4,9 +4,9 @@ #include #include -#include "CGLSLContext.h" +#include "GLSLContext.h" #include "WallpaperEngine/Data/JSON.h" -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h" +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h" #include "nlohmann/json.hpp" #include "WallpaperEngine/Data/Model/Types.h" @@ -19,24 +19,24 @@ using namespace WallpaperEngine::Data::Model; /** * Represents a whole shader unit */ -class CShaderUnit { +class ShaderUnit { public: - CShaderUnit ( - CGLSLContext::UnitType type, std::string file, std::string content, const Container& container, + ShaderUnit ( + GLSLContext::UnitType type, std::string file, std::string content, const Container& container, const ShaderConstantMap& constants, const TextureMap& passTextures, const TextureMap& overrideTextures, const ComboMap& combos, const ComboMap& overrideCombos); - ~CShaderUnit () = default; + ~ShaderUnit () = default; /** * Links this shader unit with another unit so they're treated as one * * @param unit */ - void linkToUnit (const CShaderUnit* unit); + void linkToUnit (const ShaderUnit* unit); /** * @return The shader unit linked to this unit (if any) */ - [[nodiscard]] const CShaderUnit* getLinkedUnit () const; + [[nodiscard]] const ShaderUnit* getLinkedUnit () const; /** * @return The unit's source code already compiled and ready to be used by OpenGL @@ -46,7 +46,7 @@ class CShaderUnit { /** * @return The parameters the shader unit has as input */ - [[nodiscard]] const std::vector& getParameters () const; + [[nodiscard]] const std::vector& getParameters () const; /** * @return The textures this shader unit requires */ @@ -100,31 +100,31 @@ class CShaderUnit { /** * The type of shder unit we have */ - CGLSLContext::UnitType m_type; + GLSLContext::UnitType m_type; /** * The filename of this shader unit */ - std::string m_file = ""; + std::string m_file; /** * Shader's original contents */ - std::string m_content = ""; + std::string m_content; /** * Includes content to be added on compilation */ - std::string m_includes = ""; + std::string m_includes; /** * Shader's content after the preprocessing step */ - std::string m_preprocessed = ""; + std::string m_preprocessed; /** * Shader's code after the compilation of glslang and spirv */ - std::string m_final = ""; + std::string m_final; /** * The parameters the shader needs */ - std::vector m_parameters = {}; + std::vector m_parameters = {}; /** * Pre-defined values for the combos */ @@ -154,7 +154,7 @@ class CShaderUnit { /** * The shader unit this unit is linked to */ - const CShaderUnit* m_link; + const ShaderUnit* m_link; /** * The container to source files from */ diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.cpp b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.cpp deleted file mode 100644 index 779504b..0000000 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "CShaderVariable.h" - -#include - -using namespace WallpaperEngine::Render::Shaders::Variables; - -const std::string& CShaderVariable::getIdentifierName () const { - return this->m_identifierName; -} - -const std::string& CShaderVariable::getName () const { - return this->m_name; -} - - -void CShaderVariable::setIdentifierName (std::string identifierName) { - this->m_identifierName = std::move (identifierName); -} - -void CShaderVariable::setName (const std::string& name) { - this->m_name = name; -} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h deleted file mode 100644 index da64b7a..0000000 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "CShaderVariable.h" - -namespace WallpaperEngine::Render::Shaders::Variables { -class CShaderVariableFloat final : public CShaderVariable { - public: - using CShaderVariable::CShaderVariable; - - CShaderVariableFloat (float defaultValue, const std::string& name); -}; -} // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.cpp b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.cpp deleted file mode 100644 index 4907d2c..0000000 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "CShaderVariableInteger.h" - -#include - -using namespace WallpaperEngine::Render::Shaders::Variables; - -CShaderVariableInteger::CShaderVariableInteger (int defaultValue, const std::string& name) : - CShaderVariable (defaultValue) { - this->setName (name); -} diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h deleted file mode 100644 index 17ff7ea..0000000 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "CShaderVariable.h" - -namespace WallpaperEngine::Render::Shaders::Variables { -class CShaderVariableInteger final : public CShaderVariable { - public: - using CShaderVariable::CShaderVariable; - - CShaderVariableInteger (int defaultValue, const std::string& name); -}; -} // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.cpp b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.cpp deleted file mode 100644 index 9bf915c..0000000 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "CShaderVariableVector2.h" - -#include - -using namespace WallpaperEngine::Render::Shaders::Variables; - -CShaderVariableVector2::CShaderVariableVector2 (const glm::vec2& defaultValue, const std::string& name) : - CShaderVariable (defaultValue) { - this->setName (name); -} diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h deleted file mode 100644 index 396535b..0000000 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include - -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h" - -namespace WallpaperEngine::Render::Shaders::Variables { -class CShaderVariableVector2 final : public CShaderVariable { - public: - using CShaderVariable::CShaderVariable; - - CShaderVariableVector2 (const glm::vec2& defaultValue, const std::string& name); -}; -} // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.cpp b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.cpp deleted file mode 100644 index 3ae9532..0000000 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "CShaderVariableVector3.h" - -using namespace WallpaperEngine::Render::Shaders::Variables; - -CShaderVariableVector3::CShaderVariableVector3 (const glm::vec3& defaultValue, const std::string& name) : - CShaderVariable (defaultValue) { - this->setName (name); -} diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h deleted file mode 100644 index 55ffd96..0000000 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h" - -namespace WallpaperEngine::Render::Shaders::Variables { -class CShaderVariableVector3 final : public CShaderVariable { - public: - using CShaderVariable::CShaderVariable; - - CShaderVariableVector3 (const glm::vec3& defaultValue, const std::string& name); -}; -} // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.cpp b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.cpp deleted file mode 100644 index f12253c..0000000 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "CShaderVariableVector4.h" - -#include - -using namespace WallpaperEngine::Render::Shaders::Variables; - -CShaderVariableVector4::CShaderVariableVector4 (const glm::vec4& defaultValue, const std::string& name) : - CShaderVariable (defaultValue) { - this->setName (name); -} diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h deleted file mode 100644 index c5d8bcd..0000000 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include - -#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h" - -namespace WallpaperEngine::Render::Shaders::Variables { -class CShaderVariableVector4 final : public CShaderVariable { - public: - using CShaderVariable::CShaderVariable; - - CShaderVariableVector4 (const glm::vec4& defaultValue, const std::string& name); -}; -} // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariable.cpp b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariable.cpp new file mode 100644 index 0000000..5bafef9 --- /dev/null +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariable.cpp @@ -0,0 +1,22 @@ +#include "ShaderVariable.h" + +#include + +using namespace WallpaperEngine::Render::Shaders::Variables; + +const std::string& ShaderVariable::getIdentifierName () const { + return this->m_identifierName; +} + +const std::string& ShaderVariable::getName () const { + return this->m_name; +} + + +void ShaderVariable::setIdentifierName (std::string identifierName) { + this->m_identifierName = std::move (identifierName); +} + +void ShaderVariable::setName (const std::string& name) { + this->m_name = name; +} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h similarity index 91% rename from src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h rename to src/WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h index ea7a637..d2c9f23 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h @@ -9,7 +9,7 @@ namespace WallpaperEngine::Render::Shaders::Variables { using namespace WallpaperEngine::Data::Model; using namespace WallpaperEngine::Data::Utils; -class CShaderVariable : public DynamicValue, public TypeCaster { +class ShaderVariable : public DynamicValue, public TypeCaster { public: using DynamicValue::DynamicValue; diff --git a/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableFloat.cpp b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableFloat.cpp new file mode 100644 index 0000000..1f5b554 --- /dev/null +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableFloat.cpp @@ -0,0 +1,10 @@ +#include "ShaderVariableFloat.h" + +#include + +using namespace WallpaperEngine::Render::Shaders::Variables; + +ShaderVariableFloat::ShaderVariableFloat (float defaultValue, const std::string& name) : + ShaderVariable (defaultValue) { + this->setName (name); +} diff --git a/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableFloat.h b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableFloat.h new file mode 100644 index 0000000..a7f8816 --- /dev/null +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableFloat.h @@ -0,0 +1,12 @@ +#pragma once + +#include "ShaderVariable.h" + +namespace WallpaperEngine::Render::Shaders::Variables { +class ShaderVariableFloat final : public ShaderVariable { + public: + using ShaderVariable::ShaderVariable; + + ShaderVariableFloat (float defaultValue, const std::string& name); +}; +} // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.cpp b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableInteger.cpp similarity index 50% rename from src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.cpp rename to src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableInteger.cpp index 8a43168..3f0c68c 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.cpp +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableInteger.cpp @@ -1,10 +1,10 @@ -#include "CShaderVariableFloat.h" +#include "ShaderVariableInteger.h" #include using namespace WallpaperEngine::Render::Shaders::Variables; -CShaderVariableFloat::CShaderVariableFloat (float defaultValue, const std::string& name) : - CShaderVariable (defaultValue) { +ShaderVariableInteger::ShaderVariableInteger (int defaultValue, const std::string& name) : + ShaderVariable (defaultValue) { this->setName (name); } diff --git a/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableInteger.h b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableInteger.h new file mode 100644 index 0000000..bbc1b34 --- /dev/null +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableInteger.h @@ -0,0 +1,12 @@ +#pragma once + +#include "ShaderVariable.h" + +namespace WallpaperEngine::Render::Shaders::Variables { +class ShaderVariableInteger final : public ShaderVariable { + public: + using ShaderVariable::ShaderVariable; + + ShaderVariableInteger (int defaultValue, const std::string& name); +}; +} // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector2.cpp b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector2.cpp new file mode 100644 index 0000000..928c9e1 --- /dev/null +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector2.cpp @@ -0,0 +1,10 @@ +#include "ShaderVariableVector2.h" + +#include + +using namespace WallpaperEngine::Render::Shaders::Variables; + +ShaderVariableVector2::ShaderVariableVector2 (const glm::vec2& defaultValue, const std::string& name) : + ShaderVariable (defaultValue) { + this->setName (name); +} diff --git a/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector2.h b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector2.h new file mode 100644 index 0000000..23c9067 --- /dev/null +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector2.h @@ -0,0 +1,13 @@ +#pragma once +#include + +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h" + +namespace WallpaperEngine::Render::Shaders::Variables { +class ShaderVariableVector2 final : public ShaderVariable { + public: + using ShaderVariable::ShaderVariable; + + ShaderVariableVector2 (const glm::vec2& defaultValue, const std::string& name); +}; +} // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector3.cpp b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector3.cpp new file mode 100644 index 0000000..be304fc --- /dev/null +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector3.cpp @@ -0,0 +1,8 @@ +#include "ShaderVariableVector3.h" + +using namespace WallpaperEngine::Render::Shaders::Variables; + +ShaderVariableVector3::ShaderVariableVector3 (const glm::vec3& defaultValue, const std::string& name) : + ShaderVariable (defaultValue) { + this->setName (name); +} diff --git a/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector3.h b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector3.h new file mode 100644 index 0000000..9bf67b1 --- /dev/null +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector3.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h" + +namespace WallpaperEngine::Render::Shaders::Variables { +class ShaderVariableVector3 final : public ShaderVariable { + public: + using ShaderVariable::ShaderVariable; + + ShaderVariableVector3 (const glm::vec3& defaultValue, const std::string& name); +}; +} // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector4.cpp b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector4.cpp new file mode 100644 index 0000000..c4db1e3 --- /dev/null +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector4.cpp @@ -0,0 +1,10 @@ +#include "ShaderVariableVector4.h" + +#include + +using namespace WallpaperEngine::Render::Shaders::Variables; + +ShaderVariableVector4::ShaderVariableVector4 (const glm::vec4& defaultValue, const std::string& name) : + ShaderVariable (defaultValue) { + this->setName (name); +} diff --git a/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector4.h b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector4.h new file mode 100644 index 0000000..b5920f7 --- /dev/null +++ b/src/WallpaperEngine/Render/Shaders/Variables/ShaderVariableVector4.h @@ -0,0 +1,13 @@ +#pragma once +#include + +#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h" + +namespace WallpaperEngine::Render::Shaders::Variables { +class ShaderVariableVector4 final : public ShaderVariable { + public: + using ShaderVariable::ShaderVariable; + + ShaderVariableVector4 (const glm::vec4& defaultValue, const std::string& name); +}; +} // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/CTextureCache.cpp b/src/WallpaperEngine/Render/TextureCache.cpp similarity index 70% rename from src/WallpaperEngine/Render/CTextureCache.cpp rename to src/WallpaperEngine/Render/TextureCache.cpp index 8f9c0c5..a28659a 100644 --- a/src/WallpaperEngine/Render/CTextureCache.cpp +++ b/src/WallpaperEngine/Render/TextureCache.cpp @@ -1,10 +1,10 @@ -#include "CTextureCache.h" +#include "TextureCache.h" #include "WallpaperEngine/FileSystem/Container.h" #include "CTexture.h" -#include "WallpaperEngine/Assets/CAssetLoadException.h" -#include "WallpaperEngine/Render/Helpers/CContextAware.h" +#include "WallpaperEngine/Assets/AssetLoadException.h" +#include "WallpaperEngine/Render/Helpers/ContextAware.h" #include "WallpaperEngine/Data/Model/Project.h" #include "WallpaperEngine/Data/Parsers/TextureParser.h" @@ -13,9 +13,9 @@ using namespace WallpaperEngine::Render; using namespace WallpaperEngine::FileSystem; using namespace WallpaperEngine::Data::Parsers; -CTextureCache::CTextureCache (CRenderContext& context) : Helpers::CContextAware (context) {} +TextureCache::TextureCache (RenderContext& context) : Helpers::ContextAware (context) {} -std::shared_ptr CTextureCache::resolve (const std::string& filename) { +std::shared_ptr TextureCache::resolve (const std::string& filename) { if (const auto found = this->m_textureCache.find (filename); found != this->m_textureCache.end ()) return found->second; @@ -35,14 +35,14 @@ std::shared_ptr CTextureCache::resolve (const std::string& filen this->store (filename, texture); return texture; - } catch (CAssetLoadException&) { + } catch (AssetLoadException&) { // ignored, this happens if we're looking at the wrong background } } - throw CAssetLoadException (filename, "Cannot find file"); + throw AssetLoadException (filename, "Cannot find file"); } -void CTextureCache::store (const std::string& name, std::shared_ptr texture) { +void TextureCache::store (const std::string& name, std::shared_ptr texture) { this->m_textureCache.insert_or_assign (name, texture); } \ No newline at end of file diff --git a/src/WallpaperEngine/Render/TextureCache.h b/src/WallpaperEngine/Render/TextureCache.h new file mode 100644 index 0000000..9004430 --- /dev/null +++ b/src/WallpaperEngine/Render/TextureCache.h @@ -0,0 +1,45 @@ +#pragma once + +#include +#include +#include + +#include "TextureProvider.h" +#include "WallpaperEngine/Render/Helpers/ContextAware.h" +#include "WallpaperEngine/Render/RenderContext.h" + +using namespace WallpaperEngine::Render; + +namespace WallpaperEngine::Render { +namespace Helpers { +class ContextAware; +} + +class RenderContext; + +class TextureCache final : Helpers::ContextAware { + public: + explicit TextureCache (RenderContext& context); + + /** + * Checks if the given texture was already loaded and returns it + * If the texture was not loaded yet, it tries to load it from the container + * + * @param filename + * @return + */ + std::shared_ptr resolve (const std::string& filename); + + /** + * Registers a texture in the cache + * + * @param name + * @param texture + */ + void store (const std::string& name, std::shared_ptr texture); + + private: + /** Cached textures */ + std::map> m_textureCache = {}; +}; +} // namespace WallpaperEngine::Render diff --git a/src/WallpaperEngine/Render/ITexture.h b/src/WallpaperEngine/Render/TextureProvider.h similarity index 94% rename from src/WallpaperEngine/Render/ITexture.h rename to src/WallpaperEngine/Render/TextureProvider.h index b251e97..244823a 100644 --- a/src/WallpaperEngine/Render/ITexture.h +++ b/src/WallpaperEngine/Render/TextureProvider.h @@ -9,15 +9,15 @@ #include "WallpaperEngine/Data/Assets/Texture.h" #include "WallpaperEngine/Data/Model/Types.h" -namespace WallpaperEngine::Assets { +namespace WallpaperEngine::Render { using namespace WallpaperEngine::Data::Assets; /** * Base interface that describes the minimum information required for a texture * to be displayed by the engine */ -class ITexture { +class TextureProvider { public: - virtual ~ITexture () = default; + virtual ~TextureProvider () = default; /** * @param imageIndex For animated textures, the frame to get the ID of diff --git a/src/WallpaperEngine/Render/CWallpaperState.cpp b/src/WallpaperEngine/Render/WallpaperState.cpp similarity index 72% rename from src/WallpaperEngine/Render/CWallpaperState.cpp rename to src/WallpaperEngine/Render/WallpaperState.cpp index 0244e5b..e61f994 100644 --- a/src/WallpaperEngine/Render/CWallpaperState.cpp +++ b/src/WallpaperEngine/Render/WallpaperState.cpp @@ -1,15 +1,15 @@ -#include "CWallpaperState.h" -#include "ITexture.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperState.h" +#include "TextureProvider.h" +#include "WallpaperEngine/Logging/Log.h" #include using namespace WallpaperEngine::Render; -CWallpaperState::CWallpaperState ( +WallpaperState::WallpaperState ( const TextureUVsScaling& textureUVsMode, const uint32_t& clampMode) : m_textureUVsMode (textureUVsMode) {} -bool CWallpaperState::hasChanged ( +bool WallpaperState::hasChanged ( const glm::ivec4& viewport, const bool& vflip, const int& projectionWidth,const int& projectionHeight ) const { return this->viewport.width != viewport.z || this->viewport.height != viewport.w || @@ -18,7 +18,7 @@ bool CWallpaperState::hasChanged ( } // Reset UVs to 0/1 values -void CWallpaperState::resetUVs () { +void WallpaperState::resetUVs () { this->UVs.ustart = 0; this->UVs.uend = 1; if (vflip) { @@ -31,7 +31,7 @@ void CWallpaperState::resetUVs () { } // Update Us coordinates for current viewport and projection -void CWallpaperState::updateUs (const int& projectionWidth, const int& projectionHeight) { +void WallpaperState::updateUs (const int& projectionWidth, const int& projectionHeight) { const float viewportWidth = this->getViewportWidth (); const float viewportHeight = this->getViewportHeight (); const int newWidth = viewportHeight / projectionHeight * projectionWidth; @@ -46,7 +46,7 @@ void CWallpaperState::updateUs (const int& projectionWidth, const int& projectio } // Update Vs coordinates for current viewport and projection -void CWallpaperState::updateVs (const int& projectionWidth, const int& projectionHeight) { +void WallpaperState::updateVs (const int& projectionWidth, const int& projectionHeight) { const float viewportWidth = this->getViewportWidth (); const float viewportHeight = this->getViewportHeight (); const int newHeight = viewportWidth / projectionWidth * projectionHeight; @@ -65,11 +65,11 @@ void CWallpaperState::updateVs (const int& projectionWidth, const int& projectio } } -template <> void CWallpaperState::updateTextureUVs () { +template <> void WallpaperState::updateTextureUVs () { this->resetUVs (); } -template <> void CWallpaperState::updateTextureUVs () { +template <> void WallpaperState::updateTextureUVs () { this->resetUVs (); const int viewportWidth = this->getViewportWidth (); @@ -90,7 +90,7 @@ template <> void CWallpaperState::updateTextureUVs void CWallpaperState::updateTextureUVs () { +template <> void WallpaperState::updateTextureUVs () { this->resetUVs (); const int viewportWidth = this->getViewportWidth (); @@ -111,7 +111,7 @@ template <> void CWallpaperState::updateTextureUVs void CWallpaperState::updateTextureUVs () { +template <> void WallpaperState::updateTextureUVs () { this->resetUVs (); const int viewportWidth = this->getViewportWidth (); @@ -130,41 +130,41 @@ template <> void CWallpaperState::updateTextureUVs void CWallpaperState::updateTextureUVs () { +template void WallpaperState::updateTextureUVs () { sLog.exception ( "Using generic template for scaling is not allowed. Write specialization template for your scaling mode.\ This message is for developers, if you are just user it's a bug."); } -CWallpaperState::TextureUVsScaling CWallpaperState::getTextureUVsScaling () const { +WallpaperState::TextureUVsScaling WallpaperState::getTextureUVsScaling () const { return this->m_textureUVsMode; } -uint32_t CWallpaperState::getClampingMode () const { +uint32_t WallpaperState::getClampingMode () const { return this->m_clampingMode; } -void CWallpaperState::setTextureUVsStrategy (CWallpaperState::TextureUVsScaling strategy) { +void WallpaperState::setTextureUVsStrategy (WallpaperState::TextureUVsScaling strategy) { this->m_textureUVsMode = strategy; } -int CWallpaperState::getViewportWidth () const { +int WallpaperState::getViewportWidth () const { return this->viewport.width; } -int CWallpaperState::getViewportHeight () const { +int WallpaperState::getViewportHeight () const { return this->viewport.height; } -int CWallpaperState::getProjectionWidth () const { +int WallpaperState::getProjectionWidth () const { return this->projection.width; } -int CWallpaperState::getProjectionHeight () const { +int WallpaperState::getProjectionHeight () const { return this->projection.height; } -void CWallpaperState::updateState (const glm::ivec4& viewport, const bool& vflip, const int& projectionWidth, +void WallpaperState::updateState (const glm::ivec4& viewport, const bool& vflip, const int& projectionWidth, const int& projectionHeight) { this->viewport.width = viewport.z; this->viewport.height = viewport.w; @@ -174,17 +174,17 @@ void CWallpaperState::updateState (const glm::ivec4& viewport, const bool& vflip // Set texture UVs according to choosen scaling mode for this wallpaper switch (this->getTextureUVsScaling ()) { - case CWallpaperState::TextureUVsScaling::StretchUVs: - this->updateTextureUVs (); + case WallpaperState::TextureUVsScaling::StretchUVs: + this->updateTextureUVs (); break; - case CWallpaperState::TextureUVsScaling::ZoomFillUVs: - this->updateTextureUVs (); + case WallpaperState::TextureUVsScaling::ZoomFillUVs: + this->updateTextureUVs (); break; - case CWallpaperState::TextureUVsScaling::ZoomFitUVs: - this->updateTextureUVs (); + case WallpaperState::TextureUVsScaling::ZoomFitUVs: + this->updateTextureUVs (); break; - case CWallpaperState::TextureUVsScaling::DefaultUVs: - this->updateTextureUVs (); + case WallpaperState::TextureUVsScaling::DefaultUVs: + this->updateTextureUVs (); break; default: sLog.exception ( diff --git a/src/WallpaperEngine/Render/CWallpaperState.h b/src/WallpaperEngine/Render/WallpaperState.h similarity index 95% rename from src/WallpaperEngine/Render/CWallpaperState.h rename to src/WallpaperEngine/Render/WallpaperState.h index 64ddf63..6baec30 100644 --- a/src/WallpaperEngine/Render/CWallpaperState.h +++ b/src/WallpaperEngine/Render/WallpaperState.h @@ -4,14 +4,14 @@ #include #include -#include "ITexture.h" +#include "TextureProvider.h" namespace WallpaperEngine::Render { using namespace WallpaperEngine::Data::Assets; /** * Represents current wallpaper state */ -class CWallpaperState { +class WallpaperState { public: // Scaling modes. Defines how UVs coordinates are calculated. enum class TextureUVsScaling : uint8_t { @@ -21,7 +21,7 @@ class CWallpaperState { StretchUVs, }; - CWallpaperState ( + WallpaperState ( const TextureUVsScaling& textureUVsMode, const uint32_t& clampMode); /** @@ -66,7 +66,7 @@ class CWallpaperState { /** * Updates UVs coordinates for current viewport and projection */ - template void updateTextureUVs (); + template void updateTextureUVs (); // Updates state with provided values void updateState (const glm::ivec4& viewport, const bool& vflip, const int& projectionWidth, diff --git a/src/WallpaperEngine/Render/Wallpapers/CScene.cpp b/src/WallpaperEngine/Render/Wallpapers/CScene.cpp index 829e060..0d2f385 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CScene.cpp +++ b/src/WallpaperEngine/Render/Wallpapers/CScene.cpp @@ -1,10 +1,10 @@ #include "WallpaperEngine/Render/Objects/CImage.h" #include "WallpaperEngine/Render/Objects/CSound.h" -#include "WallpaperEngine/Render/CWallpaperState.h" +#include "WallpaperEngine/Render/WallpaperState.h" #include "CScene.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" #include "WallpaperEngine/Data/Model/Wallpaper.h" #include "WallpaperEngine/Data/Parsers/ObjectParser.h" @@ -20,8 +20,8 @@ using namespace WallpaperEngine::Render::Wallpapers; using JSON = WallpaperEngine::Data::JSON::JSON; CScene::CScene ( - const Wallpaper& wallpaper, CRenderContext& context, CAudioContext& audioContext, - const CWallpaperState::TextureUVsScaling& scalingMode, + const Wallpaper& wallpaper, RenderContext& context, AudioContext& audioContext, + const WallpaperState::TextureUVsScaling& scalingMode, const uint32_t& clampMode ) : CWallpaper (wallpaper, context, audioContext, scalingMode, clampMode) { @@ -29,7 +29,7 @@ CScene::CScene ( auto scene = wallpaper.as (); // setup the scene camera - this->m_camera = std::make_unique (*this, scene->camera); + this->m_camera = std::make_unique (*this, scene->camera); float width = scene->camera.projection.width; float height = scene->camera.projection.height; @@ -242,7 +242,7 @@ void CScene::addObjectToRenderOrder (const Object& object) { } } -CCamera& CScene::getCamera () const { +Camera& CScene::getCamera () const { return *this->m_camera; } diff --git a/src/WallpaperEngine/Render/Wallpapers/CScene.h b/src/WallpaperEngine/Render/Wallpapers/CScene.h index c064b31..92b1984 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CScene.h +++ b/src/WallpaperEngine/Render/Wallpapers/CScene.h @@ -1,11 +1,11 @@ #pragma once -#include "WallpaperEngine/Render/CCamera.h" +#include "WallpaperEngine/Render/Camera.h" #include "WallpaperEngine/Render/CWallpaper.h" namespace WallpaperEngine::Render { -class CCamera; +class Camera; class CObject; } @@ -15,11 +15,11 @@ using namespace WallpaperEngine::Data::Model; class CScene final : public CWallpaper { public: CScene ( - const Wallpaper& wallpaper, CRenderContext& context, CAudioContext& audioContext, - const CWallpaperState::TextureUVsScaling& scalingMode, + const Wallpaper& wallpaper, RenderContext& context, AudioContext& audioContext, + const WallpaperState::TextureUVsScaling& scalingMode, const uint32_t& clampMode); - [[nodiscard]] CCamera& getCamera () const; + [[nodiscard]] Camera& getCamera () const; [[nodiscard]] const Scene& getScene () const; @@ -42,7 +42,7 @@ class CScene final : public CWallpaper { Render::CObject* createObject (const Object& object); void addObjectToRenderOrder (const Object& object); - std::unique_ptr m_camera; + std::unique_ptr m_camera; ObjectUniquePtr m_bloomObjectData; CObject* m_bloomObject = nullptr; std::map m_objects = {}; diff --git a/src/WallpaperEngine/Render/Wallpapers/CVideo.cpp b/src/WallpaperEngine/Render/Wallpapers/CVideo.cpp index 58a8e11..5602bf1 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CVideo.cpp +++ b/src/WallpaperEngine/Render/Wallpapers/CVideo.cpp @@ -1,5 +1,5 @@ #include "CVideo.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Logging/Log.h" #include @@ -15,8 +15,8 @@ void* get_proc_address (void* ctx, const char* name) { } CVideo::CVideo ( - const Wallpaper& wallpaper, CRenderContext& context, CAudioContext& audioContext, - const CWallpaperState::TextureUVsScaling& scalingMode, + const Wallpaper& wallpaper, RenderContext& context, AudioContext& audioContext, + const WallpaperState::TextureUVsScaling& scalingMode, const uint32_t& clampMode ) : CWallpaper (wallpaper, context, audioContext, scalingMode, clampMode) { diff --git a/src/WallpaperEngine/Render/Wallpapers/CVideo.h b/src/WallpaperEngine/Render/Wallpapers/CVideo.h index efba092..a9a5cf3 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CVideo.h +++ b/src/WallpaperEngine/Render/Wallpapers/CVideo.h @@ -1,6 +1,6 @@ #pragma once -#include "WallpaperEngine/Audio/CAudioStream.h" +#include "WallpaperEngine/Audio/AudioStream.h" #include "WallpaperEngine/Render/CWallpaper.h" #include #include @@ -9,8 +9,8 @@ namespace WallpaperEngine::Render::Wallpapers { class CVideo final : public CWallpaper { public: CVideo ( - const Wallpaper& video, CRenderContext& context, CAudioContext& audioContext, - const CWallpaperState::TextureUVsScaling& scalingMode, + const Wallpaper& video, RenderContext& context, AudioContext& audioContext, + const WallpaperState::TextureUVsScaling& scalingMode, const uint32_t& clampMode); const Video& getVideo () const; diff --git a/src/WallpaperEngine/Render/Wallpapers/CWeb.cpp b/src/WallpaperEngine/Render/Wallpapers/CWeb.cpp index b6ddf86..c3480c0 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CWeb.cpp +++ b/src/WallpaperEngine/Render/Wallpapers/CWeb.cpp @@ -2,10 +2,10 @@ // https://github.com/if1live/cef-gl-example // https://github.com/andmcgregor/cefgui #include "CWeb.h" -#include "WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.h" +#include "WallpaperEngine/WebBrowser/CEF/WPSchemeHandlerFactory.h" -#include "WallpaperEngine/Data/Model/Wallpaper.h" #include "WallpaperEngine/Data/Model/Project.h" +#include "WallpaperEngine/Data/Model/Wallpaper.h" using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Render::Wallpapers; @@ -14,8 +14,8 @@ using namespace WallpaperEngine::WebBrowser; using namespace WallpaperEngine::WebBrowser::CEF; CWeb::CWeb ( - const Wallpaper& wallpaper, CRenderContext& context, CAudioContext& audioContext, - CWebBrowserContext& browserContext, const CWallpaperState::TextureUVsScaling& scalingMode, + const Wallpaper& wallpaper, RenderContext& context, AudioContext& audioContext, + WebBrowserContext& browserContext, const WallpaperState::TextureUVsScaling& scalingMode, const uint32_t& clampMode ) : CWallpaper (wallpaper, context, audioContext, scalingMode, clampMode), @@ -26,16 +26,16 @@ CWeb::CWeb ( CefWindowInfo window_info; window_info.SetAsWindowless (0); - this->m_renderHandler = new WebBrowser::CEF::CRenderHandler (this); + this->m_renderHandler = new WebBrowser::CEF::RenderHandler (this); CefBrowserSettings browserSettings; // Documentaion says that 60 fps is maximum value browserSettings.windowless_frame_rate = std::max (60, context.getApp ().getContext ().settings.render.maximumFPS); - this->m_client = new WebBrowser::CEF::CBrowserClient (m_renderHandler); + this->m_client = new WebBrowser::CEF::BrowserClient (m_renderHandler); // use the custom scheme for the wallpaper's files const std::string htmlURL = - CWPSchemeHandlerFactory::generateSchemeName(this->getWeb ().project.workshopId) + + WPSchemeHandlerFactory::generateSchemeName(this->getWeb ().project.workshopId) + "://root/" + this->getWeb().filename; this->m_browser = diff --git a/src/WallpaperEngine/Render/Wallpapers/CWeb.h b/src/WallpaperEngine/Render/Wallpapers/CWeb.h index b5e3d99..b542999 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CWeb.h +++ b/src/WallpaperEngine/Render/Wallpapers/CWeb.h @@ -10,15 +10,15 @@ #include #include -#include "WallpaperEngine/Audio/CAudioStream.h" +#include "WallpaperEngine/Audio/AudioStream.h" #include "WallpaperEngine/Render/CWallpaper.h" -#include "WallpaperEngine/WebBrowser/CEF/CBrowserClient.h" -#include "WallpaperEngine/WebBrowser/CEF/CRenderHandler.h" +#include "WallpaperEngine/WebBrowser/CEF/BrowserClient.h" +#include "WallpaperEngine/WebBrowser/CEF/RenderHandler.h" #include "WallpaperEngine/Data/Model/Wallpaper.h" namespace WallpaperEngine::WebBrowser::CEF { -class CRenderHandler; +class RenderHandler; } namespace WallpaperEngine::Render::Wallpapers { @@ -26,9 +26,9 @@ class CWeb : public CWallpaper { public: CWeb ( - const Wallpaper& wallpaper, CRenderContext& context, CAudioContext& audioContext, - WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext, - const CWallpaperState::TextureUVsScaling& scalingMode, + const Wallpaper& wallpaper, RenderContext& context, AudioContext& audioContext, + WallpaperEngine::WebBrowser::WebBrowserContext& browserContext, + const WallpaperState::TextureUVsScaling& scalingMode, const uint32_t& clampMode); ~CWeb() override; [[nodiscard]] int getWidth () const override { return this->m_width; } @@ -47,10 +47,10 @@ class CWeb : public CWallpaper friend class CWallpaper; private: - WallpaperEngine::WebBrowser::CWebBrowserContext& m_browserContext; + WallpaperEngine::WebBrowser::WebBrowserContext& m_browserContext; CefRefPtr m_browser = nullptr; - CefRefPtr m_client = nullptr; - WallpaperEngine::WebBrowser::CEF::CRenderHandler* m_renderHandler = nullptr; + CefRefPtr m_client = nullptr; + WallpaperEngine::WebBrowser::CEF::RenderHandler* m_renderHandler = nullptr; int m_width = 16; int m_height = 17; diff --git a/src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.cpp b/src/WallpaperEngine/WebBrowser/CEF/BrowserApp.cpp similarity index 77% rename from src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.cpp rename to src/WallpaperEngine/WebBrowser/CEF/BrowserApp.cpp index b56fe7b..fe5f3b8 100644 --- a/src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.cpp +++ b/src/WallpaperEngine/WebBrowser/CEF/BrowserApp.cpp @@ -1,28 +1,28 @@ -#include "CBrowserApp.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "BrowserApp.h" +#include "WallpaperEngine/Logging/Log.h" using namespace WallpaperEngine::WebBrowser::CEF; -CBrowserApp::CBrowserApp (WallpaperEngine::Application::CWallpaperApplication& application) : - CSubprocessApp (application) { +BrowserApp::BrowserApp (WallpaperEngine::Application::WallpaperApplication& application) : + SubprocessApp (application) { } -CefRefPtr CBrowserApp::GetBrowserProcessHandler () { +CefRefPtr BrowserApp::GetBrowserProcessHandler () { return this; } -void CBrowserApp::OnContextInitialized () { +void BrowserApp::OnContextInitialized () { // register all the needed schemes, "wp" + the background id is going to be our scheme for (const auto& [workshopId, factory] : this->getHandlerFactories ()) { CefRegisterSchemeHandlerFactory ( - CWPSchemeHandlerFactory::generateSchemeName (workshopId), + WPSchemeHandlerFactory::generateSchemeName (workshopId), (const char*) nullptr, factory ); } } -void CBrowserApp::OnBeforeCommandLineProcessing (const CefString& process_type, CefRefPtr command_line) { +void BrowserApp::OnBeforeCommandLineProcessing (const CefString& process_type, CefRefPtr command_line) { command_line->AppendSwitchWithValue ("--disable-features", "IsolateOrigins,HardwareMediaKeyHandling,WebContentsOcclusion,RendererCodeIntegrityEnabled,site-per-process"); command_line->AppendSwitch ("--disable-gpu-shader-disk-cache"); command_line->AppendSwitch ("--disable-site-isolation-trials"); @@ -48,7 +48,7 @@ if (process_type.empty()) { }*/ } -void CBrowserApp::OnBeforeChildProcessLaunch(CefRefPtr command_line) { +void BrowserApp::OnBeforeChildProcessLaunch(CefRefPtr command_line) { // add back any parameters we had before so the new process can load up everything needed for (int i = 1; i < this->getApplication ().getContext ().getArgc (); i ++) { command_line->AppendArgument (this->getApplication ().getContext ().getArgv () [i]); diff --git a/src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.h b/src/WallpaperEngine/WebBrowser/CEF/BrowserApp.h similarity index 60% rename from src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.h rename to src/WallpaperEngine/WebBrowser/CEF/BrowserApp.h index fee39c2..2e74eb4 100644 --- a/src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.h +++ b/src/WallpaperEngine/WebBrowser/CEF/BrowserApp.h @@ -1,21 +1,21 @@ #pragma once -#include "CSubprocessApp.h" -#include "CWPSchemeHandlerFactory.h" -#include "WallpaperEngine/WebBrowser/CWebBrowserContext.h" +#include "SubprocessApp.h" +#include "WPSchemeHandlerFactory.h" +#include "WallpaperEngine/WebBrowser/WebBrowserContext.h" #include "include/cef_app.h" namespace WallpaperEngine::Application { -class CWallpaperApplication; +class WallpaperApplication; } namespace WallpaperEngine::WebBrowser::CEF { /** * Provides custom protocol to contain everything under it */ -class CBrowserApp : public CSubprocessApp, public CefBrowserProcessHandler { +class BrowserApp : public SubprocessApp, public CefBrowserProcessHandler { public: - explicit CBrowserApp (WallpaperEngine::Application::CWallpaperApplication& application); + explicit BrowserApp (WallpaperEngine::Application::WallpaperApplication& application); [[nodiscard]] CefRefPtr GetBrowserProcessHandler () override; @@ -24,7 +24,7 @@ class CBrowserApp : public CSubprocessApp, public CefBrowserProcessHandler { void OnBeforeChildProcessLaunch(CefRefPtr command_line) override; private: - IMPLEMENT_REFCOUNTING (CBrowserApp); - DISALLOW_COPY_AND_ASSIGN (CBrowserApp); + IMPLEMENT_REFCOUNTING (BrowserApp); + DISALLOW_COPY_AND_ASSIGN (BrowserApp); }; } // namespace WallpaperEngine::WebBrowser::CEF \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/BrowserClient.cpp b/src/WallpaperEngine/WebBrowser/CEF/BrowserClient.cpp new file mode 100644 index 0000000..7ed9919 --- /dev/null +++ b/src/WallpaperEngine/WebBrowser/CEF/BrowserClient.cpp @@ -0,0 +1,11 @@ +#include "BrowserClient.h" + +using namespace WallpaperEngine::WebBrowser::CEF; + +BrowserClient::BrowserClient(CefRefPtr ptr) : + m_renderHandler(std::move(ptr)) {} + +CefRefPtr BrowserClient::GetRenderHandler() +{ + return m_renderHandler; +} \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.h b/src/WallpaperEngine/WebBrowser/CEF/BrowserClient.h similarity index 80% rename from src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.h rename to src/WallpaperEngine/WebBrowser/CEF/BrowserClient.h index d8c1234..e4cdbba 100644 --- a/src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.h +++ b/src/WallpaperEngine/WebBrowser/CEF/BrowserClient.h @@ -7,15 +7,15 @@ namespace WallpaperEngine::WebBrowser::CEF { //! \brief Provide access to browser-instance-specific callbacks. A single //! CefClient instance can be shared among any number of browsers. // ************************************************************************* -class CBrowserClient: public CefClient +class BrowserClient: public CefClient { public: - explicit CBrowserClient(CefRefPtr ptr); + explicit BrowserClient(CefRefPtr ptr); [[nodiscard]] CefRefPtr GetRenderHandler() override; CefRefPtr m_renderHandler = nullptr; - IMPLEMENT_REFCOUNTING(CBrowserClient); + IMPLEMENT_REFCOUNTING(BrowserClient); }; } // namespace WallpaperEngine::WebBrowser::CEF \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.cpp b/src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.cpp deleted file mode 100644 index 4df9e94..0000000 --- a/src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "CBrowserClient.h" - -using namespace WallpaperEngine::WebBrowser::CEF; - -CBrowserClient::CBrowserClient(CefRefPtr ptr) : - m_renderHandler(std::move(ptr)) {} - -CefRefPtr CBrowserClient::GetRenderHandler() -{ - return m_renderHandler; -} \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.cpp b/src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.cpp deleted file mode 100644 index b1e6b5f..0000000 --- a/src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "CSubprocessApp.h" -#include "CWPSchemeHandlerFactory.h" -#include "WallpaperEngine/Data/Model/Project.h" - -using namespace WallpaperEngine::WebBrowser::CEF; - -CSubprocessApp::CSubprocessApp (WallpaperEngine::Application::CWallpaperApplication& application) : - m_application (application) { - for (const auto& [_, info] : this->m_application.getBackgrounds()) { - this->m_handlerFactories [info->workshopId] = new CWPSchemeHandlerFactory (*info); - } -} - -void CSubprocessApp::OnRegisterCustomSchemes (CefRawPtr registrar) { - // register all the needed schemes, "wp" + the background id is going to be our scheme - for (const auto& [workshopId, _] : this->m_handlerFactories) { - registrar->AddCustomScheme ( - CWPSchemeHandlerFactory::generateSchemeName (workshopId), - CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_SECURE | CEF_SCHEME_OPTION_FETCH_ENABLED - ); - } -} - -const WallpaperEngine::Application::CWallpaperApplication& CSubprocessApp::getApplication () const { - return this->m_application; -} - -const std::map& CSubprocessApp::getHandlerFactories () const { - return this->m_handlerFactories; -} \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.h b/src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.h deleted file mode 100644 index a2c9013..0000000 --- a/src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "CWPSchemeHandlerFactory.h" -#include "WallpaperEngine/WebBrowser/CWebBrowserContext.h" -#include "include/cef_app.h" - -namespace WallpaperEngine::Application { -class CWallpaperApplication; -} - -namespace WallpaperEngine::WebBrowser::CEF { -class CSubprocessApp : public CefApp { - public: - explicit CSubprocessApp (WallpaperEngine::Application::CWallpaperApplication& application); - - void OnRegisterCustomSchemes (CefRawPtr registrar) override; - - protected: - const WallpaperEngine::Application::CWallpaperApplication& getApplication () const; - const std::map& getHandlerFactories () const; - - private: - std::map m_handlerFactories = {}; - WallpaperEngine::Application::CWallpaperApplication& m_application; - IMPLEMENT_REFCOUNTING (CSubprocessApp); - DISALLOW_COPY_AND_ASSIGN (CSubprocessApp); -}; -} \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.cpp b/src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.cpp deleted file mode 100644 index 3bdd42c..0000000 --- a/src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "CWPSchemeHandlerFactory.h" -#include "CWPSchemeHandler.h" -#include "WallpaperEngine/WebBrowser/CWebBrowserContext.h" -#include "include/wrapper/cef_helpers.h" - -using namespace WallpaperEngine::WebBrowser::CEF; - -CWPSchemeHandlerFactory::CWPSchemeHandlerFactory (const Project& project) : - m_project (project) {} - -CefRefPtr CWPSchemeHandlerFactory::Create ( - CefRefPtr browser, CefRefPtr frame, - const CefString& scheme_name, CefRefPtr request) { - CEF_REQUIRE_IO_THREAD (); - return new CWPSchemeHandler(this->m_project); -} - -std::string CWPSchemeHandlerFactory::generateSchemeName (const std::string& workshopId) { - return std::string(WPENGINE_SCHEME) + workshopId; -} \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.cpp b/src/WallpaperEngine/WebBrowser/CEF/RenderHandler.cpp similarity index 62% rename from src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.cpp rename to src/WallpaperEngine/WebBrowser/CEF/RenderHandler.cpp index 267819b..ca0c353 100644 --- a/src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.cpp +++ b/src/WallpaperEngine/WebBrowser/CEF/RenderHandler.cpp @@ -1,17 +1,17 @@ -#include "CRenderHandler.h" +#include "RenderHandler.h" using namespace WallpaperEngine::WebBrowser::CEF; -CRenderHandler::CRenderHandler (WallpaperEngine::Render::Wallpapers::CWeb* webdata) : +RenderHandler::RenderHandler (WallpaperEngine::Render::Wallpapers::CWeb* webdata) : m_webdata (webdata) {} // Required by CEF -void CRenderHandler::GetViewRect (CefRefPtr browser, CefRect& rect) { +void RenderHandler::GetViewRect (CefRefPtr browser, CefRect& rect) { rect = CefRect (0, 0, this->m_webdata->getWidth (), this->m_webdata->getHeight ()); } // Will be executed in CEF message loop -void CRenderHandler::OnPaint (CefRefPtr browser, PaintElementType type, const RectList& dirtyRects, +void RenderHandler::OnPaint (CefRefPtr browser, PaintElementType type, const RectList& dirtyRects, const void* buffer, int width, int height) { glActiveTexture (GL_TEXTURE0); glBindTexture (GL_TEXTURE_2D, this->texture ()); @@ -19,14 +19,14 @@ void CRenderHandler::OnPaint (CefRefPtr browser, PaintElementType ty glBindTexture (GL_TEXTURE_2D, 0); } -int CRenderHandler::getWidth() const { +int RenderHandler::getWidth() const { return this->m_webdata->getWidth (); } -int CRenderHandler::getHeight() const { +int RenderHandler::getHeight() const { return this->m_webdata->getHeight (); } -GLuint CRenderHandler::texture () const { +GLuint RenderHandler::texture () const { return this->m_webdata->getWallpaperFramebuffer(); } \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.h b/src/WallpaperEngine/WebBrowser/CEF/RenderHandler.h similarity index 84% rename from src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.h rename to src/WallpaperEngine/WebBrowser/CEF/RenderHandler.h index b0e8ba0..74d4681 100644 --- a/src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.h +++ b/src/WallpaperEngine/WebBrowser/CEF/RenderHandler.h @@ -11,12 +11,12 @@ namespace WallpaperEngine::WebBrowser::CEF { // ************************************************************************* //! \brief Private implementation to handle CEF events to draw the web page. // ************************************************************************* -class CRenderHandler : public CefRenderHandler { +class RenderHandler : public CefRenderHandler { public: - explicit CRenderHandler (WallpaperEngine::Render::Wallpapers::CWeb* webdata); + explicit RenderHandler (WallpaperEngine::Render::Wallpapers::CWeb* webdata); //! \brief - ~CRenderHandler () override = default; + ~RenderHandler () override = default; //! \brief CefRenderHandler interface void GetViewRect (CefRefPtr browser, CefRect& rect) override; @@ -27,7 +27,7 @@ class CRenderHandler : public CefRenderHandler { int width, int height) override; //! \brief CefBase interface - IMPLEMENT_REFCOUNTING (CRenderHandler); + IMPLEMENT_REFCOUNTING (RenderHandler); private: WallpaperEngine::Render::Wallpapers::CWeb* m_webdata = nullptr; diff --git a/src/WallpaperEngine/WebBrowser/CEF/SubprocessApp.cpp b/src/WallpaperEngine/WebBrowser/CEF/SubprocessApp.cpp new file mode 100644 index 0000000..784b28c --- /dev/null +++ b/src/WallpaperEngine/WebBrowser/CEF/SubprocessApp.cpp @@ -0,0 +1,30 @@ +#include "SubprocessApp.h" +#include "WPSchemeHandlerFactory.h" +#include "WallpaperEngine/Data/Model/Project.h" + +using namespace WallpaperEngine::WebBrowser::CEF; + +SubprocessApp::SubprocessApp (WallpaperEngine::Application::WallpaperApplication& application) : + m_application (application) { + for (const auto& [_, info] : this->m_application.getBackgrounds()) { + this->m_handlerFactories [info->workshopId] = new WPSchemeHandlerFactory (*info); + } +} + +void SubprocessApp::OnRegisterCustomSchemes (CefRawPtr registrar) { + // register all the needed schemes, "wp" + the background id is going to be our scheme + for (const auto& [workshopId, _] : this->m_handlerFactories) { + registrar->AddCustomScheme ( + WPSchemeHandlerFactory::generateSchemeName (workshopId), + CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_SECURE | CEF_SCHEME_OPTION_FETCH_ENABLED + ); + } +} + +const WallpaperEngine::Application::WallpaperApplication& SubprocessApp::getApplication () const { + return this->m_application; +} + +const std::map& SubprocessApp::getHandlerFactories () const { + return this->m_handlerFactories; +} \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/SubprocessApp.h b/src/WallpaperEngine/WebBrowser/CEF/SubprocessApp.h new file mode 100644 index 0000000..f006a20 --- /dev/null +++ b/src/WallpaperEngine/WebBrowser/CEF/SubprocessApp.h @@ -0,0 +1,28 @@ +#pragma once + +#include "WPSchemeHandlerFactory.h" +#include "WallpaperEngine/WebBrowser/WebBrowserContext.h" +#include "include/cef_app.h" + +namespace WallpaperEngine::Application { +class WallpaperApplication; +} + +namespace WallpaperEngine::WebBrowser::CEF { +class SubprocessApp : public CefApp { + public: + explicit SubprocessApp (WallpaperEngine::Application::WallpaperApplication& application); + + void OnRegisterCustomSchemes (CefRawPtr registrar) override; + + protected: + const WallpaperEngine::Application::WallpaperApplication& getApplication () const; + const std::map& getHandlerFactories () const; + + private: + std::map m_handlerFactories = {}; + WallpaperEngine::Application::WallpaperApplication& m_application; + IMPLEMENT_REFCOUNTING (SubprocessApp); + DISALLOW_COPY_AND_ASSIGN (SubprocessApp); +}; +} \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.cpp b/src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandler.cpp similarity index 83% rename from src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.cpp rename to src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandler.cpp index 5ceaba9..d02aa55 100644 --- a/src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.cpp +++ b/src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandler.cpp @@ -1,5 +1,5 @@ -#include "CWPSchemeHandler.h" -#include "WallpaperEngine/Assets/CAssetLoadException.h" +#include "WPSchemeHandler.h" +#include "WallpaperEngine/Assets/AssetLoadException.h" #include #include "MimeTypes.h" @@ -7,15 +7,15 @@ #include "WallpaperEngine/Data/Model/Project.h" -using namespace WallpaperEngine::Assets; +using namespace WallpaperEngine::Render; using namespace WallpaperEngine::WebBrowser::CEF; -CWPSchemeHandler::CWPSchemeHandler(const Project& project) : +WPSchemeHandler::WPSchemeHandler(const Project& project) : m_project (project), m_container (*this->m_project.container) { } -bool CWPSchemeHandler::Open(CefRefPtr request, +bool WPSchemeHandler::Open(CefRefPtr request, bool& handle_request, CefRefPtr callback) { DCHECK(!CefCurrentlyOn(TID_UI) && !CefCurrentlyOn(TID_IO)); @@ -50,7 +50,7 @@ bool CWPSchemeHandler::Open(CefRefPtr request, this->m_contents = this->m_container.read (file); callback->Continue (); - } catch (CAssetLoadException&) { + } catch (AssetLoadException&) { #if !NDEBUG std::cout << "Cannot read file " << file << std::endl; #endif @@ -62,7 +62,7 @@ bool CWPSchemeHandler::Open(CefRefPtr request, } -void CWPSchemeHandler::GetResponseHeaders(CefRefPtr response, +void WPSchemeHandler::GetResponseHeaders(CefRefPtr response, int64_t& response_length, CefString& redirectUrl) { CEF_REQUIRE_IO_THREAD(); @@ -81,11 +81,11 @@ void CWPSchemeHandler::GetResponseHeaders(CefRefPtr response, response_length = -1; } -void CWPSchemeHandler::Cancel () { +void WPSchemeHandler::Cancel () { CEF_REQUIRE_IO_THREAD(); } -bool CWPSchemeHandler::Read(void* data_out, int bytes_to_read, int& bytes_read, +bool WPSchemeHandler::Read(void* data_out, int bytes_to_read, int& bytes_read, CefRefPtr callback) { DCHECK(!CefCurrentlyOn(TID_UI) && !CefCurrentlyOn(TID_IO)); diff --git a/src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.h b/src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandler.h similarity index 84% rename from src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.h rename to src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandler.h index 132ef1f..60640cf 100644 --- a/src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.h +++ b/src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandler.h @@ -19,9 +19,9 @@ using namespace WallpaperEngine::Data::Model; /** * wp{id}:// actual handler called by cef to access files */ -class CWPSchemeHandler : public CefResourceHandler { +class WPSchemeHandler : public CefResourceHandler { public: - explicit CWPSchemeHandler(const Project& project); + explicit WPSchemeHandler(const Project& project); bool Open(CefRefPtr request, bool& handle_request, @@ -44,7 +44,7 @@ class CWPSchemeHandler : public CefResourceHandler { std::string m_mimeType; - IMPLEMENT_REFCOUNTING(CWPSchemeHandler); - DISALLOW_COPY_AND_ASSIGN(CWPSchemeHandler); + IMPLEMENT_REFCOUNTING(WPSchemeHandler); + DISALLOW_COPY_AND_ASSIGN(WPSchemeHandler); }; }; \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandlerFactory.cpp b/src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandlerFactory.cpp new file mode 100644 index 0000000..6dd316e --- /dev/null +++ b/src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandlerFactory.cpp @@ -0,0 +1,20 @@ +#include "WPSchemeHandlerFactory.h" +#include "WPSchemeHandler.h" +#include "WallpaperEngine/WebBrowser/WebBrowserContext.h" +#include "include/wrapper/cef_helpers.h" + +using namespace WallpaperEngine::WebBrowser::CEF; + +WPSchemeHandlerFactory::WPSchemeHandlerFactory (const Project& project) : + m_project (project) {} + +CefRefPtr WPSchemeHandlerFactory::Create ( + CefRefPtr browser, CefRefPtr frame, + const CefString& scheme_name, CefRefPtr request) { + CEF_REQUIRE_IO_THREAD (); + return new WPSchemeHandler(this->m_project); +} + +std::string WPSchemeHandlerFactory::generateSchemeName (const std::string& workshopId) { + return std::string(WPENGINE_SCHEME) + workshopId; +} \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.h b/src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandlerFactory.h similarity index 73% rename from src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.h rename to src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandlerFactory.h index 208fe86..738aeaa 100644 --- a/src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.h +++ b/src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandlerFactory.h @@ -13,9 +13,9 @@ using namespace WallpaperEngine::Data::Model; /** * Simple factory that creates a scheme handler for wp when requested by Cef */ -class CWPSchemeHandlerFactory : public CefSchemeHandlerFactory { +class WPSchemeHandlerFactory : public CefSchemeHandlerFactory { public: - explicit CWPSchemeHandlerFactory (const Project& project); + explicit WPSchemeHandlerFactory (const Project& project); CefRefPtr Create ( CefRefPtr browser, CefRefPtr frame, @@ -25,7 +25,7 @@ class CWPSchemeHandlerFactory : public CefSchemeHandlerFactory { private: const Project& m_project; - IMPLEMENT_REFCOUNTING (CWPSchemeHandlerFactory); - DISALLOW_COPY_AND_ASSIGN (CWPSchemeHandlerFactory); + IMPLEMENT_REFCOUNTING (WPSchemeHandlerFactory); + DISALLOW_COPY_AND_ASSIGN (WPSchemeHandlerFactory); }; } // namespace WallpaperEngine::WebBrowser::CEF \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp b/src/WallpaperEngine/WebBrowser/WebBrowserContext.cpp similarity index 85% rename from src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp rename to src/WallpaperEngine/WebBrowser/WebBrowserContext.cpp index 5810842..5d01f6c 100644 --- a/src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp +++ b/src/WallpaperEngine/WebBrowser/WebBrowserContext.cpp @@ -1,7 +1,7 @@ -#include "CWebBrowserContext.h" -#include "CEF/CBrowserApp.h" -#include "WallpaperEngine/Logging/CLog.h" -#include "WallpaperEngine/WebBrowser/CEF/CSubprocessApp.h" +#include "WebBrowserContext.h" +#include "CEF/BrowserApp.h" +#include "WallpaperEngine/Logging/Log.h" +#include "WallpaperEngine/WebBrowser/CEF/SubprocessApp.h" #include "include/cef_app.h" #include "include/cef_render_handler.h" #include @@ -44,7 +44,7 @@ std::string generate_uuid_v4() { } } -CWebBrowserContext::CWebBrowserContext (WallpaperEngine::Application::CWallpaperApplication& wallpaperApplication) : +WebBrowserContext::WebBrowserContext (WallpaperEngine::Application::WallpaperApplication& wallpaperApplication) : m_browserApplication (nullptr), m_wallpaperApplication (wallpaperApplication) { CefMainArgs main_args (this->m_wallpaperApplication.getContext ().getArgc (), this->m_wallpaperApplication.getContext ().getArgv ()); @@ -58,9 +58,9 @@ CWebBrowserContext::CWebBrowserContext (WallpaperEngine::Application::CWallpaper commandLine->InitFromArgv (main_args.argc, main_args.argv); if (!commandLine->HasSwitch("type")) { - this->m_browserApplication = new CEF::CBrowserApp(wallpaperApplication); + this->m_browserApplication = new CEF::BrowserApp(wallpaperApplication); } else { - this->m_browserApplication = new CEF::CSubprocessApp(wallpaperApplication); + this->m_browserApplication = new CEF::SubprocessApp(wallpaperApplication); } // this blocks for anything not-main-thread @@ -94,7 +94,7 @@ CWebBrowserContext::CWebBrowserContext (WallpaperEngine::Application::CWallpaper } } -CWebBrowserContext::~CWebBrowserContext () { +WebBrowserContext::~WebBrowserContext () { sLog.out ("Shutting down CEF"); CefShutdown (); } diff --git a/src/WallpaperEngine/WebBrowser/CWebBrowserContext.h b/src/WallpaperEngine/WebBrowser/WebBrowserContext.h similarity index 52% rename from src/WallpaperEngine/WebBrowser/CWebBrowserContext.h rename to src/WallpaperEngine/WebBrowser/WebBrowserContext.h index 42c4fdc..0876c88 100644 --- a/src/WallpaperEngine/WebBrowser/CWebBrowserContext.h +++ b/src/WallpaperEngine/WebBrowser/WebBrowserContext.h @@ -1,7 +1,7 @@ #pragma once -#include "WallpaperEngine/Application/CApplicationContext.h" -#include "WallpaperEngine/Application/CWallpaperApplication.h" +#include "WallpaperEngine/Application/ApplicationContext.h" +#include "WallpaperEngine/Application/WallpaperApplication.h" #include "include/cef_app.h" #include "include/cef_browser_process_handler.h" #include "include/wrapper/cef_helpers.h" @@ -9,18 +9,18 @@ #define WPENGINE_SCHEME "wp" namespace WallpaperEngine::WebBrowser::CEF { -class CBrowserApp; +class BrowserApp; } namespace WallpaperEngine::WebBrowser { - class CWebBrowserContext { + class WebBrowserContext { public: - explicit CWebBrowserContext (WallpaperEngine::Application::CWallpaperApplication& wallpaperApplication); - ~CWebBrowserContext(); + explicit WebBrowserContext (WallpaperEngine::Application::WallpaperApplication& wallpaperApplication); + ~WebBrowserContext(); private: CefRefPtr m_browserApplication = nullptr; CefRefPtr m_commandLine = nullptr; - WallpaperEngine::Application::CWallpaperApplication& m_wallpaperApplication; + WallpaperEngine::Application::WallpaperApplication& m_wallpaperApplication; }; } // namespace WallpaperEngine::WebBrowser diff --git a/src/main.cpp b/src/main.cpp index 21341c1..bbcafcd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,11 +1,11 @@ #include #include -#include "WallpaperEngine/Application/CApplicationContext.h" -#include "WallpaperEngine/Application/CWallpaperApplication.h" -#include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Application/ApplicationContext.h" +#include "WallpaperEngine/Application/WallpaperApplication.h" +#include "WallpaperEngine/Logging/Log.h" -WallpaperEngine::Application::CWallpaperApplication* app; +WallpaperEngine::Application::WallpaperApplication* app; void signalhandler(int sig) { if (app == nullptr) @@ -40,13 +40,13 @@ int main (int argc, char* argv[]) { initLogging (); } - WallpaperEngine::Application::CApplicationContext appContext (argc, argv); + WallpaperEngine::Application::ApplicationContext appContext (argc, argv); // halt if the list-properties option was specified if (appContext.settings.general.onlyListProperties) return 0; - app = new WallpaperEngine::Application::CWallpaperApplication (appContext); + app = new WallpaperEngine::Application::WallpaperApplication (appContext); // attach signals to gracefully stop std::signal (SIGINT, signalhandler);