From e553f68e90b1da9b35191a7d1dd8a397ec3b26bd Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Tue, 23 Aug 2022 22:34:56 +0200 Subject: [PATCH] Greatly improved application startup time by removing a lot of unnecessary splash screen re-rasterizations. --- es-app/src/main.cpp | 9 +++------ es-app/src/views/ViewController.cpp | 3 +-- es-core/src/Settings.cpp | 2 -- es-core/src/Window.cpp | 16 +++++++++------- es-core/src/Window.h | 1 + 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 65047066f..882ce9d41 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -648,8 +648,7 @@ int main(int argc, char* argv[]) window->pushGui(ViewController::getInstance()); - bool splashScreen = Settings::getInstance()->getBool("SplashScreen"); - bool splashScreenProgress = Settings::getInstance()->getBool("SplashScreenProgress"); + bool splashScreen {Settings::getInstance()->getBool("SplashScreen")}; InputManager::getInstance().parseEvent(event); if (event.type == SDL_QUIT) @@ -674,9 +673,7 @@ int main(int argc, char* argv[]) #endif if (splashScreen) { - std::string progressText = "Loading..."; - if (splashScreenProgress) - progressText = "Loading system config..."; + std::string progressText {"Loading system config..."}; window->renderLoadingScreen(progressText); } @@ -720,7 +717,7 @@ int main(int argc, char* argv[]) << "\""; } - if (splashScreen && splashScreenProgress) + if (splashScreen) window->renderLoadingScreen("Done"); // Open the input configuration GUI if the flag to force this was passed from the command line. diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index bd7324d9a..79d446853 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -945,8 +945,7 @@ void ViewController::preload() for (auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); ++it) { - if (Settings::getInstance()->getBool("SplashScreen") && - Settings::getInstance()->getBool("SplashScreenProgress")) { + if (Settings::getInstance()->getBool("SplashScreen")) { mWindow->renderLoadingScreen( "Loading '" + (*it)->getFullName() + "' (" + std::to_string(std::distance(SystemData::sSystemVector.cbegin(), it) + 1) + "/" + diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 2c51c7287..c30537574 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -49,7 +49,6 @@ namespace "DebugGrid", "DebugText", "DebugImage", - "SplashScreenProgress", "ScraperFilter" // clang-format on }; @@ -296,7 +295,6 @@ void Settings::setDefaults() mBoolMap["DebugGrid"] = {false, false}; mBoolMap["DebugText"] = {false, false}; mBoolMap["DebugImage"] = {false, false}; - mBoolMap["SplashScreenProgress"] = {true, true}; mIntMap["ScraperFilter"] = {0, 0}; } diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 17c74fba8..843c2eb47 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -54,6 +54,7 @@ Window::Window() noexcept Window::~Window() { delete mBackgroundOverlay; + delete mSplash; // Delete all our GUIs. while (peekGui()) @@ -112,6 +113,8 @@ bool Window::init() ResourceManager::getInstance().reloadAll(); mHelp = new HelpComponent; + mSplash = new ImageComponent; + mBackgroundOverlay = new ImageComponent; mBackgroundOverlayOpacity = 0.0f; @@ -122,6 +125,11 @@ bool Window::init() mDefaultFonts.push_back(Font::get(FONT_SIZE_LARGE)); } + mSplash->setResize(Renderer::getScreenWidth() * 0.6f, 0.0f); + mSplash->setImage(":/graphics/splash.svg"); + mSplash->setPosition((Renderer::getScreenWidth() - mSplash->getSize().x) / 2.0f, + (Renderer::getScreenHeight() - mSplash->getSize().y) / 2.0f * 0.6f); + mBackgroundOverlay->setImage(":/graphics/frame.png"); mBackgroundOverlay->setResize(Renderer::getScreenWidth(), Renderer::getScreenHeight()); @@ -598,13 +606,7 @@ void Window::renderLoadingScreen(std::string text) mRenderer->setMatrix(trans); mRenderer->drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF, 0x000000FF); - - ImageComponent splash(true); - splash.setImage(":/graphics/splash.svg"); - splash.setResize(Renderer::getScreenWidth() * 0.6f, 0.0f); - splash.setPosition((Renderer::getScreenWidth() - splash.getSize().x) / 2.0f, - (Renderer::getScreenHeight() - splash.getSize().y) / 2.0f * 0.6f); - splash.render(trans); + mSplash->render(trans); auto& font = mDefaultFonts.at(1); TextCache* cache = font->buildTextCache(text, 0.0f, 0.0f, 0x656565FF); diff --git a/es-core/src/Window.h b/es-core/src/Window.h index 51cad5d91..92b4e32b0 100644 --- a/es-core/src/Window.h +++ b/es-core/src/Window.h @@ -153,6 +153,7 @@ private: Renderer* mRenderer; HelpComponent* mHelp; ImageComponent* mBackgroundOverlay; + ImageComponent* mSplash; float mBackgroundOverlayOpacity; std::vector mGuiStack; std::vector> mDefaultFonts;