From 9e271a2b39159d800b75300d98c6b01b1b5a6a66 Mon Sep 17 00:00:00 2001 From: Almamu Date: Tue, 7 May 2024 04:15:20 +0200 Subject: [PATCH] chore: remove notion of default background in render, each screen needs it's own independent render --- .../Application/CWallpaperApplication.cpp | 32 +++++++++---------- src/WallpaperEngine/Render/CRenderContext.cpp | 7 ---- src/WallpaperEngine/Render/CRenderContext.h | 3 -- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.cpp b/src/WallpaperEngine/Application/CWallpaperApplication.cpp index 9110e2b..bd08c10 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.cpp +++ b/src/WallpaperEngine/Application/CWallpaperApplication.cpp @@ -157,18 +157,19 @@ void CWallpaperApplication::setupContainer (CCombinedContainer& container, const } void CWallpaperApplication::loadBackgrounds () { - for (const auto& [background, path] : this->m_context.settings.general.screenBackgrounds) { - // ignore the screen settings if there was no background specified - // the default will be used - if (path.empty ()) - continue; - - this->m_backgrounds [background] = this->loadBackground (path); + // load default background if specified + if (!this->m_context.settings.general.defaultBackground.empty()) { + this->m_defaultBackground = this->loadBackground (this->m_context.settings.general.defaultBackground); } - // load the default project if required - if (!this->m_context.settings.general.defaultBackground.empty ()) - this->m_defaultBackground = this->loadBackground (this->m_context.settings.general.defaultBackground); + for (const auto& [background, path] : this->m_context.settings.general.screenBackgrounds) { + // screens with no background should use the default + if (path.empty ()) { + this->m_backgrounds [background] = this->m_defaultBackground; + } else { + this->m_backgrounds [background] = this->loadBackground (path); + } + } } Core::CProject* CWallpaperApplication::loadBackground (const std::string& bg) { @@ -292,17 +293,14 @@ void CWallpaperApplication::show () { // initialize render context context = new WallpaperEngine::Render::CRenderContext (*videoDriver, *inputContext, *this); + // create a new background for each screen + // set all the specific wallpapers required - for (const auto& [background, info] : this->m_backgrounds) + for (const auto& [background, info] : this->m_backgrounds) { context->setWallpaper (background, WallpaperEngine::Render::CWallpaper::fromWallpaper ( info->getWallpaper (), *context, *audioContext, browserContext, this->m_context.settings.general.screenScalings [background])); - - // set the default rendering wallpaper if available - if (this->m_defaultBackground != nullptr) - context->setDefaultWallpaper (WallpaperEngine::Render::CWallpaper::fromWallpaper ( - this->m_defaultBackground->getWallpaper (), *context, *audioContext, browserContext, - this->m_context.settings.render.window.scalingMode)); + } // wallpapers are setup, free browsesr context if possible if (!this->browserContext.isUsed()) { diff --git a/src/WallpaperEngine/Render/CRenderContext.cpp b/src/WallpaperEngine/Render/CRenderContext.cpp index e98c84a..ae4c055 100644 --- a/src/WallpaperEngine/Render/CRenderContext.cpp +++ b/src/WallpaperEngine/Render/CRenderContext.cpp @@ -10,7 +10,6 @@ namespace WallpaperEngine::Render { CRenderContext::CRenderContext (Drivers::CVideoDriver& driver, Input::CInputContext& input, CWallpaperApplication& app) : - m_defaultWallpaper (nullptr), m_driver (driver), m_app (app), m_input (input), @@ -31,8 +30,6 @@ void CRenderContext::render (Drivers::Output::COutputViewport* viewport) { // render the background if (ref != this->m_wallpapers.end ()) ref->second->render (viewport->viewport, this->getOutput ().renderVFlip ()); - else - this->m_defaultWallpaper->render (viewport->viewport, this->getOutput ().renderVFlip ()); #if !NDEBUG glPopDebugGroup (); @@ -41,10 +38,6 @@ void CRenderContext::render (Drivers::Output::COutputViewport* viewport) { viewport->swapOutput (); } -void CRenderContext::setDefaultWallpaper (CWallpaper* wallpaper) { - this->m_defaultWallpaper = wallpaper; -} - void CRenderContext::setWallpaper (const std::string& display, CWallpaper* wallpaper) { this->m_wallpapers.insert_or_assign (display, wallpaper); } diff --git a/src/WallpaperEngine/Render/CRenderContext.h b/src/WallpaperEngine/Render/CRenderContext.h index 60e6082..6017f07 100644 --- a/src/WallpaperEngine/Render/CRenderContext.h +++ b/src/WallpaperEngine/Render/CRenderContext.h @@ -34,7 +34,6 @@ class CRenderContext { CRenderContext (Drivers::CVideoDriver& driver, Input::CInputContext& input, CWallpaperApplication& app); void render (Drivers::Output::COutputViewport* viewport); - void setDefaultWallpaper (CWallpaper* wallpaper); void setWallpaper (const std::string& display, CWallpaper* wallpaper); [[nodiscard]] Input::CInputContext& getInputContext () const; [[nodiscard]] const CWallpaperApplication& getApp () const; @@ -47,8 +46,6 @@ class CRenderContext { Drivers::CVideoDriver& m_driver; /** Maps screen -> wallpaper list */ std::map m_wallpapers; - /** Default wallpaper to use */ - CWallpaper* m_defaultWallpaper; /** Input context for interactions */ Input::CInputContext& m_input; /** App that holds the render context */