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

View File

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

View File

@ -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<std::string, CWallpaper*> m_wallpapers;
/** Default wallpaper to use */
CWallpaper* m_defaultWallpaper;
/** Input context for interactions */
Input::CInputContext& m_input;
/** App that holds the render context */