diff --git a/CMakeLists.txt b/CMakeLists.txt index 73a7144..4fefd5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) endif() set_property(GLOBAL PROPERTY OS_FOLDERS ON) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") set(OpenGL_GL_PREFERENCE "LEGACY") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -104,6 +104,8 @@ find_package(CEF REQUIRED) # remove some switches that forbid us from using things that are commonplace in our codebase list(REMOVE_ITEM CEF_CXX_COMPILER_FLAGS -fno-exceptions) list(REMOVE_ITEM CEF_CXX_COMPILER_FLAGS -fno-rtti) +list(REMOVE_ITEM CEF_CXX_COMPILER_FLAGS -std=c++17) +list(APPEND CEF_CXX_COMPILER_FLAGS -std=c++20) # remove the vulkan library from the files to copy so it doesn't fail after removing it list(REMOVE_ITEM CEF_BINARY_FILES libvulkan.so.1) @@ -419,6 +421,8 @@ add_executable( src/WallpaperEngine/Data/Utils/BinaryReader.h src/WallpaperEngine/Data/Utils/MemoryStream.h src/WallpaperEngine/Data/Utils/SFINAE.h + src/WallpaperEngine/Data/Parsers/EffectParser.cpp + src/WallpaperEngine/Data/Parsers/EffectParser.h src/WallpaperEngine/Data/Parsers/ProjectParser.cpp src/WallpaperEngine/Data/Parsers/ProjectParser.h src/WallpaperEngine/Data/Parsers/WallpaperParser.cpp @@ -440,15 +444,13 @@ add_executable( src/WallpaperEngine/Data/Builders/UserSettingBuilder.h src/WallpaperEngine/Data/Builders/VectorBuilder.cpp src/WallpaperEngine/Data/Builders/VectorBuilder.h - - ${WAYLAND_SOURCES} - ${X11_SOURCES} - ${DEMOMODE_SOURCES} src/WallpaperEngine/Data/Dumpers/StringPrinter.cpp src/WallpaperEngine/Data/Dumpers/StringPrinter.h src/WallpaperEngine/Data/JSON.cpp - src/WallpaperEngine/Data/Parsers/EffectParser.cpp - src/WallpaperEngine/Data/Parsers/EffectParser.h) + + ${WAYLAND_SOURCES} + ${X11_SOURCES} + ${DEMOMODE_SOURCES}) target_link_libraries (linux-wallpaperengine PUBLIC ${OPENGL_LIBRARIES} diff --git a/CMakeModules/DownloadCEF.cmake b/CMakeModules/DownloadCEF.cmake index b780121..650f464 100644 --- a/CMakeModules/DownloadCEF.cmake +++ b/CMakeModules/DownloadCEF.cmake @@ -52,8 +52,8 @@ endfunction() # SET_EXECUTABLE_TARGET_PROPERTIES() instead of calling this macro directly. macro(REPLACED_SET_COMMON_TARGET_PROPERTIES target) # Compile flags. (MODIFIED FOR C/C++ SEPARATION) - target_compile_options(${target} PRIVATE $<$:${CEF_COMPILER_FLAGS}>) - target_compile_options(${target} PRIVATE $<$:${CEF_CXX_COMPILER_FLAGS}>) + target_compile_options(${target} PRIVATE $<$:${CEF_COMPILER_FLAGS} ${CEF_C_COMPILER_FLAGS}>) + target_compile_options(${target} PRIVATE $<$:${CEF_COMPILER_FLAGS} ${CEF_CXX_COMPILER_FLAGS}>) target_compile_options(${target} PRIVATE $<$:${CEF_COMPILER_FLAGS_DEBUG} ${CEF_CXX_COMPILER_FLAGS_DEBUG}>) target_compile_options(${target} PRIVATE $<$:${CEF_COMPILER_FLAGS_RELEASE} ${CEF_CXX_COMPILER_FLAGS_RELEASE}>) diff --git a/src/WallpaperEngine/Application/CApplicationContext.cpp b/src/WallpaperEngine/Application/CApplicationContext.cpp index aca9b3a..6ea50d3 100644 --- a/src/WallpaperEngine/Application/CApplicationContext.cpp +++ b/src/WallpaperEngine/Application/CApplicationContext.cpp @@ -192,7 +192,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) : screenshotGroup.add_argument ("--screenshot-delay") .help ("Frames to wait before taking the screenshot") - .default_value (5) + .default_value (5) .store_into (this->settings.screenshot.delay); auto& contentGroup = program.add_group ("Content options"); @@ -263,7 +263,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) : } this->settings.audio.volume = std::max(0, std::min (this->settings.audio.volume, 128)); - this->settings.screenshot.delay = std::max (0, std::min (this->settings.screenshot.delay, 5)); + this->settings.screenshot.delay = std::max (0, std::min (this->settings.screenshot.delay, 5)); // use std::cout on this in case logging is disabled, this way it's easy to look at what is running std::stringbuf buffer; diff --git a/src/WallpaperEngine/Application/CApplicationContext.h b/src/WallpaperEngine/Application/CApplicationContext.h index 4650a52..d67c9fe 100644 --- a/src/WallpaperEngine/Application/CApplicationContext.h +++ b/src/WallpaperEngine/Application/CApplicationContext.h @@ -105,7 +105,7 @@ class CApplicationContext { /** If an screenshot should be taken */ bool take; /** The frames to wait until the screenshot is taken */ - int delay; + uint32_t delay; /** The path to where the screenshot must be saved */ std::filesystem::path path; } screenshot; diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.cpp b/src/WallpaperEngine/Application/CWallpaperApplication.cpp index cfdabc3..74722ba 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.cpp +++ b/src/WallpaperEngine/Application/CWallpaperApplication.cpp @@ -421,7 +421,6 @@ void CWallpaperApplication::show () { std::vector pixels(width * height * 3); bool initialized = false; int frame = 0; - int elapsed_frames = 0; #endif /* DEMOMODE */ while (this->m_context.state.general.keepRunning) { @@ -447,12 +446,10 @@ void CWallpaperApplication::show () { } #if DEMOMODE - elapsed_frames ++; - // wait for a full render cycle before actually starting // this gives some extra time for video and web decoders to set themselves up // because of size changes - if (elapsed_frames > this->m_context.settings.render.maximumFPS) { + if (m_videoDriver->getFrameCounter () > this->m_context.settings.render.maximumFPS) { if (!initialized) { width = this->m_renderContext->getWallpapers ().begin ()->second->getWidth (); height = this->m_renderContext->getWallpapers ().begin ()->second->getHeight (); diff --git a/src/WallpaperEngine/Data/Model/Object.h b/src/WallpaperEngine/Data/Model/Object.h index 624fc09..118dd24 100644 --- a/src/WallpaperEngine/Data/Model/Object.h +++ b/src/WallpaperEngine/Data/Model/Object.h @@ -35,7 +35,7 @@ struct ObjectData { */ class Object : public TypeCaster, public ObjectData { public: - explicit Object (ObjectData data) noexcept : ObjectData (std::move (data)), TypeCaster () {}; + explicit Object (ObjectData data) noexcept : TypeCaster (), ObjectData (std::move (data)) {}; ~Object () override = default; }; diff --git a/src/WallpaperEngine/Data/Model/Property.h b/src/WallpaperEngine/Data/Model/Property.h index dcd0eed..8516a34 100644 --- a/src/WallpaperEngine/Data/Model/Property.h +++ b/src/WallpaperEngine/Data/Model/Property.h @@ -27,7 +27,7 @@ struct ComboData { class Property : public DynamicValue, public TypeCaster, public PropertyData { public: - explicit Property (PropertyData data) : PropertyData (std::move(data)), TypeCaster (), DynamicValue () {} + explicit Property (PropertyData data) : DynamicValue (), TypeCaster (), PropertyData (std::move(data)) {} using DynamicValue::update; virtual void update(const std::string& value) = 0; diff --git a/src/WallpaperEngine/Data/Model/Wallpaper.h b/src/WallpaperEngine/Data/Model/Wallpaper.h index 55c366c..eeb3c56 100644 --- a/src/WallpaperEngine/Data/Model/Wallpaper.h +++ b/src/WallpaperEngine/Data/Model/Wallpaper.h @@ -19,7 +19,7 @@ struct WallpaperData { class Wallpaper : public TypeCaster, public WallpaperData { public: - explicit Wallpaper (WallpaperData data) noexcept : WallpaperData (std::move(data)), TypeCaster () {}; + explicit Wallpaper (WallpaperData data) noexcept : TypeCaster (), WallpaperData (std::move(data)) {}; ~Wallpaper () override = default; }; diff --git a/src/WallpaperEngine/Data/Utils/BinaryReader.cpp b/src/WallpaperEngine/Data/Utils/BinaryReader.cpp index 9c87d31..79ead31 100644 --- a/src/WallpaperEngine/Data/Utils/BinaryReader.cpp +++ b/src/WallpaperEngine/Data/Utils/BinaryReader.cpp @@ -1,4 +1,5 @@ #include +#include #include "BinaryReader.h" @@ -13,10 +14,17 @@ uint32_t BinaryReader::nextUInt32 () { this->m_input.read (buffer, 4); - return (buffer [3] & 0xFF) << 24 | - (buffer [2] & 0xFF) << 16 | - (buffer [1] & 0xFF) << 8 | - (buffer [0] & 0xFF); + if constexpr (std::endian::native == std::endian::little) { + return (buffer [3] & 0xFF) << 24 | + (buffer [2] & 0xFF) << 16 | + (buffer [1] & 0xFF) << 8 | + (buffer [0] & 0xFF); + } else { + return (buffer [0] & 0xFF) << 24 | + (buffer [1] & 0xFF) << 16 | + (buffer [2] & 0xFF) << 8 | + (buffer [3] & 0xFF); + } } int BinaryReader::nextInt () { @@ -24,18 +32,24 @@ int BinaryReader::nextInt () { this->m_input.read (buffer, 4); - return (buffer [3] & 0xFF) << 24 | - (buffer [2] & 0xFF) << 16 | - (buffer [1] & 0xFF) << 8 | - (buffer [0] & 0xFF); + if constexpr (std::endian::native == std::endian::little) { + return (buffer [3] & 0xFF) << 24 | + (buffer [2] & 0xFF) << 16 | + (buffer [1] & 0xFF) << 8 | + (buffer [0] & 0xFF); + } else { + return (buffer [0] & 0xFF) << 24 | + (buffer [1] & 0xFF) << 16 | + (buffer [2] & 0xFF) << 8 | + (buffer [3] & 0xFF); + } } - float BinaryReader::nextFloat () { - float result {}; - uint32_t bytes = this->nextUInt32 (); + float result; + static_assert (std::endian::native == std::endian::little, "Only little endian is supported for floats"); - memcpy (&result, &bytes, sizeof (result)); + this->m_input.read (reinterpret_cast(&result), sizeof (result)); return result; } diff --git a/src/WallpaperEngine/Render/CCamera.cpp b/src/WallpaperEngine/Render/CCamera.cpp index 0a22e29..afe481f 100644 --- a/src/WallpaperEngine/Render/CCamera.cpp +++ b/src/WallpaperEngine/Render/CCamera.cpp @@ -7,10 +7,10 @@ using namespace WallpaperEngine; using namespace WallpaperEngine::Render; CCamera::CCamera (Wallpapers::CScene& scene, const SceneData::Camera& camera) : - m_camera (camera), - m_scene (scene), m_width (0), - m_height (0) { + m_height (0), + m_camera (camera), + m_scene (scene) { // get the lookat position // TODO: ENSURE THIS IS ONLY USED WHEN NOT DOING AN ORTOGRAPHIC CAMERA AS IT THROWS OFF POINTS this->m_lookat = glm::lookAt (this->getEye (), this->getCenter (), this->getUp ()); diff --git a/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp b/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp index 5d73167..42adeb6 100644 --- a/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp +++ b/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp @@ -20,9 +20,9 @@ void CustomGLFWErrorHandler (int errorCode, const char* reason) { CGLFWOpenGLDriver::CGLFWOpenGLDriver ( const char* windowTitle, CApplicationContext& context, CWallpaperApplication& app ) : - m_mouseInput (*this), CVideoDriver (app, m_mouseInput), - m_context (context) { + m_context (context), + m_mouseInput (*this) { glfwSetErrorCallback (CustomGLFWErrorHandler); // initialize glfw diff --git a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp index 7555e9f..bcf0255 100644 --- a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp +++ b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp @@ -232,12 +232,12 @@ void CWaylandOpenGLDriver::onLayerClose (Output::CWaylandOutputViewport* viewpor } CWaylandOpenGLDriver::CWaylandOpenGLDriver (CApplicationContext& context, CWallpaperApplication& app) : - m_mouseInput (*this), CVideoDriver (app, m_mouseInput), m_output (context, *this), m_requestedExit (false), m_frameCounter (0), - m_context (context) { + m_context (context), + m_mouseInput (*this) { m_waylandContext.display = wl_display_connect (nullptr); if (!m_waylandContext.display) diff --git a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h index 27cc429..41082ac 100644 --- a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h +++ b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h @@ -22,10 +22,6 @@ class CApplicationContext; class CWallpaperApplication; } // namespace WallpaperEngine::Application -namespace WallpaperEngine::Input::Drivers { -class CWaylandMouseInput; -} - struct zwlr_layer_shell_v1; struct zwlr_layer_surface_v1; diff --git a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp index 154384b..075a832 100644 --- a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp +++ b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp @@ -40,12 +40,12 @@ CPass::CPass ( ) : Helpers::CContextAware (image), m_image (image), + m_fboProvider (std::move(fboProvider)), m_pass (pass), - m_blendingmode (pass.blending), m_binds (binds.has_value () ? binds.value ().get () : DEFAULT_BINDS), m_override (override.has_value () ? override.value ().get () : DEFAULT_OVERRIDE), - m_fboProvider (std::move(fboProvider)), - m_target (target) { + m_target (target), + m_blendingmode (pass.blending) { this->setupShaders (); } diff --git a/src/WallpaperEngine/Render/Shaders/CShader.cpp b/src/WallpaperEngine/Render/Shaders/CShader.cpp index 75e7fbe..1c5d0c3 100644 --- a/src/WallpaperEngine/Render/Shaders/CShader.cpp +++ b/src/WallpaperEngine/Render/Shaders/CShader.cpp @@ -19,17 +19,17 @@ CShader::CShader ( const TextureMap& textures, const TextureMap& overrideTextures, const ShaderConstantMap& constants ) : - m_file (std::move (filename)), - m_combos (combos), - m_overrideCombos (overrideCombos), - m_passTextures (textures), - m_overrideTextures (overrideTextures), m_vertex ( CGLSLContext::UnitType_Vertex, filename, container.readVertexShader (filename), container, constants, textures, overrideTextures, combos, overrideCombos), m_fragment ( CGLSLContext::UnitType_Fragment, filename, container.readFragmentShader (filename), - container, constants, textures, overrideTextures, combos, overrideCombos) { + container, constants, textures, overrideTextures, combos, overrideCombos), + m_file (std::move (filename)), + m_combos (combos), + m_overrideCombos (overrideCombos), + m_passTextures (textures), + m_overrideTextures (overrideTextures) { // link shaders between them this->m_vertex.linkToUnit (&this->m_fragment); this->m_fragment.linkToUnit (&this->m_vertex); diff --git a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp b/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp index 9db5623..680943a 100644 --- a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp +++ b/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp @@ -57,17 +57,15 @@ CShaderUnit::CShaderUnit ( const ComboMap& combos, const ComboMap& overrideCombos ) : m_type (type), - m_link (nullptr), - m_container (container), m_file (std::move (file)), - m_constants (constants), m_content (std::move(content)), - m_passTextures (passTextures), - m_overrideTextures (overrideTextures), m_combos (combos), m_overrideCombos (overrideCombos), - m_discoveredCombos (), - m_usedCombos () { + m_constants (constants), + m_passTextures (passTextures), + m_overrideTextures (overrideTextures), + m_link (nullptr), + m_container (container) { // pre-process the shader so the units are clear this->preprocess (); }