2
0
Эх сурвалжийг харах

WIP: macOS port
- Splash screen modified so it starts earlier, and so that it no longer needs to block the calling thread (with was messing up macOS)

BearishSun 7 жил өмнө
parent
commit
c01f976534

+ 1 - 1
Source/BansheeD3D11RenderAPI/BsD3D11RenderWindow.cpp

@@ -190,7 +190,7 @@ namespace bs
 
 
 		if (!windowDesc.external)
 		if (!windowDesc.external)
 		{
 		{
-			mShowOnSwap = mDesc.hideUntilSwap;
+			mShowOnSwap = mDesc.hideUntilSwap && !mDesc.hidden;
 			props.isHidden = mDesc.hideUntilSwap || mDesc.hidden;
 			props.isHidden = mDesc.hideUntilSwap || mDesc.hidden;
 		}
 		}
 
 

+ 20 - 2
Source/BansheeEditor/BsEditorApplication.cpp

@@ -33,6 +33,8 @@
 
 
 namespace bs
 namespace bs
 {
 {
+	constexpr UINT32 SPLASH_SCREEN_DURATION_MS = 1000;
+
 	const Path EditorApplication::WIDGET_LAYOUT_PATH = PROJECT_INTERNAL_DIR + L"Layout.asset";
 	const Path EditorApplication::WIDGET_LAYOUT_PATH = PROJECT_INTERNAL_DIR + L"Layout.asset";
 	const Path EditorApplication::BUILD_DATA_PATH = PROJECT_INTERNAL_DIR + L"BuildData.asset";
 	const Path EditorApplication::BUILD_DATA_PATH = PROJECT_INTERNAL_DIR + L"BuildData.asset";
 	const Path EditorApplication::PROJECT_SETTINGS_PATH = PROJECT_INTERNAL_DIR + L"Settings.asset";
 	const Path EditorApplication::PROJECT_SETTINGS_PATH = PROJECT_INTERNAL_DIR + L"Settings.asset";
@@ -53,6 +55,7 @@ namespace bs
 		startUpDesc.primaryWindowDesc.showBorder = false;
 		startUpDesc.primaryWindowDesc.showBorder = false;
 		startUpDesc.primaryWindowDesc.hideUntilSwap = true;
 		startUpDesc.primaryWindowDesc.hideUntilSwap = true;
 		startUpDesc.primaryWindowDesc.depthBuffer = false;
 		startUpDesc.primaryWindowDesc.depthBuffer = false;
+		startUpDesc.primaryWindowDesc.hidden = true;
 
 
 		startUpDesc.importers.push_back("BansheeFreeImgImporter");
 		startUpDesc.importers.push_back("BansheeFreeImgImporter");
 		startUpDesc.importers.push_back("BansheeFBXImporter");
 		startUpDesc.importers.push_back("BansheeFBXImporter");
@@ -82,7 +85,6 @@ namespace bs
 	void EditorApplication::onStartUp()
 	void EditorApplication::onStartUp()
 	{
 	{
 		Application::onStartUp();
 		Application::onStartUp();
-		SplashScreen::show();
 
 
 		// In editor we render game on a separate surface, handled in Game window
 		// In editor we render game on a separate surface, handled in Game window
 		SceneManager::instance().setMainRenderTarget(nullptr);
 		SceneManager::instance().setMainRenderTarget(nullptr);
@@ -167,6 +169,12 @@ namespace bs
 		CoreApplication::startUp<EditorApplication>();
 		CoreApplication::startUp<EditorApplication>();
 	}
 	}
 
 
+	void EditorApplication::startUpRenderer()
+	{
+		mSplashScreenTimer.reset();
+		SplashScreen::show();
+	}
+
 	void EditorApplication::preUpdate()
 	void EditorApplication::preUpdate()
 	{
 	{
 		Application::preUpdate();
 		Application::preUpdate();
@@ -183,7 +191,17 @@ namespace bs
 
 
 		Application::postUpdate();
 		Application::postUpdate();
 
 
-		SplashScreen::hide();
+		if(mSplashScreenShown)
+		{
+			UINT64 currentTime = mSplashScreenTimer.getMilliseconds();
+			if (currentTime >= SPLASH_SCREEN_DURATION_MS)
+			{
+				SplashScreen::hide();
+				EditorWindowManager::instance().showWindows();
+				mSplashScreenShown = false;
+			}
+		}
+
 		setFPSLimit(mEditorSettings->getFPSLimit());
 		setFPSLimit(mEditorSettings->getFPSLimit());
 	}
 	}
 
 

+ 7 - 0
Source/BansheeEditor/BsEditorApplication.h

@@ -4,6 +4,7 @@
 
 
 #include "BsEditorPrerequisites.h"
 #include "BsEditorPrerequisites.h"
 #include "BsApplication.h"
 #include "BsApplication.h"
+#include "Utility/BsTimer.h"
 
 
 namespace bs
 namespace bs
 {
 {
@@ -103,6 +104,9 @@ namespace bs
 		/** @copydoc Application::unloadScriptSystem */
 		/** @copydoc Application::unloadScriptSystem */
 		void unloadScriptSystem() override;
 		void unloadScriptSystem() override;
 
 
+		/** @copydoc Application::startUpRenderer */
+		void startUpRenderer() override;
+
 		/**
 		/**
 		 * Loads the previously saved editor widget layout from the default location. Can return null if no layout was 
 		 * Loads the previously saved editor widget layout from the default location. Can return null if no layout was 
 		 * previously saved.
 		 * previously saved.
@@ -139,6 +143,9 @@ namespace bs
 		Path mProjectPath;
 		Path mProjectPath;
 		WString mProjectName;
 		WString mProjectName;
 
 
+		Timer mSplashScreenTimer;
+		bool mSplashScreenShown = true;
+
 		DynLib* mSBansheeEditorPlugin;
 		DynLib* mSBansheeEditorPlugin;
 	};
 	};
 
 

+ 3 - 0
Source/BansheeEditor/EditorWindow/BsEditorWindowBase.cpp

@@ -44,6 +44,9 @@ namespace bs
 		renderWindowDesc.top = top;
 		renderWindowDesc.top = top;
 		renderWindowDesc.depthBuffer = false;
 		renderWindowDesc.depthBuffer = false;
 
 
+		if(EditorWindowManager::instance().areNewWindowsHidden())
+			renderWindowDesc.hidden = true;
+
 		mRenderWindow = RenderWindow::create(renderWindowDesc, gCoreApplication().getPrimaryWindow());
 		mRenderWindow = RenderWindow::create(renderWindowDesc, gCoreApplication().getPrimaryWindow());
 
 
 		construct(mRenderWindow);
 		construct(mRenderWindow);

+ 20 - 1
Source/BansheeEditor/EditorWindow/BsEditorWindowManager.cpp

@@ -3,6 +3,7 @@
 #include "EditorWindow/BsEditorWindowManager.h"
 #include "EditorWindow/BsEditorWindowManager.h"
 #include "EditorWindow/BsEditorWindow.h"
 #include "EditorWindow/BsEditorWindow.h"
 #include "EditorWindow/BsMainEditorWindow.h"
 #include "EditorWindow/BsMainEditorWindow.h"
+#include "RenderAPI/BsRenderWindow.h"
 
 
 namespace bs
 namespace bs
 {
 {
@@ -63,6 +64,24 @@ namespace bs
 		mEditorWindows.erase(iterFind);
 		mEditorWindows.erase(iterFind);
 	}
 	}
 
 
+	void EditorWindowManager::showWindows()
+	{
+		for(auto& entry : mEditorWindows)
+		{
+			SPtr<RenderWindow> window = entry->getRenderWindow();
+			if(window)
+				window->show();
+		}
+
+		if(mMainWindow)
+		{
+			SPtr<RenderWindow> mainRenderWindow = mMainWindow->getRenderWindow();
+			mainRenderWindow->show();
+		}
+
+		mNewWindowsHidden = false;
+	}
+
 	void EditorWindowManager::update()
 	void EditorWindowManager::update()
 	{
 	{
 		// Editor window destroy is deferred to this point, otherwise we risk
 		// Editor window destroy is deferred to this point, otherwise we risk
@@ -98,4 +117,4 @@ namespace bs
 
 
 		return false;
 		return false;
 	}
 	}
-}
+}

+ 10 - 0
Source/BansheeEditor/EditorWindow/BsEditorWindowManager.h

@@ -42,7 +42,17 @@ namespace bs
 
 
 		/**	Checks if any editor window has keyboard focus. */
 		/**	Checks if any editor window has keyboard focus. */
 		bool hasFocus() const;
 		bool hasFocus() const;
+
+		/** 
+		 * By default all windows are created as hidden. After this method is called all windows will be shown, and
+		 * any new windows will be shown by default.
+		 */
+		void showWindows();
+
+		/** Checks if new editor windows should be created hidden. */
+		bool areNewWindowsHidden() const { return mNewWindowsHidden; }
 	protected:
 	protected:
+		bool mNewWindowsHidden = true;
 		MainEditorWindow* mMainWindow;
 		MainEditorWindow* mMainWindow;
 
 
 		Vector<EditorWindowBase*> mEditorWindows;
 		Vector<EditorWindowBase*> mEditorWindows;

+ 0 - 5
Source/BansheeEngine/Platform/BsSplashScreen.cpp

@@ -19,7 +19,6 @@ namespace bs
 
 
 	// Note: Never freed, but that's fine
 	// Note: Never freed, but that's fine
 	SplashScreen::Pimpl* SplashScreen::m = bs_new<Pimpl>();
 	SplashScreen::Pimpl* SplashScreen::m = bs_new<Pimpl>();
-	const UINT32 SplashScreen::SPLASH_SCREEN_DURATION_MS = 1000;
 
 
 	void SplashScreen::show()
 	void SplashScreen::show()
 	{
 	{
@@ -67,10 +66,6 @@ namespace bs
 		if (m->window == nullptr)
 		if (m->window == nullptr)
 			return;
 			return;
 
 
-		UINT64 currentTime = m->timer.getMilliseconds();
-		if (currentTime < SPLASH_SCREEN_DURATION_MS)
-			BS_THREAD_SLEEP(SPLASH_SCREEN_DURATION_MS - currentTime);
-
 		bs_delete(m->window);
 		bs_delete(m->window);
 		m->window = nullptr;
 		m->window = nullptr;
 	}
 	}

+ 1 - 1
Source/BansheeGLRenderAPI/Win32/BsWin32RenderWindow.cpp

@@ -177,7 +177,7 @@ namespace bs
 
 
 		if (!windowDesc.external)
 		if (!windowDesc.external)
 		{
 		{
-			mShowOnSwap = mDesc.hideUntilSwap;
+			mShowOnSwap = mDesc.hideUntilSwap && !mDesc.hidden;
 			props.isHidden = mDesc.hideUntilSwap || mDesc.hidden;
 			props.isHidden = mDesc.hideUntilSwap || mDesc.hidden;
 		}
 		}
 
 

+ 1 - 4
Source/BansheeSL/BsSLFXCompiler.cpp

@@ -582,10 +582,7 @@ namespace bs
 		outputDesc.sourceCode = &output;
 		outputDesc.sourceCode = &output;
 		outputDesc.options.autoBinding = isVulkan;
 		outputDesc.options.autoBinding = isVulkan;
 		outputDesc.options.autoBindingStartSlot = startBindingSlot;
 		outputDesc.options.autoBindingStartSlot = startBindingSlot;
-		
-		
-		// DEBUG ONLY
-		//outputDesc.options.fragmentLocations = true;
+		outputDesc.options.fragmentLocations = true;
 		outputDesc.options.separateShaders = true;
 		outputDesc.options.separateShaders = true;
 		outputDesc.options.separateSamplers = false;
 		outputDesc.options.separateSamplers = false;
 		outputDesc.nameMangling.inputPrefix = "bs_";
 		outputDesc.nameMangling.inputPrefix = "bs_";

+ 16 - 0
Source/BansheeUtility/Private/Win32/BsWin32Window.cpp

@@ -18,6 +18,7 @@ namespace bs
 		UINT32 height = 0;
 		UINT32 height = 0;
 		bool isExternal = false;
 		bool isExternal = false;
 		bool isModal = false;
 		bool isModal = false;
+		bool isHidden = false;
 		DWORD style = 0;
 		DWORD style = 0;
 		DWORD styleEx = 0;
 		DWORD styleEx = 0;
 	};
 	};
@@ -26,6 +27,7 @@ namespace bs
 	{
 	{
 		m = bs_new<Pimpl>();
 		m = bs_new<Pimpl>();
 		m->isModal = desc.modal;
 		m->isModal = desc.modal;
+		m->isHidden = desc.hidden;
 
 
 		HMONITOR hMonitor = desc.monitor;
 		HMONITOR hMonitor = desc.monitor;
 		if (!desc.external)
 		if (!desc.external)
@@ -263,6 +265,9 @@ namespace bs
 				BringWindowToTop(entry);
 				BringWindowToTop(entry);
 		}
 		}
 
 
+		if(desc.hidden)
+			setHidden(true);
+
 		bs_frame_clear();
 		bs_frame_clear();
 	}
 	}
 
 
@@ -373,24 +378,35 @@ namespace bs
 			ShowWindow(m->hWnd, SW_HIDE);
 			ShowWindow(m->hWnd, SW_HIDE);
 		else
 		else
 			ShowWindow(m->hWnd, SW_SHOW);
 			ShowWindow(m->hWnd, SW_SHOW);
+
+		m->isHidden = hidden;
 	}
 	}
 
 
 	void Win32Window::minimize()
 	void Win32Window::minimize()
 	{
 	{
 		if (m->hWnd)
 		if (m->hWnd)
 			ShowWindow(m->hWnd, SW_MINIMIZE);
 			ShowWindow(m->hWnd, SW_MINIMIZE);
+
+		if(m->isHidden)
+			ShowWindow(m->hWnd, SW_HIDE);
 	}
 	}
 
 
 	void Win32Window::maximize()
 	void Win32Window::maximize()
 	{
 	{
 		if (m->hWnd)
 		if (m->hWnd)
 			ShowWindow(m->hWnd, SW_MAXIMIZE);
 			ShowWindow(m->hWnd, SW_MAXIMIZE);
+
+		if(m->isHidden)
+			ShowWindow(m->hWnd, SW_HIDE);
 	}
 	}
 
 
 	void Win32Window::restore()
 	void Win32Window::restore()
 	{
 	{
 		if (m->hWnd)
 		if (m->hWnd)
 			ShowWindow(m->hWnd, SW_RESTORE);
 			ShowWindow(m->hWnd, SW_RESTORE);
+
+		if(m->isHidden)
+			ShowWindow(m->hWnd, SW_HIDE);
 	}
 	}
 
 
 	void Win32Window::_windowMovedOrResized()
 	void Win32Window::_windowMovedOrResized()

+ 1 - 1
Source/BansheeVulkanRenderAPI/Win32/BsWin32RenderWindow.cpp

@@ -154,7 +154,7 @@ namespace bs
 		// Must be set before creating a window, since wndProc will call ShowWindow if needed after creation
 		// Must be set before creating a window, since wndProc will call ShowWindow if needed after creation
 		if (!windowDesc.external)
 		if (!windowDesc.external)
 		{
 		{
-			mShowOnSwap = mDesc.hideUntilSwap;
+			mShowOnSwap = mDesc.hideUntilSwap && !mDesc.hidden;
 			props.isHidden = mDesc.hideUntilSwap || mDesc.hidden;
 			props.isHidden = mDesc.hideUntilSwap || mDesc.hidden;
 		}
 		}