Compare commits

...

6 Commits

187 changed files with 1838 additions and 1844 deletions

View File

@ -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,19 +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/ITexture.h
src/WallpaperEngine/Assets/CTexture.h
src/WallpaperEngine/Assets/CTexture.cpp
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
@ -283,97 +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/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}

View File

@ -1,5 +1,5 @@
#include "FileSystem.h"
#include "WallpaperEngine/Logging/CLog.h"
#include "WallpaperEngine/Logging/Log.h"
#include <climits>
#include <cstdlib>
#include <filesystem>

View File

@ -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 <cstdlib>
#include <cstring>
@ -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;

View File

@ -7,10 +7,10 @@
#include <glm/vec4.hpp>
#include "CApplicationState.h"
#include "ApplicationState.h"
#include "WallpaperEngine/Assets/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<std::string, std::string> properties;
/** The scaling mode for different screens */
std::map<std::string, WallpaperEngine::Render::CWallpaperState::TextureUVsScaling> screenScalings;
std::map<std::string, WallpaperEngine::Render::WallpaperState::TextureUVsScaling> screenScalings;
/** The clamping mode for different screens */
std::map<std::string, TextureFlags> 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;

View File

@ -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;

View File

@ -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 <Container> ();
std::filesystem::path path (bg);
@ -48,15 +48,11 @@ ContainerUniquePtr CWallpaperApplication::setupContainer (const std::string& bg)
container->mount (path, "/");
try {
container->mount (path / "scene.pkg", "/");
} catch (std::runtime_error&) {
}
} catch (std::runtime_error&) { }
try {
container->mount (path / "gifscene.pkg", "/");
} catch (std::runtime_error&) {
}
} catch (std::runtime_error&) { }
try {
container->mount (this->m_context.settings.general.assets, "/");
@ -200,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;
}
@ -217,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
@ -241,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<const std::string, ProjectUniquePtr>& pair) -> bool {
@ -259,10 +255,10 @@ void CWallpaperApplication::setupBrowser () {
return;
}
this->m_browserContext = std::make_unique <WebBrowser::CWebBrowserContext> (*this);
this->m_browserContext = std::make_unique <WebBrowser::WebBrowserContext> (*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 ();
@ -332,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) {
@ -351,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 (),
@ -361,26 +357,26 @@ void CWallpaperApplication::setupAudio () {
);
if (audioProcessingRequired && this->m_context.settings.audio.audioprocessing) {
this->m_audioRecorder = std::make_unique <WallpaperEngine::Audio::Drivers::Recorders::CPulseAudioPlaybackRecorder> ();
this->m_audioRecorder = std::make_unique <WallpaperEngine::Audio::Drivers::Recorders::PulseAudioPlaybackRecorder> ();
} else {
this->m_audioRecorder = std::make_unique <WallpaperEngine::Audio::Drivers::Recorders::CPlaybackRecorder> ();
this->m_audioRecorder = std::make_unique <WallpaperEngine::Audio::Drivers::Recorders::PlaybackRecorder> ();
}
if (this->m_context.settings.audio.automute) {
m_audioDetector = std::make_unique <WallpaperEngine::Audio::Drivers::Detectors::CPulseAudioPlayingDetector> (this->m_context, *this->m_fullScreenDetector);
m_audioDetector = std::make_unique <WallpaperEngine::Audio::Drivers::Detectors::PulseAudioPlayingDetector> (this->m_context, *this->m_fullScreenDetector);
} else {
m_audioDetector = std::make_unique <WallpaperEngine::Audio::Drivers::Detectors::CAudioPlayingDetector> (this->m_context, *this->m_fullScreenDetector);
m_audioDetector = std::make_unique <WallpaperEngine::Audio::Drivers::Detectors::AudioPlayingDetector> (this->m_context, *this->m_fullScreenDetector);
}
// initialize sdl audio driver
m_audioDriver = std::make_unique <WallpaperEngine::Audio::Drivers::CSDLAudioDriver> (this->m_context, *this->m_audioDetector, *this->m_audioRecorder);
m_audioDriver = std::make_unique <WallpaperEngine::Audio::Drivers::SDLAudioDriver> (this->m_context, *this->m_audioDetector, *this->m_audioRecorder);
// initialize audio context
m_audioContext = std::make_unique <WallpaperEngine::Audio::CAudioContext> (*m_audioDriver);
m_audioContext = std::make_unique <WallpaperEngine::Audio::AudioContext> (*m_audioDriver);
}
void CWallpaperApplication::prepareOutputs () {
void WallpaperApplication::prepareOutputs () {
// initialize render context
m_renderContext = std::make_unique <WallpaperEngine::Render::CRenderContext> (*m_videoDriver, *this);
m_renderContext = std::make_unique <WallpaperEngine::Render::RenderContext> (*m_videoDriver, *this);
// create a new background for each screen
// set all the specific wallpapers required
@ -396,7 +392,7 @@ void CWallpaperApplication::prepareOutputs () {
}
}
void CWallpaperApplication::show () {
void WallpaperApplication::show () {
this->setupOutput ();
this->setupAudio ();
this->prepareOutputs ();
@ -502,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<std::string, ProjectUniquePtr>& CWallpaperApplication::getBackgrounds () const {
const std::map<std::string, ProjectUniquePtr>& 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 ();
}

View File

@ -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 <almamu@almamu.com>
*/
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<std::string, ProjectUniquePtr> m_backgrounds {};
std::unique_ptr <WallpaperEngine::Audio::Drivers::Detectors::CAudioPlayingDetector> m_audioDetector = nullptr;
std::unique_ptr <WallpaperEngine::Audio::CAudioContext> m_audioContext = nullptr;
std::unique_ptr <WallpaperEngine::Audio::Drivers::CSDLAudioDriver> m_audioDriver = nullptr;
std::unique_ptr <WallpaperEngine::Audio::Drivers::Recorders::CPlaybackRecorder> m_audioRecorder = nullptr;
std::unique_ptr <WallpaperEngine::Render::CRenderContext> m_renderContext = nullptr;
std::unique_ptr <WallpaperEngine::Render::Drivers::CVideoDriver> m_videoDriver = nullptr;
std::unique_ptr <WallpaperEngine::Render::Drivers::Detectors::CFullScreenDetector> m_fullScreenDetector = nullptr;
std::unique_ptr <WallpaperEngine::WebBrowser::CWebBrowserContext> m_browserContext = nullptr;
std::unique_ptr <WallpaperEngine::Audio::Drivers::Detectors::AudioPlayingDetector> m_audioDetector = nullptr;
std::unique_ptr <WallpaperEngine::Audio::AudioContext> m_audioContext = nullptr;
std::unique_ptr <WallpaperEngine::Audio::Drivers::SDLAudioDriver> m_audioDriver = nullptr;
std::unique_ptr <WallpaperEngine::Audio::Drivers::Recorders::PlaybackRecorder> m_audioRecorder = nullptr;
std::unique_ptr <WallpaperEngine::Render::RenderContext> m_renderContext = nullptr;
std::unique_ptr <WallpaperEngine::Render::Drivers::VideoDriver> m_videoDriver = nullptr;
std::unique_ptr <WallpaperEngine::Render::Drivers::Detectors::FullScreenDetector> m_fullScreenDetector = nullptr;
std::unique_ptr <WallpaperEngine::WebBrowser::WebBrowserContext> m_browserContext = nullptr;
};
} // namespace WallpaperEngine::Application

View File

@ -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 ();
}

View File

@ -4,10 +4,10 @@
#include <string>
// 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:

View File

@ -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 ();
}

View File

@ -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

View File

@ -3,35 +3,35 @@
#include <libavutil/samplefmt.h>
#include <vector>
#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

View File

@ -1,5 +1,5 @@
#include "CAudioStream.h"
#include "WallpaperEngine/Logging/CLog.h"
#include "AudioStream.h"
#include "WallpaperEngine/Logging/Log.h"
#include <cassert>
#include <cmath>
#include <iostream>
@ -10,7 +10,7 @@ using namespace WallpaperEngine::Audio;
int audio_read_thread (void* arg) {
SDL_mutex* waitMutex = SDL_CreateMutex ();
auto* stream = static_cast<CAudioStream*> (arg);
auto* stream = static_cast<AudioStream*> (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<CAudioStream*> (streamarg);
const auto stream = static_cast<AudioStream*> (streamarg);
stream->getBuffer ()->read (reinterpret_cast<std::istream::char_type*> (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<CAudioStream*> (streamarg);
const auto stream = static_cast<AudioStream*> (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;
}

View File

@ -14,7 +14,7 @@ extern "C" {
#include <SDL.h>
#include <SDL_thread.h>
#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? */

View File

@ -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

View File

@ -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

View File

@ -2,44 +2,44 @@
#include <vector>
#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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,11 +1,11 @@
#include "CPulseAudioPlayingDetector.h"
#include "WallpaperEngine/Logging/CLog.h"
#include "PulseAudioPlayingDetector.h"
#include "WallpaperEngine/Logging/Log.h"
#include <unistd.h>
namespace WallpaperEngine::Audio::Drivers::Detectors {
void sinkInputInfoCallback (pa_context* context, const pa_sink_input_info* info, int eol, void* userdata) {
auto* detector = static_cast<CPulseAudioPlayingDetector*> (userdata);
auto* detector = static_cast<PulseAudioPlayingDetector*> (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 ())

View File

@ -1,16 +1,16 @@
#pragma once
#include "CAudioPlayingDetector.h"
#include "AudioPlayingDetector.h"
#include <condition_variable>
#include <mutex>
#include <pulse/pulseaudio.h>
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;

View File

@ -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

View File

@ -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 ();

View File

@ -1,5 +1,5 @@
#include "CPulseAudioPlaybackRecorder.h"
#include "WallpaperEngine/Logging/CLog.h"
#include "PulseAudioPlaybackRecorder.h"
#include "WallpaperEngine/Logging/Log.h"
#include <cmath>
#include <cstring>
#include <glm/common.hpp>
@ -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<CPulseAudioPlaybackRecorder::SPulseAudioData*> (userdata);
auto* recorder = static_cast<PulseAudioPlaybackRecorder::PulseAudioData*> (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<CPulseAudioPlaybackRecorder::SPulseAudioData*> (userdata);
auto* recorder = static_cast<PulseAudioPlaybackRecorder::PulseAudioData*> (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

View File

@ -1,20 +1,20 @@
#pragma once
#include "PlaybackRecorder.h"
#include "kiss_fftr.h"
#include "CPlaybackRecorder.h"
#include <pulse/pulseaudio.h>
#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};

View File

@ -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<CSDLAudioDriver*> (userdata);
auto* driver = static_cast<SDLAudioDriver*> (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<CSDLAudioBuffer*>& CSDLAudioDriver::getStreams () {
const std::vector<SDLAudioBuffer*>& 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;
}

View File

@ -3,8 +3,8 @@
#include <map>
#include <vector>
#include "WallpaperEngine/Audio/CAudioStream.h"
#include "WallpaperEngine/Audio/Drivers/CAudioDriver.h"
#include "WallpaperEngine/Audio/AudioStream.h"
#include "WallpaperEngine/Audio/Drivers/AudioDriver.h"
#include <SDL.h>
@ -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<CSDLAudioBuffer*>& getStreams ();
const std::vector<SDLAudioBuffer*>& 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<CSDLAudioBuffer*> m_streams {};
std::vector<SDLAudioBuffer*> m_streams {};
};
} // namespace WallpaperEngine::Audio::Drivers

View File

@ -5,8 +5,8 @@
#include <glm/detail/qualifier.hpp>
#include <glm/detail/type_vec1.hpp>
#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;

View File

@ -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;

View File

@ -9,13 +9,13 @@
using namespace WallpaperEngine::Data::Parsers;
using namespace WallpaperEngine::Data::Model;
EffectUniquePtr EffectParser::load (Project& project, const std::string& filename) {
EffectUniquePtr EffectParser::load (const Project& project, const std::string& filename) {
const auto effectJson = JSON::parse (project.container->readString (filename));
return parse (effectJson, project);
}
EffectUniquePtr EffectParser::parse (const JSON& it, Project& project) {
EffectUniquePtr EffectParser::parse (const JSON& it, const Project& project) {
const auto dependencies = it.optional ("dependencies");
const auto fbos = it.optional ("fbos");
@ -44,7 +44,7 @@ std::vector <std::string> EffectParser::parseDependencies (const JSON& it) {
return result;
}
std::vector <EffectPassUniquePtr> EffectParser::parseEffectPasses (const JSON& it, Project& project) {
std::vector <EffectPassUniquePtr> EffectParser::parseEffectPasses (const JSON& it, const Project& project) {
std::vector <EffectPassUniquePtr> result = {};
if (!it.is_array ()) {

View File

@ -9,12 +9,12 @@ using namespace WallpaperEngine::Data::Model;
class EffectParser {
public:
static EffectUniquePtr load (Project& project, const std::string& filename);
static EffectUniquePtr load (const Project& project, const std::string& filename);
private:
static EffectUniquePtr parse (const JSON& it, Project& project);
static EffectUniquePtr parse (const JSON& it, const Project& project);
static std::vector <std::string> parseDependencies (const JSON& it);
static std::vector <EffectPassUniquePtr> parseEffectPasses (const JSON& it, Project& project);
static std::vector <EffectPassUniquePtr> parseEffectPasses (const JSON& it, const Project& project);
static std::map <int, std::string> parseBinds (const JSON& it);
static std::vector <FBOUniquePtr> parseFBOs (const JSON& it);
};

View File

@ -7,20 +7,20 @@
using namespace WallpaperEngine::Data::Parsers;
using namespace WallpaperEngine::Data::Model;
MaterialUniquePtr MaterialParser::load (Project& project, const std::string& filename) {
MaterialUniquePtr MaterialParser::load (const Project& project, const std::string& filename) {
const auto materialJson = JSON::parse (project.container->readString (filename));
return parse (materialJson, project, filename);
return parse (materialJson, filename);
}
MaterialUniquePtr MaterialParser::parse (const JSON& it, Project& project, const std::string& filename) {
MaterialUniquePtr MaterialParser::parse (const JSON& it, const std::string& filename) {
return std::make_unique <Material> (Material {
.filename = filename,
.passes = parsePasses (it.require ("passes", "Material must have passes to render"), project),
.passes = parsePasses (it.require ("passes", "Material must have passes to render")),
});
}
std::vector <MaterialPassUniquePtr> MaterialParser::parsePasses (const JSON& it, Project& project) {
std::vector <MaterialPassUniquePtr> MaterialParser::parsePasses (const JSON& it) {
std::vector <MaterialPassUniquePtr> result = {};
if (!it.is_array ()) {
@ -28,13 +28,13 @@ std::vector <MaterialPassUniquePtr> MaterialParser::parsePasses (const JSON& it,
}
for (const auto& cur : it) {
result.push_back (parsePass (cur, project));
result.push_back (parsePass (cur));
}
return result;
}
MaterialPassUniquePtr MaterialParser::parsePass (const JSON& it, Project& project) {
MaterialPassUniquePtr MaterialParser::parsePass (const JSON& it) {
const auto textures = it.optional ("textures");
const auto usertextures = it.optional ("usertextures");
const auto combos = it.optional ("combos");

View File

@ -10,10 +10,10 @@ using namespace WallpaperEngine::Data::Model;
class MaterialParser {
public:
static MaterialUniquePtr load (Project& project, const std::string& filename);
static MaterialUniquePtr parse (const JSON& it, Project& project, const std::string& filename);
static std::vector <MaterialPassUniquePtr> parsePasses (const JSON& it, Project& project);
static MaterialPassUniquePtr parsePass (const JSON& it, Project& project);
static MaterialUniquePtr load (const Project& project, const std::string& filename);
static MaterialUniquePtr parse (const JSON& it, const std::string& filename);
static std::vector <MaterialPassUniquePtr> parsePasses (const JSON& it);
static MaterialPassUniquePtr parsePass (const JSON& it);
static std::map <int, std::string> parseTextures (const JSON& it);
static std::map <std::string, int> parseCombos (const JSON& it);
static BlendingMode parseBlendMode (const std::string& mode);

View File

@ -9,13 +9,13 @@
using namespace WallpaperEngine::Data::Parsers;
using namespace WallpaperEngine::Data::Model;
ModelUniquePtr ModelParser::load (Project& project, const std::string& filename) {
ModelUniquePtr ModelParser::load (const Project& project, const std::string& filename) {
const auto model = JSON::parse (project.container->readString (filename));
return parse (model, project, filename);
}
ModelUniquePtr ModelParser::parse (const JSON& file, Project& project, const std::string& filename) {
ModelUniquePtr ModelParser::parse (const JSON& file, const Project& project, const std::string& filename) {
const auto material = file.require <std::string> ("material", "Model must have a material");
return std::make_unique <ModelStruct> (ModelStruct {

View File

@ -9,7 +9,7 @@ using namespace WallpaperEngine::Data::Model;
class ModelParser {
public:
static ModelUniquePtr load (Project& project, const std::string& filename);
static ModelUniquePtr parse (const JSON& file, Project& project, const std::string& filename);
static ModelUniquePtr load (const Project& project, const std::string& filename);
static ModelUniquePtr parse (const JSON& file, const Project& project, const std::string& filename);
};
} // namespace WallpaperEngine::Data::Parsers

View File

@ -5,12 +5,12 @@
#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;
ObjectUniquePtr ObjectParser::parse (const JSON& it, Project& project) {
ObjectUniquePtr ObjectParser::parse (const JSON& it, const Project& project) {
const auto imageIt = it.find ("image");
const auto soundIt = it.find ("sound");
const auto particleIt = it.find ("particle");
@ -25,7 +25,7 @@ ObjectUniquePtr ObjectParser::parse (const JSON& it, Project& project) {
if (imageIt != it.end () && imageIt->is_string ()) {
return parseImage (it, project, basedata, *imageIt);
} else if (soundIt != it.end () && soundIt->is_array ()) {
return parseSound (it, project, basedata);
return parseSound (it, basedata);
} else if (particleIt != it.end ()) {
sLog.error ("Particle objects are not supported yet");
} else if (textIt != it.end ()) {
@ -56,7 +56,7 @@ std::vector<int> ObjectParser::parseDependencies (const JSON& it) {
return result;
}
SoundUniquePtr ObjectParser::parseSound (const JSON& it, Project& project, ObjectData base) {
SoundUniquePtr ObjectParser::parseSound (const JSON& it, ObjectData base) {
const auto soundIt = it.require ("sound", "Object must have a sound");
std::vector<std::string> sounds = {};
@ -73,8 +73,7 @@ SoundUniquePtr ObjectParser::parseSound (const JSON& it, Project& project, Objec
);
}
ImageUniquePtr ObjectParser::parseImage (
const JSON& it, Project& project, ObjectData base, const std::string& image) {
ImageUniquePtr ObjectParser::parseImage (const JSON& it, const Project& project, ObjectData base, const std::string& image) {
const auto& properties = project.properties;
const auto& effects = it.optional ("effects");
@ -107,7 +106,7 @@ ImageUniquePtr ObjectParser::parseImage (
return result;
}
std::vector <ImageEffectUniquePtr> ObjectParser::parseEffects (const JSON& it, Project& project) {
std::vector <ImageEffectUniquePtr> ObjectParser::parseEffects (const JSON& it, const Project& project) {
if (!it.is_array ()) {
return {};
}
@ -121,7 +120,7 @@ std::vector <ImageEffectUniquePtr> ObjectParser::parseEffects (const JSON& it, P
return result;
}
ImageEffectUniquePtr ObjectParser::parseEffect (const JSON& it, Project& project) {
ImageEffectUniquePtr ObjectParser::parseEffect (const JSON& it, const Project& project) {
const auto& passsOverrides = it.optional ("passes");
return std::make_unique <ImageEffect> (ImageEffect {
.id = it.optional <int> ("id", -1),
@ -132,7 +131,7 @@ ImageEffectUniquePtr ObjectParser::parseEffect (const JSON& it, Project& project
});
}
std::vector <ImageEffectPassOverrideUniquePtr> ObjectParser::parseEffectPassOverrides (const JSON& it, Project& project) {
std::vector <ImageEffectPassOverrideUniquePtr> ObjectParser::parseEffectPassOverrides (const JSON& it, const Project& project) {
if (!it.is_array ()) {
return {};
}
@ -146,7 +145,7 @@ std::vector <ImageEffectPassOverrideUniquePtr> ObjectParser::parseEffectPassOver
return result;
}
ImageEffectPassOverrideUniquePtr ObjectParser::parseEffectPass (const JSON& it, Project& project) {
ImageEffectPassOverrideUniquePtr ObjectParser::parseEffectPass (const JSON& it, const Project& project) {
const auto& combos = it.optional ("combos");
const auto& textures = it.optional ("textures");
const auto& constants = it.optional ("constantshadervalues");

View File

@ -15,17 +15,16 @@ using namespace WallpaperEngine::Data::Model;
class ObjectParser {
public:
static ObjectUniquePtr parse (const JSON& it, Project& project);
static ObjectUniquePtr parse (const JSON& it, const Project& project);
private:
static std::vector<int> parseDependencies (const JSON& it);
static SoundUniquePtr parseSound (const JSON& it, Project& project, ObjectData base);
static ImageUniquePtr parseImage (
const JSON& it, Project& project, ObjectData base, const std::string& image);
static std::vector <ImageEffectUniquePtr> parseEffects (const JSON& it, Project& project);
static ImageEffectUniquePtr parseEffect (const JSON& it, Project& project);
static std::vector <ImageEffectPassOverrideUniquePtr> parseEffectPassOverrides (const JSON& it, Project& project);
static ImageEffectPassOverrideUniquePtr parseEffectPass (const JSON& it, Project& project);
static SoundUniquePtr parseSound (const JSON& it, ObjectData base);
static ImageUniquePtr parseImage (const JSON& it, const Project& project, ObjectData base, const std::string& image);
static std::vector <ImageEffectUniquePtr> parseEffects (const JSON& it, const Project& project);
static ImageEffectUniquePtr parseEffect (const JSON& it, const Project& project);
static std::vector <ImageEffectPassOverrideUniquePtr> parseEffectPassOverrides (const JSON& it, const Project& project);
static ImageEffectPassOverrideUniquePtr parseEffectPass (const JSON& it, const Project& project);
static TextureMap parseTextureMap (const JSON& it);
static ComboMap parseComboMap (const JSON& it);
};

View File

@ -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"

View File

@ -1,7 +1,7 @@
#include <algorithm>
#include "ProjectParser.h"
#include "WallpaperEngine/Logging/CLog.h"
#include "WallpaperEngine/Logging/Log.h"
#include "WallpaperParser.h"

View File

@ -4,7 +4,7 @@
using namespace WallpaperEngine::Data::Parsers;
using namespace WallpaperEngine::Data::Model;
PropertySharedPtr PropertyParser::parse (const JSON& it, std::string name) {
PropertySharedPtr PropertyParser::parse (const JSON& it, const std::string& name) {
const auto type = it.require <std::string> ("type", "Property type is required");
if (type == "color") {
@ -36,7 +36,7 @@ PropertySharedPtr PropertyParser::parse (const JSON& it, std::string name) {
}
PropertySharedPtr PropertyParser::parseCombo (const JSON& it, std::string name) {
PropertySharedPtr PropertyParser::parseCombo (const JSON& it, const std::string& name) {
std::map <std::string, std::string> optionsMap = {};
const auto options = it.require ("options", "Combo property must have options");
@ -68,21 +68,21 @@ PropertySharedPtr PropertyParser::parseCombo (const JSON& it, std::string name)
}, value.is_number () ? std::to_string (value.get <int> ()) : value.get <std::string> ());
}
PropertySharedPtr PropertyParser::parseColor (const JSON& it, std::string name) {
PropertySharedPtr PropertyParser::parseColor (const JSON& it, const std::string& name) {
return std::make_shared <PropertyColor> (PropertyData {
.name = name,
.text = it.optional <std::string> ("text", ""),
}, it.require ("value", "Property must have a value"));
}
PropertySharedPtr PropertyParser::parseBoolean (const JSON& it, std::string name) {
PropertySharedPtr PropertyParser::parseBoolean (const JSON& it, const std::string& name) {
return std::make_shared <PropertyBoolean> (PropertyData {
.name = name,
.text = it.optional <std::string> ("text", ""),
}, it.require ("value", "Property must have a value"));
}
PropertySharedPtr PropertyParser::parseSlider (const JSON& it, std::string name) {
PropertySharedPtr PropertyParser::parseSlider (const JSON& it, const std::string& name) {
return std::make_shared <PropertySlider> (PropertyData {
.name = name,
.text = it.optional <std::string> ("text", ""),
@ -93,14 +93,14 @@ PropertySharedPtr PropertyParser::parseSlider (const JSON& it, std::string name)
}, it.require ("value", "Property must have a value"));
}
PropertySharedPtr PropertyParser::parseText (const JSON& it, std::string name) {
PropertySharedPtr PropertyParser::parseText (const JSON& it, const std::string& name) {
return std::make_shared <PropertyText> (PropertyData {
.name = name,
.text = it.optional <std::string> ("text", ""),
});
}
PropertySharedPtr PropertyParser::parseSceneTexture (const JSON& it, std::string name) {
PropertySharedPtr PropertyParser::parseSceneTexture (const JSON& it, const std::string& name) {
return std::make_shared <PropertySceneTexture> (PropertyData {
.name = name,
.text = it.optional <std::string> ("text", ""),

View File

@ -8,14 +8,14 @@ using namespace WallpaperEngine::Data::Model;
class PropertyParser {
public:
static PropertySharedPtr parse (const JSON& it, std::string name);
static PropertySharedPtr parse (const JSON& it, const std::string& name);
private:
static PropertySharedPtr parseCombo (const JSON& it, std::string name);
static PropertySharedPtr parseColor (const JSON& it, std::string name);
static PropertySharedPtr parseBoolean (const JSON& it, std::string name);
static PropertySharedPtr parseSlider (const JSON& it, std::string name);
static PropertySharedPtr parseText (const JSON& it, std::string name);
static PropertySharedPtr parseSceneTexture (const JSON& it, std::string name);
static PropertySharedPtr parseCombo (const JSON& it, const std::string& name);
static PropertySharedPtr parseColor (const JSON& it, const std::string& name);
static PropertySharedPtr parseBoolean (const JSON& it, const std::string& name);
static PropertySharedPtr parseSlider (const JSON& it, const std::string& name);
static PropertySharedPtr parseText (const JSON& it, const std::string& name);
static PropertySharedPtr parseSceneTexture (const JSON& it, const std::string& name);
};
}

View File

@ -6,7 +6,7 @@
using namespace WallpaperEngine::Data::Parsers;
using namespace WallpaperEngine::Data::Model;
ShaderConstantMap ShaderConstantParser::parse (const JSON& it, Project& project) {
ShaderConstantMap ShaderConstantParser::parse (const JSON& it, const Project& project) {
if (!it.is_object ()) {
return {};
}

View File

@ -9,6 +9,6 @@ using namespace WallpaperEngine::Data::Model;
class ShaderConstantParser {
public:
static ShaderConstantMap parse (const JSON& it, Project& project);
static ShaderConstantMap parse (const JSON& it, const Project& project);
};
} // namespace WallpaperEngine::Data::Parsers

View File

@ -4,62 +4,16 @@
#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;
TextureUniquePtr TextureParser::parse (BinaryReader& file) {
char magic[9] = { 0 };
file.next (magic, 9);
if (strncmp (magic, "TEXV0005", 9) != 0)
sLog.exception ("unexpected texture container type: ", std::string_view (magic, 9));
file.next (magic, 9);
if (strncmp (magic, "TEXI0001", 9) != 0)
sLog.exception ("unexpected texture sub-container type: ", std::string_view (magic, 9));
TextureUniquePtr TextureParser::parse (const BinaryReader& file) {
auto result = std::make_unique<Texture> ();
result->format = parseTextureFormat (file.nextUInt32 ());
result->flags = parseTextureFlags (file.nextUInt32 ());
result->textureWidth = file.nextUInt32 ();
result->textureHeight = file.nextUInt32 ();
result->width = file.nextUInt32 ();
result->height = file.nextUInt32 ();
// ignore some more bytes
std::ignore = file.nextUInt32 ();
file.next (magic, 9);
result->imageCount = file.nextUInt32 ();
if (strncmp (magic, "TEXB0004", 9) == 0) {
result->containerVersion = ContainerVersion_TEXB0004;
result->freeImageFormat = parseFIF (file.nextUInt32 ());
result->isVideoMp4 = file.nextUInt32 () == 1;
if (result->freeImageFormat == FIF_UNKNOWN && result->isVideoMp4) {
result->freeImageFormat = FIF_MP4;
}
// default to TEXB0003 format here
if (result->freeImageFormat != FIF_MP4) {
result->containerVersion = ContainerVersion_TEXB0003;
}
} else if (strncmp (magic, "TEXB0003", 9) == 0) {
result->containerVersion = ContainerVersion_TEXB0003;
result->freeImageFormat = parseFIF (file.nextUInt32 ());
} else if (strncmp (magic, "TEXB0002", 9) == 0) {
result->containerVersion = ContainerVersion_TEXB0002;
} else if (strncmp (magic, "TEXB0001", 9) == 0) {
result->containerVersion = ContainerVersion_TEXB0001;
} else {
sLog.exception ("unknown texture format type: ", std::string_view (magic, 9));
}
parseTextureHeader (*result, file);
parseContainer (*result, file);
for (uint32_t image = 0; image < result->imageCount; image++) {
uint32_t mipmapCount = file.nextUInt32 ();
@ -76,38 +30,12 @@ TextureUniquePtr TextureParser::parse (BinaryReader& file) {
return result;
}
// image is animated, keep parsing the rest of the image info
file.next (magic, 9);
if (strncmp (magic, "TEXS0002", 9) == 0) {
result->animatedVersion = AnimatedVersion_TEXS0002;
} else if (strncmp (magic, "TEXS0003", 9) == 0) {
result->animatedVersion = AnimatedVersion_TEXS0003;
} else {
sLog.exception ("found animation information of unknown type: ", std::string_view (magic, 9));
}
uint32_t frameCount = file.nextUInt32 ();
if (result->animatedVersion == AnimatedVersion_TEXS0003) {
result->gifWidth = file.nextUInt32 ();
result->gifHeight = file.nextUInt32 ();
}
while (frameCount-- > 0) {
result->frames.push_back (parseFrame (file, *result));
}
// ensure gif width and height is right for TEXS0002
if (result->animatedVersion == AnimatedVersion_TEXS0002) {
result->gifWidth = (*result->frames.begin ())->width1;
result->gifHeight = (*result->frames.begin ())->height1;
}
parseAnimations (*result, file);
return result;
}
MipmapSharedPtr TextureParser::parseMipmap (BinaryReader& file, Texture& header) {
MipmapSharedPtr TextureParser::parseMipmap (const BinaryReader& file, const Texture& header) {
auto result = std::make_shared<Mipmap> ();
// TEXB0004 has some extra data in the header that has to be handled
@ -162,7 +90,7 @@ MipmapSharedPtr TextureParser::parseMipmap (BinaryReader& file, Texture& header)
return result;
}
FrameSharedPtr TextureParser::parseFrame (BinaryReader& file, Texture& header) {
FrameSharedPtr TextureParser::parseFrame (const BinaryReader& file) {
auto result = std::make_shared<Frame> ();
result->frameNumber = file.nextUInt32 ();
@ -201,6 +129,95 @@ TextureFormat TextureParser::parseTextureFormat (uint32_t value) {
}
}
void TextureParser::parseTextureHeader (Texture& header, const BinaryReader& file) {
char magic[9] = { 0 };
file.next (magic, 9);
if (strncmp (magic, "TEXV0005", 9) != 0)
sLog.exception ("unexpected texture container type: ", std::string_view (magic, 9));
file.next (magic, 9);
if (strncmp (magic, "TEXI0001", 9) != 0)
sLog.exception ("unexpected texture sub-container type: ", std::string_view (magic, 9));
header.format = parseTextureFormat (file.nextUInt32 ());
header.flags = parseTextureFlags (file.nextUInt32 ());
header.textureWidth = file.nextUInt32 ();
header.textureHeight = file.nextUInt32 ();
header.width = file.nextUInt32 ();
header.height = file.nextUInt32 ();
// ignore some more bytes
std::ignore = file.nextUInt32 ();
}
void TextureParser::parseContainer (Texture& header, const BinaryReader& file) {
char magic[9] = { 0 };
file.next (magic, 9);
header.imageCount = file.nextUInt32 ();
if (strncmp (magic, "TEXB0004", 9) == 0) {
header.containerVersion = ContainerVersion_TEXB0004;
header.freeImageFormat = parseFIF (file.nextUInt32 ());
header.isVideoMp4 = file.nextUInt32 () == 1;
if (header.freeImageFormat == FIF_UNKNOWN && header.isVideoMp4) {
header.freeImageFormat = FIF_MP4;
}
// default to TEXB0003 format here
if (header.freeImageFormat != FIF_MP4) {
header.containerVersion = ContainerVersion_TEXB0003;
}
} else if (strncmp (magic, "TEXB0003", 9) == 0) {
header.containerVersion = ContainerVersion_TEXB0003;
header.freeImageFormat = parseFIF (file.nextUInt32 ());
} else if (strncmp (magic, "TEXB0002", 9) == 0) {
header.containerVersion = ContainerVersion_TEXB0002;
} else if (strncmp (magic, "TEXB0001", 9) == 0) {
header.containerVersion = ContainerVersion_TEXB0001;
} else {
sLog.exception ("unknown texture format type: ", std::string_view (magic, 9));
}
}
void TextureParser::parseAnimations (Texture& header, const BinaryReader& file) {
char magic[9] = { 0 };
// image is animated, keep parsing the rest of the image info
file.next (magic, 9);
if (strncmp (magic, "TEXS0002", 9) == 0) {
header.animatedVersion = AnimatedVersion_TEXS0002;
} else if (strncmp (magic, "TEXS0003", 9) == 0) {
header.animatedVersion = AnimatedVersion_TEXS0003;
} else {
sLog.exception ("found animation information of unknown type: ", std::string_view (magic, 9));
}
uint32_t frameCount = file.nextUInt32 ();
if (header.animatedVersion == AnimatedVersion_TEXS0003) {
header.gifWidth = file.nextUInt32 ();
header.gifHeight = file.nextUInt32 ();
}
while (frameCount-- > 0) {
header.frames.push_back (parseFrame (file));
}
// ensure gif width and height is right for TEXS0002
if (header.animatedVersion == AnimatedVersion_TEXS0002) {
header.gifWidth = (*header.frames.begin ())->width1;
header.gifHeight = (*header.frames.begin ())->height1;
}
}
uint32_t TextureParser::parseTextureFlags (uint32_t value) {
if (value < TextureFlags_All) {
return value;

View File

@ -13,11 +13,14 @@ using namespace WallpaperEngine::Data::Assets;
class TextureParser {
public:
static TextureUniquePtr parse (BinaryReader& file);
static MipmapSharedPtr parseMipmap (BinaryReader& file, Texture& header);
static FrameSharedPtr parseFrame (BinaryReader& file, Texture& header);
static TextureUniquePtr parse (const BinaryReader& file);
static MipmapSharedPtr parseMipmap (const BinaryReader& file, const Texture& header);
static FrameSharedPtr parseFrame (const BinaryReader& file);
private:
static void parseTextureHeader (Texture& header, const BinaryReader& file);
static void parseContainer (Texture& header, const BinaryReader& file);
static void parseAnimations (Texture& header, const BinaryReader& file);
static TextureFormat parseTextureFormat (uint32_t value);
static uint32_t parseTextureFlags (uint32_t value);
static FIF parseFIF (uint32_t value);

View File

@ -53,11 +53,11 @@ UserSettingUniquePtr UserSettingParser::parse (const json& data, const Propertie
//TODO: VALIDATE THIS IS RIGHT?
if (size == 2) {
value->update ((glm::vec2) valueIt);
value->update (static_cast<glm::vec2> (valueIt));
} else if (size == 3) {
value->update ((glm::vec3) valueIt);
value->update (static_cast<glm::vec3> (valueIt));
} else {
value->update ((glm::vec4) valueIt);
value->update (static_cast<glm::vec4> (valueIt));
}
} else if (valueIt.is_number_integer ()) {
value->update (valueIt.get <int> ());

View File

@ -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;

View File

@ -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;
@ -92,15 +92,11 @@ WebUniquePtr WallpaperParser::parseWeb (const JSON& file, Project& project) {
});
}
ObjectList WallpaperParser::parseObjects (const JSON& objects, Project& project) {
ObjectList WallpaperParser::parseObjects (const JSON& objects, const Project& project) {
ObjectList result = {};
for (const auto& cur : objects) {
auto object = ObjectParser::parse (cur, project);
//TODO: DO WE REALLY WANT TO DIRECTLY CONSTRUCT UNIQUE AND SHARED PTRS EVERYWHERE?
// SHOULDN'T THAT BE HANDLED BY CALLING CODE (LIKE THIS) INSTEAD?
result.emplace_back (std::move (object));
result.emplace_back (ObjectParser::parse (cur, project));
}
return result;

View File

@ -15,6 +15,6 @@ class WallpaperParser {
static SceneUniquePtr parseScene (const JSON& file, Project& project);
static VideoUniquePtr parseVideo (const JSON& file, Project& project);
static WebUniquePtr parseWeb (const JSON& file, Project& project);
static ObjectList parseObjects (const JSON& objects, Project& project);
static ObjectList parseObjects (const JSON& objects, const Project& project);
};
} // namespace WallpaperEngine::Data::Parsers

View File

@ -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;
@ -53,11 +53,11 @@ bool DirectoryAdapter::exists (const std::filesystem::path& path) const {
}
}
std::filesystem::path DirectoryAdapter::realpath (const std::filesystem::path& path) const {
std::filesystem::path DirectoryAdapter::physicalPath (const std::filesystem::path& path) const {
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;

View File

@ -18,7 +18,7 @@ struct DirectoryAdapter final : Adapter {
[[nodiscard]] ReadStreamSharedPtr open (const std::filesystem::path& path) const override;
[[nodiscard]] bool exists (const std::filesystem::path& path) const override;
[[nodiscard]] std::filesystem::path realpath (const std::filesystem::path& path) const override;
[[nodiscard]] std::filesystem::path physicalPath (const std::filesystem::path& path) const override;
const std::filesystem::path basepath;
};

View File

@ -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"
@ -44,8 +44,8 @@ bool PackageAdapter::exists (const std::filesystem::path& path) const {
return false;
}
std::filesystem::path PackageAdapter::realpath (const std::filesystem::path& path) const {
throw Assets::CAssetLoadException ("Package adapter does not support realpath", path);
std::filesystem::path PackageAdapter::physicalPath (const std::filesystem::path& path) const {
throw Render::AssetLoadException ("Package adapter does not support realpath", path);
}
bool PackageFactory::handlesMountpoint (const std::filesystem::path& path) const {

View File

@ -22,7 +22,7 @@ struct PackageAdapter final : Adapter {
[[nodiscard]] ReadStreamSharedPtr open (const std::filesystem::path& path) const override;
[[nodiscard]] bool exists (const std::filesystem::path& path) const override;
[[nodiscard]] std::filesystem::path realpath (const std::filesystem::path& path) const override;
[[nodiscard]] std::filesystem::path physicalPath (const std::filesystem::path& path) const override;
PackageUniquePtr package;
};

View File

@ -11,7 +11,7 @@ struct Adapter {
[[nodiscard]] virtual ReadStreamSharedPtr open (const std::filesystem::path& path) const = 0;
[[nodiscard]] virtual bool exists (const std::filesystem::path& path) const = 0;
[[nodiscard]] virtual std::filesystem::path realpath (const std::filesystem::path& path) const = 0;
[[nodiscard]] virtual std::filesystem::path physicalPath (const std::filesystem::path& path) const = 0;
};
using AdapterSharedPtr = std::shared_ptr<Adapter>;

View File

@ -1,6 +1,6 @@
#include "Virtual.h"
#include "WallpaperEngine/Assets/CAssetLoadException.h"
#include "WallpaperEngine/Assets/AssetLoadException.h"
#include <cstring>
@ -21,8 +21,8 @@ bool VirtualAdapter::exists (const std::filesystem::path& path) const {
return this->files.contains (path);
}
std::filesystem::path VirtualAdapter::realpath (const std::filesystem::path& path) const {
throw Assets::CAssetLoadException ("Virtual adapter does not support realpath", path);
std::filesystem::path VirtualAdapter::physicalPath (const std::filesystem::path& path) const {
throw Render::AssetLoadException ("Virtual adapter does not support realpath", path);
}

View File

@ -20,7 +20,7 @@ struct VirtualFactory final : Factory {
struct VirtualAdapter final : Adapter {
[[nodiscard]] ReadStreamSharedPtr open (const std::filesystem::path& path) const override;
[[nodiscard]] bool exists (const std::filesystem::path& path) const override;
[[nodiscard]] std::filesystem::path realpath (const std::filesystem::path& path) const override;
[[nodiscard]] std::filesystem::path physicalPath (const std::filesystem::path& path) const override;
void add (const std::filesystem::path& path, const char* data);
void add (const std::filesystem::path& path, const JSON& contents);

View File

@ -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<PackageFactory> ());
this->m_factories.push_back (std::make_unique<DirectoryFactory> ());
// TODO: FIND A BETTER WAY OF MOUNTING THE VIRTUAL FILESYSTEM
this->m_vfs = std::make_shared<VirtualAdapter> ();
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 {
@ -76,10 +75,10 @@ std::string Container::readString (const std::filesystem::path& path) const {
return buffer.str ();
}
std::filesystem::path Container::realpath (const std::filesystem::path& path) const {
std::filesystem::path normalized = normalize_path (path);
std::filesystem::path Container::physicalPath (const std::filesystem::path& path) const {
const auto normalized = normalize_path (path);
return this->resolveAdapterForFile (path).realpath (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);
}

View File

@ -38,7 +38,7 @@ class Container {
* @param path The path to resolve to a real file
* @return The full public, absolute path to the given file
*/
[[nodiscard]] std::filesystem::path realpath (const std::filesystem::path& path) const;
[[nodiscard]] std::filesystem::path physicalPath (const std::filesystem::path& path) const;
/**
*

View File

@ -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;
}

View File

@ -1,14 +1,14 @@
#include "CGLFWMouseInput.h"
#include "GLFWMouseInput.h"
#include <glm/common.hpp>
#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;
}

View File

@ -1,20 +1,20 @@
#pragma once
#include "WallpaperEngine/Input/CMouseInput.h"
#include "WallpaperEngine/Input/MouseInput.h"
#include <glm/vec2.hpp>
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

View File

@ -1,15 +1,15 @@
#include "WaylandMouseInput.h"
#include "WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.h"
#include <glm/common.hpp>
#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;

View File

@ -2,21 +2,21 @@
#ifdef ENABLE_WAYLAND
#include "WallpaperEngine/Input/CMouseInput.h"
#include "WallpaperEngine/Input/MouseInput.h"
#include <glm/vec2.hpp>
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 = {};
};

View File

@ -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;
}

View File

@ -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

View File

@ -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
*/
@ -33,6 +33,5 @@ class CMouseInput {
* @return The status of the mouse's right click
*/
[[nodiscard]] virtual MouseClickStatus rightClick () const = 0;
};
} // namespace WallpaperEngine::Input

View File

@ -1,28 +1,28 @@
#include "CLog.h"
#include "Log.h"
#include <cassert>
#include <memory>
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<CLog> ();
sInstance = std::make_unique<Log> ();
}
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> CLog::sInstance = nullptr;
std::unique_ptr<Log> Log::sInstance = nullptr;

View File

@ -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<std::runtime_error> (data...);
}
static CLog& get ();
static Log& get ();
private:
template <typename... Data> std::string buildBuffer (Data... data) {
@ -82,8 +82,8 @@ class CLog {
std::vector<std::ostream*> mOutputs = {};
std::vector<std::ostream*> mErrors = {};
static std::unique_ptr<CLog> sInstance;
static std::unique_ptr<Log> sInstance;
};
} // namespace WallpaperEngine::Logging
#define sLog (WallpaperEngine::Logging::CLog::get ())
#define sLog (WallpaperEngine::Logging::Log::get ())

View File

@ -1,5 +1,5 @@
#include "CFBO.h"
#include "WallpaperEngine/Logging/CLog.h"
#include "WallpaperEngine/Logging/Log.h"
using namespace WallpaperEngine::Render;

View File

@ -2,12 +2,12 @@
#include <string>
#include "WallpaperEngine/Assets/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);

View File

@ -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) {}

View File

@ -2,7 +2,7 @@
#include <string>
#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 <class T> [[nodiscard]] const T* as () const {
if (is <T> ()) {

View File

@ -1,58 +0,0 @@
#pragma once
#include <glm/vec4.hpp>
#include <vector>
#include <memory>
#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 <CWallpaper> 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<const ITexture> resolveTexture (const std::string& name);
[[nodiscard]] const std::map<std::string, std::shared_ptr <CWallpaper>>& getWallpapers () const;
private:
/** Video driver in use */
Drivers::CVideoDriver& m_driver;
/** Maps screen -> wallpaper list */
std::map<std::string, std::shared_ptr <CWallpaper>> m_wallpapers = {};
/** App that holds the render context */
CWallpaperApplication& m_app;
/** Texture cache for the render */
CTextureCache* m_textureCache = nullptr;
};
} // namespace Render
} // namespace WallpaperEngine

View File

@ -1,5 +1,5 @@
#include "CTexture.h"
#include "WallpaperEngine/Logging/CLog.h"
#include "WallpaperEngine/Logging/Log.h"
#include <cstring>
#include <lz4.h>
@ -8,7 +8,7 @@
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
using namespace WallpaperEngine::Assets;
using namespace WallpaperEngine::Render;
CTexture::CTexture (TextureUniquePtr header) : m_header (std::move(header)) {
// ensure the header is parsed

View File

@ -1,23 +1,20 @@
#pragma once
#include "ITexture.h"
#include "TextureProvider.h"
#include "WallpaperEngine/Data/Assets/Texture.h"
#include <GL/glew.h>
#include <glm/vec4.hpp>
#include <map>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
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);

View File

@ -1,45 +0,0 @@
#pragma once
#include <map>
#include <string>
#include <memory>
#include "WallpaperEngine/Assets/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<const ITexture> resolve (const std::string& filename);
/**
* Registers a texture in the cache
*
* @param name
* @param texture
*/
void store (const std::string& name, std::shared_ptr<const ITexture> texture);
private:
/** Cached textures */
std::map<std::string, std::shared_ptr<const ITexture>> m_textureCache = {};
};
} // namespace WallpaperEngine::Render

View File

@ -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<const CFBO> CWallpaper::getFBO () const {
}
std::unique_ptr<CWallpaper> 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<Scene> ()) {

View File

@ -3,32 +3,32 @@
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#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 <class T> [[nodiscard]] const T* as () const {
if (is <T> ()) {
@ -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<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);
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<std::string, std::shared_ptr<const CFBO>> 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

View File

@ -1,12 +1,12 @@
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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 () {}

View File

@ -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 () {}

View File

@ -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

View File

@ -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 <cstring>
@ -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<CWaylandFullScreenDetector*> (data);
const auto detector = static_cast<WaylandFullScreenDetector*> (data);
if (strcmp (interface, zwlr_foreign_toplevel_manager_v1_interface.name) == 0) {
detector->m_toplevelManager = static_cast<zwlr_foreign_toplevel_manager_v1*> (
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<CFullScreenDetector> {
return std::make_unique <CWaylandFullScreenDetector> (context);
[](ApplicationContext& context, VideoDriver& driver) -> std::unique_ptr<FullScreenDetector> {
return std::make_unique <WaylandFullScreenDetector> (context);
}
);
}

View File

@ -4,17 +4,17 @@
#include <glm/vec4.hpp>
#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;

View File

@ -1,15 +1,15 @@
#include "CX11FullScreenDetector.h"
#include "WallpaperEngine/Logging/CLog.h"
#include "WallpaperEngine/Logging/Log.h"
#include "X11FullScreenDetector.h"
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#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<CX11FullScreenDetector*> (userdata);
const auto context = static_cast<X11FullScreenDetector*> (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 <CGLFWOpenGLDriver&> (this->m_driver);
dynamic_cast <GLFWOpenGLDriver&> (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<Window> (dynamic_cast <CGLFWOpenGLDriver&> (this->m_driver).getWindow ());
const auto ourWindow = reinterpret_cast<Window> (dynamic_cast <GLFWOpenGLDriver&> (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<CFullScreenDetector> {
return std::make_unique <CX11FullScreenDetector> (context, driver);
[](ApplicationContext& context, VideoDriver& driver) -> std::unique_ptr<FullScreenDetector> {
return std::make_unique <X11FullScreenDetector> (context, driver);
}
);
}

View File

@ -4,18 +4,18 @@
#include <string>
#include <vector>
#include "CFullScreenDetector.h"
#include "WallpaperEngine/Render/Drivers/CVideoDriver.h"
#include "FullScreenDetector.h"
#include "WallpaperEngine/Render/Drivers/VideoDriver.h"
#include <X11/Xlib.h>
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<std::string, glm::ivec4> m_screens = {};
CVideoDriver& m_driver;
VideoDriver& m_driver;
};
} // namespace Detectors
} // namespace WallpaperEngine::Render::Drivers

View File

@ -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<float> (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<void*> (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<CVideoDriver> {
return std::make_unique <CGLFWOpenGLDriver> ("wallpaperengine", context, application);
[](ApplicationContext& context, WallpaperApplication& application) -> std::unique_ptr<VideoDriver> {
return std::make_unique <GLFWOpenGLDriver> ("wallpaperengine", context, application);
}
);
sVideoFactories.registerDriver (
CApplicationContext::EXPLICIT_WINDOW,
ApplicationContext::EXPLICIT_WINDOW,
DEFAULT_WINDOW_NAME,
[](CApplicationContext& context, CWallpaperApplication& application) -> std::unique_ptr<CVideoDriver> {
return std::make_unique <CGLFWOpenGLDriver> ("wallpaperengine", context, application);
[](ApplicationContext& context, WallpaperApplication& application) -> std::unique_ptr<VideoDriver> {
return std::make_unique <GLFWOpenGLDriver> ("wallpaperengine", context, application);
}
);
sVideoFactories.registerDriver (
CApplicationContext::NORMAL_WINDOW,
ApplicationContext::NORMAL_WINDOW,
DEFAULT_WINDOW_NAME,
[](CApplicationContext& context, CWallpaperApplication& application) -> std::unique_ptr<CVideoDriver> {
return std::make_unique <CGLFWOpenGLDriver> ("wallpaperengine", context, application);
[](ApplicationContext& context, WallpaperApplication& application) -> std::unique_ptr<VideoDriver> {
return std::make_unique <GLFWOpenGLDriver> ("wallpaperengine", context, application);
}
);
}

View File

@ -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 <GL/glew.h>
#include <GLFW/glfw3.h>
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;
};

View File

@ -1,12 +0,0 @@
#include "CGLFWOutputViewport.h"
#include <utility>
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 () {}

View File

@ -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<std::string, COutputViewport*>& COutput::getViewports () const {
return this->m_viewports;
}
int COutput::getFullWidth () const {
return this->m_fullWidth;
}
int COutput::getFullHeight () const {
return this->m_fullHeight;
}

View File

@ -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<CWaylandOpenGLDriver*> (&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 {}

View File

@ -0,0 +1,12 @@
#include "GLFWOutputViewport.h"
#include <utility>
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 () {}

View File

@ -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;

View File

@ -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 <GL/glew.h>
#include <GLFW/glfw3.h>
@ -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)

View File

@ -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;

Some files were not shown because too many files have changed in this diff Show More