chore: remove notion of default background in render, each screen needs it's own independent render

This commit is contained in:
Almamu 2024-05-07 04:15:20 +02:00
parent 235cda8c94
commit 9e271a2b39
3 changed files with 15 additions and 27 deletions

View File

@ -157,18 +157,19 @@ void CWallpaperApplication::setupContainer (CCombinedContainer& container, const
} }
void CWallpaperApplication::loadBackgrounds () { void CWallpaperApplication::loadBackgrounds () {
for (const auto& [background, path] : this->m_context.settings.general.screenBackgrounds) { // load default background if specified
// ignore the screen settings if there was no background specified if (!this->m_context.settings.general.defaultBackground.empty()) {
// the default will be used this->m_defaultBackground = this->loadBackground (this->m_context.settings.general.defaultBackground);
if (path.empty ())
continue;
this->m_backgrounds [background] = this->loadBackground (path);
} }
// load the default project if required for (const auto& [background, path] : this->m_context.settings.general.screenBackgrounds) {
if (!this->m_context.settings.general.defaultBackground.empty ()) // screens with no background should use the default
this->m_defaultBackground = this->loadBackground (this->m_context.settings.general.defaultBackground); 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) { Core::CProject* CWallpaperApplication::loadBackground (const std::string& bg) {
@ -292,17 +293,14 @@ void CWallpaperApplication::show () {
// initialize render context // initialize render context
context = new WallpaperEngine::Render::CRenderContext (*videoDriver, *inputContext, *this); context = new WallpaperEngine::Render::CRenderContext (*videoDriver, *inputContext, *this);
// create a new background for each screen
// set all the specific wallpapers required // 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 ( context->setWallpaper (background, WallpaperEngine::Render::CWallpaper::fromWallpaper (
info->getWallpaper (), *context, *audioContext, browserContext, info->getWallpaper (), *context, *audioContext, browserContext,
this->m_context.settings.general.screenScalings [background])); 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 // wallpapers are setup, free browsesr context if possible
if (!this->browserContext.isUsed()) { if (!this->browserContext.isUsed()) {

View File

@ -10,7 +10,6 @@
namespace WallpaperEngine::Render { namespace WallpaperEngine::Render {
CRenderContext::CRenderContext (Drivers::CVideoDriver& driver, Input::CInputContext& input, CRenderContext::CRenderContext (Drivers::CVideoDriver& driver, Input::CInputContext& input,
CWallpaperApplication& app) : CWallpaperApplication& app) :
m_defaultWallpaper (nullptr),
m_driver (driver), m_driver (driver),
m_app (app), m_app (app),
m_input (input), m_input (input),
@ -31,8 +30,6 @@ void CRenderContext::render (Drivers::Output::COutputViewport* viewport) {
// render the background // render the background
if (ref != this->m_wallpapers.end ()) if (ref != this->m_wallpapers.end ())
ref->second->render (viewport->viewport, this->getOutput ().renderVFlip ()); ref->second->render (viewport->viewport, this->getOutput ().renderVFlip ());
else
this->m_defaultWallpaper->render (viewport->viewport, this->getOutput ().renderVFlip ());
#if !NDEBUG #if !NDEBUG
glPopDebugGroup (); glPopDebugGroup ();
@ -41,10 +38,6 @@ void CRenderContext::render (Drivers::Output::COutputViewport* viewport) {
viewport->swapOutput (); viewport->swapOutput ();
} }
void CRenderContext::setDefaultWallpaper (CWallpaper* wallpaper) {
this->m_defaultWallpaper = wallpaper;
}
void CRenderContext::setWallpaper (const std::string& display, CWallpaper* wallpaper) { void CRenderContext::setWallpaper (const std::string& display, CWallpaper* wallpaper) {
this->m_wallpapers.insert_or_assign (display, wallpaper); this->m_wallpapers.insert_or_assign (display, wallpaper);
} }

View File

@ -34,7 +34,6 @@ class CRenderContext {
CRenderContext (Drivers::CVideoDriver& driver, Input::CInputContext& input, CWallpaperApplication& app); CRenderContext (Drivers::CVideoDriver& driver, Input::CInputContext& input, CWallpaperApplication& app);
void render (Drivers::Output::COutputViewport* viewport); void render (Drivers::Output::COutputViewport* viewport);
void setDefaultWallpaper (CWallpaper* wallpaper);
void setWallpaper (const std::string& display, CWallpaper* wallpaper); void setWallpaper (const std::string& display, CWallpaper* wallpaper);
[[nodiscard]] Input::CInputContext& getInputContext () const; [[nodiscard]] Input::CInputContext& getInputContext () const;
[[nodiscard]] const CWallpaperApplication& getApp () const; [[nodiscard]] const CWallpaperApplication& getApp () const;
@ -47,8 +46,6 @@ class CRenderContext {
Drivers::CVideoDriver& m_driver; Drivers::CVideoDriver& m_driver;
/** Maps screen -> wallpaper list */ /** Maps screen -> wallpaper list */
std::map<std::string, CWallpaper*> m_wallpapers; std::map<std::string, CWallpaper*> m_wallpapers;
/** Default wallpaper to use */
CWallpaper* m_defaultWallpaper;
/** Input context for interactions */ /** Input context for interactions */
Input::CInputContext& m_input; Input::CInputContext& m_input;
/** App that holds the render context */ /** App that holds the render context */