mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
chore: update to C++20 and take into account endianness
This commit is contained in:
parent
896cfe2c4c
commit
8012056342
@ -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}
|
||||
|
@ -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 $<$<COMPILE_LANGUAGE:C>:${CEF_COMPILER_FLAGS}>)
|
||||
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CEF_CXX_COMPILER_FLAGS}>)
|
||||
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:${CEF_COMPILER_FLAGS} ${CEF_C_COMPILER_FLAGS}>)
|
||||
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CEF_COMPILER_FLAGS} ${CEF_CXX_COMPILER_FLAGS}>)
|
||||
target_compile_options(${target} PRIVATE $<$<CONFIG:Debug>:${CEF_COMPILER_FLAGS_DEBUG} ${CEF_CXX_COMPILER_FLAGS_DEBUG}>)
|
||||
target_compile_options(${target} PRIVATE $<$<CONFIG:Release>:${CEF_COMPILER_FLAGS_RELEASE} ${CEF_CXX_COMPILER_FLAGS_RELEASE}>)
|
||||
|
||||
|
@ -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 <uint32_t> (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 <uint32_t> (0, std::min <uint32_t> (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;
|
||||
|
@ -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;
|
||||
|
@ -421,7 +421,6 @@ void CWallpaperApplication::show () {
|
||||
std::vector<uint8_t> 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 ();
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <iostream>
|
||||
#include <bit>
|
||||
|
||||
#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<char*>(&result), sizeof (result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -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 ());
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 ();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user