diff --git a/es-app/src/SystemScreensaver.cpp b/es-app/src/SystemScreensaver.cpp index f94ede47d..8be829374 100644 --- a/es-app/src/SystemScreensaver.cpp +++ b/es-app/src/SystemScreensaver.cpp @@ -44,6 +44,7 @@ SystemScreensaver::SystemScreensaver( mMediaSwapTime(0), mTriggerNextGame(false), mHasMediaFiles(false), + mFallbackScreensaver(false), mOpacity(0.0f), mDimValue(1.0), mRectangleFadeIn(50), @@ -70,11 +71,17 @@ bool SystemScreensaver::isScreensaverActive() return (mState != STATE_INACTIVE); } +bool SystemScreensaver::isFallbackScreensaver() +{ + return mFallbackScreensaver; +} + void SystemScreensaver::startScreensaver(bool generateMediaList) { std::string path = ""; std::string screensaverType = Settings::getInstance()->getString("ScreensaverType"); mHasMediaFiles = false; + mFallbackScreensaver = false; mOpacity = 0.0f; // Keep a reference to the default fonts, so they don't keep getting destroyed/recreated. @@ -253,6 +260,7 @@ void SystemScreensaver::goToGame() void SystemScreensaver::renderScreensaver() { std::string screensaverType = Settings::getInstance()->getString("ScreensaverType"); + if (mVideoScreensaver && screensaverType == "video") { // Render a black background below the video. Renderer::setMatrix(Transform4x4f::Identity()); @@ -309,20 +317,10 @@ void SystemScreensaver::renderScreensaver() } } else { - // If there are no images, fade in a black screen. - #if defined(USE_OPENGL_21) - Renderer::shaderParameters blackParameters; - blackParameters.fragmentDimValue = mDimValue; - Renderer::shaderPostprocessing(Renderer::SHADER_DIM, blackParameters); - #else - Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), - Renderer::getScreenHeight(), 0x000000FF, 0x000000FF, mDimValue); - #endif - if (mDimValue > 0.0) - mDimValue = Math::clamp(mDimValue - 0.045f, 0.0f, 1.0f); + mFallbackScreensaver = true; } } - if (Settings::getInstance()->getString("ScreensaverType") == "video") { + else if (Settings::getInstance()->getString("ScreensaverType") == "video") { if (mHasMediaFiles) { #if defined(USE_OPENGL_21) Renderer::shaderParameters videoParameters; @@ -370,20 +368,23 @@ void SystemScreensaver::renderScreensaver() } } else { - // If there are no videos, fade in a black screen. - #if defined(USE_OPENGL_21) - Renderer::shaderParameters blackParameters; - blackParameters.fragmentDimValue = mDimValue; - Renderer::shaderPostprocessing(Renderer::SHADER_DIM, blackParameters); - #else - Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), - Renderer::getScreenHeight(), 0x000000FF, 0x000000FF, mDimValue); - #endif - if (mDimValue > 0.0) - mDimValue = Math::clamp(mDimValue - 0.045f, 0.0f, 1.0f); + mFallbackScreensaver = true; } } + if (mFallbackScreensaver || + Settings::getInstance()->getString("ScreensaverType") == "black") { + #if defined(USE_OPENGL_21) + Renderer::shaderParameters blackParameters; + blackParameters.fragmentDimValue = mDimValue; + Renderer::shaderPostprocessing(Renderer::SHADER_DIM, blackParameters); + if (mDimValue > 0.0) + mDimValue = Math::clamp(mDimValue - 0.045f, 0.0f, 1.0f); + #else + Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), + Renderer::getScreenHeight(), 0x000000FF, 0x000000FF); + #endif + } else if (Settings::getInstance()->getString("ScreensaverType") == "dim") { #if defined(USE_OPENGL_21) Renderer::shaderParameters dimParameters; @@ -400,18 +401,6 @@ void SystemScreensaver::renderScreensaver() Renderer::getScreenHeight(), 0x000000A0, 0x000000A0); #endif } - else if (Settings::getInstance()->getString("ScreensaverType") == "black") { - #if defined(USE_OPENGL_21) - Renderer::shaderParameters blackParameters; - blackParameters.fragmentDimValue = mDimValue; - Renderer::shaderPostprocessing(Renderer::SHADER_DIM, blackParameters); - if (mDimValue > 0.0) - mDimValue = Math::clamp(mDimValue - 0.045f, 0.0f, 1.0f); - #else - Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), - Renderer::getScreenHeight(), 0x000000FF, 0x000000FF); - #endif - } } } diff --git a/es-app/src/SystemScreensaver.h b/es-app/src/SystemScreensaver.h index 9868e7fd8..5ec3cddaa 100644 --- a/es-app/src/SystemScreensaver.h +++ b/es-app/src/SystemScreensaver.h @@ -24,6 +24,7 @@ public: virtual bool allowSleep(); virtual bool isScreensaverActive(); + virtual bool isFallbackScreensaver(); virtual void startScreensaver(bool generateMediaList); virtual void stopScreensaver(); @@ -72,6 +73,7 @@ private: int mMediaSwapTime; bool mTriggerNextGame; bool mHasMediaFiles; + bool mFallbackScreensaver; float mOpacity; float mDimValue; unsigned char mRectangleFadeIn; diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 947197b04..4be16a3b0 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -312,9 +312,10 @@ void Window::render() } // Don't render the system view or gamelist view if the video or slideshow screensaver - // is running. - if (!(mRenderScreensaver && (Settings::getInstance()->getString("ScreensaverType") == - "video" || Settings::getInstance()->getString("ScreensaverType") == "slideshow"))) + // is running, unless the fallback screensaver is active due to lack of images or videos. + if ((mRenderScreensaver && mScreensaver->isFallbackScreensaver()) || + (!(mRenderScreensaver && (Settings::getInstance()->getString("ScreensaverType") == + "video" || Settings::getInstance()->getString("ScreensaverType") == "slideshow")))) bottom->render(transform); if (bottom != top) { diff --git a/es-core/src/Window.h b/es-core/src/Window.h index 59197fda5..120af4fa6 100644 --- a/es-core/src/Window.h +++ b/es-core/src/Window.h @@ -35,6 +35,7 @@ public: public: virtual bool allowSleep() = 0; virtual bool isScreensaverActive() = 0; + virtual bool isFallbackScreensaver() = 0; virtual void startScreensaver(bool generateMediaList) = 0; virtual void stopScreensaver() = 0;