editor: switch workspace window sync to projection payload

This commit is contained in:
2026-04-26 01:39:03 +08:00
parent 306fa521ff
commit 67f52c69de
16 changed files with 371 additions and 90 deletions

View File

@@ -22,6 +22,7 @@ namespace {
constexpr const wchar_t* kWindowClassName = L"XCEditorShellHost";
constexpr const wchar_t* kWindowTitle = L"Main Scene * - Main.xx - XCEngine Editor";
constexpr DWORD kBorderlessWindowStyle = WS_POPUP | WS_THICKFRAME;
constexpr int kDefaultSmokeTestDurationSeconds = 12;
void EnableDpiAwareness() {
const HMODULE user32 = GetModuleHandleW(L"user32.dll");
@@ -152,6 +153,24 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
createParams.primary = true;
createParams.autoCaptureOnStartup =
App::IsEnvironmentFlagEnabled("XCUI_AUTO_CAPTURE_ON_STARTUP");
m_smokeTestEnabled = App::IsEnvironmentFlagEnabled("XCUIEDITOR_SMOKE_TEST");
m_smokeTestCloseRequested = false;
m_smokeTestRenderedFrameCount = 0;
m_smokeTestFrameLimit = m_smokeTestEnabled
? App::TryGetEnvironmentInt("XCUIEDITOR_SMOKE_TEST_FRAME_LIMIT").value_or(0)
: 0;
if (m_smokeTestFrameLimit < 0) {
m_smokeTestFrameLimit = 0;
}
int smokeTestDurationSeconds = m_smokeTestEnabled
? App::TryGetEnvironmentInt("XCUIEDITOR_SMOKE_TEST_DURATION_SECONDS")
.value_or(kDefaultSmokeTestDurationSeconds)
: 0;
if (smokeTestDurationSeconds < 0) {
smokeTestDurationSeconds = 0;
}
m_smokeTestDuration = std::chrono::seconds(smokeTestDurationSeconds);
m_smokeTestStartTime = {};
UIEditorWorkspaceController primaryWorkspaceController =
m_editorContext->BuildWorkspaceController();
std::string windowSystemError = {};
@@ -172,6 +191,13 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
}
AppendUIEditorRuntimeTrace("app", "initialize end");
if (m_smokeTestEnabled) {
m_smokeTestStartTime = std::chrono::steady_clock::now();
AppendUIEditorRuntimeTrace(
"smoke",
"enabled durationSeconds=" + std::to_string(smokeTestDurationSeconds) +
" frameLimit=" + std::to_string(m_smokeTestFrameLimit));
}
return true;
}
@@ -193,9 +219,16 @@ void Application::Shutdown() {
if (m_windowClassAtom != 0 && m_hInstance != nullptr) {
UnregisterClassW(kWindowClassName, m_hInstance);
m_windowClassAtom = 0;
m_windowClassAtom = 0;
}
m_smokeTestStartTime = {};
m_smokeTestDuration = std::chrono::milliseconds::zero();
m_smokeTestFrameLimit = 0;
m_smokeTestRenderedFrameCount = 0;
m_smokeTestEnabled = false;
m_smokeTestCloseRequested = false;
AppendUIEditorRuntimeTrace("app", "shutdown end");
ShutdownUIEditorRuntimeTrace();
}
@@ -256,6 +289,30 @@ int Application::Run(HINSTANCE hInstance, int nCmdShow) {
}
m_windowManager->RenderAllWindows();
if (m_smokeTestEnabled && !m_smokeTestCloseRequested) {
++m_smokeTestRenderedFrameCount;
const bool reachedFrameLimit =
m_smokeTestFrameLimit > 0 &&
m_smokeTestRenderedFrameCount >= m_smokeTestFrameLimit;
const bool reachedDuration =
m_smokeTestDuration.count() > 0 &&
m_smokeTestStartTime != std::chrono::steady_clock::time_point{} &&
(std::chrono::steady_clock::now() - m_smokeTestStartTime) >=
m_smokeTestDuration;
if (reachedFrameLimit || reachedDuration) {
AppendUIEditorRuntimeTrace(
"smoke",
"auto-exit requested after duration/frame limit");
m_smokeTestCloseRequested = true;
if (App::EditorWindow* primaryWindow = m_windowManager->FindPrimaryWindow();
primaryWindow != nullptr &&
primaryWindow->GetHwnd() != nullptr) {
PostMessageW(primaryWindow->GetHwnd(), WM_CLOSE, 0, 0);
} else {
PostQuitMessage(0);
}
}
}
} else {
break;
}