refactor(new_editor/app): reorganize host structure and add smoke test
This commit is contained in:
67
new_editor/app/Bootstrap/ApplicationRunLoop.cpp
Normal file
67
new_editor/app/Bootstrap/ApplicationRunLoop.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#include "Bootstrap/Application.h"
|
||||
|
||||
#include "Platform/Win32/EditorWindow.h"
|
||||
#include "Platform/Win32/EditorWindowManager.h"
|
||||
|
||||
#include <XCEditor/Foundation/UIEditorRuntimeTrace.h>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
void Application::TickSmokeTest() {
|
||||
if (!m_smokeTestEnabled || m_smokeTestCloseRequested || m_windowManager == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
++m_smokeTestRenderedFrames;
|
||||
if (m_smokeTestRenderedFrames < m_smokeTestFrameLimit) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (App::EditorWindow* primaryWindow = m_windowManager->FindPrimaryWindow();
|
||||
primaryWindow != nullptr &&
|
||||
primaryWindow->GetHwnd() != nullptr) {
|
||||
PostMessageW(primaryWindow->GetHwnd(), WM_CLOSE, 0, 0);
|
||||
m_smokeTestCloseRequested = true;
|
||||
AppendUIEditorRuntimeTrace("smoke", "frame budget reached, requested WM_CLOSE");
|
||||
}
|
||||
}
|
||||
|
||||
int Application::Run(HINSTANCE hInstance, int nCmdShow) {
|
||||
if (!Initialize(hInstance, nCmdShow)) {
|
||||
Shutdown();
|
||||
return 1;
|
||||
}
|
||||
|
||||
MSG message = {};
|
||||
while (true) {
|
||||
while (PeekMessageW(&message, nullptr, 0U, 0U, PM_REMOVE)) {
|
||||
if (message.message == WM_QUIT) {
|
||||
Shutdown();
|
||||
return static_cast<int>(message.wParam);
|
||||
}
|
||||
|
||||
TranslateMessage(&message);
|
||||
DispatchMessageW(&message);
|
||||
}
|
||||
|
||||
if (m_windowManager != nullptr) {
|
||||
m_windowManager->DestroyClosedWindows();
|
||||
m_windowManager->ProcessPendingGlobalTabDragStarts();
|
||||
m_windowManager->ProcessPendingDetachRequests();
|
||||
m_windowManager->DestroyClosedWindows();
|
||||
if (!m_windowManager->HasWindows()) {
|
||||
break;
|
||||
}
|
||||
|
||||
m_windowManager->RenderAllWindows();
|
||||
TickSmokeTest();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
Reference in New Issue
Block a user