From 18db8b0bd6531cbb5f02fdb116cb99ac84c74907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 1 Mar 2018 16:08:23 +0100 Subject: [PATCH] Fix custom UI backgrounds again by initializing lazily (turned out to be the cause of #10662) --- UI/MiscScreens.cpp | 8 ++++++++ UI/NativeApp.cpp | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 577e1cedd6..fa6980f0f4 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -71,6 +71,8 @@ static const uint32_t colors[4] = { static std::unique_ptr bgTexture; +static bool backgroundInited; + void UIBackgroundInit(UIContext &dc) { const std::string bgPng = GetSysDirectory(DIRECTORY_SYSTEM) + "background.png"; const std::string bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) + "background.jpg"; @@ -82,9 +84,15 @@ void UIBackgroundInit(UIContext &dc) { void UIBackgroundShutdown() { bgTexture.reset(nullptr); + backgroundInited = false; } void DrawBackground(UIContext &dc, float alpha) { + if (!backgroundInited) { + UIBackgroundInit(dc); + backgroundInited = true; + } + static float xbase[100] = {0}; static float ybase[100] = {0}; float xres = dc.GetBounds().w; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 59344be74e..cbfceed7c2 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -664,8 +664,6 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) { screenManager->setDrawContext(g_draw); screenManager->setPostRenderCallback(&RenderOverlays, nullptr); - UIBackgroundInit(*uiContext); - #ifdef _WIN32 winAudioBackend = CreateAudioBackend((AudioBackendType)g_Config.iAudioBackend); #if PPSSPP_PLATFORM(UWP)