Refactor new editor host resize pipeline

This commit is contained in:
2026-04-13 23:09:02 +08:00
parent 712f99e723
commit 4362008b39
17 changed files with 1481 additions and 929 deletions

View File

@@ -478,6 +478,7 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
"app",
"workspace initialized: " +
m_editorContext.DescribeWorkspaceState(m_editorWorkspace.GetShellInteractionState()));
m_renderReady = true;
ShowWindow(m_hwnd, nCmdShow);
UpdateWindow(m_hwnd);
@@ -493,6 +494,7 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
void Application::Shutdown() {
LogRuntimeTrace("app", "shutdown begin");
m_renderReady = false;
if (GetCapture() == m_hwnd) {
ReleaseCapture();
}
@@ -518,12 +520,10 @@ void Application::Shutdown() {
}
void Application::RenderFrame() {
if (m_hwnd == nullptr) {
if (!m_renderReady || m_hwnd == nullptr) {
return;
}
ApplyPendingWindowResize();
RECT clientRect = {};
GetClientRect(m_hwnd, &clientRect);
const unsigned int pixelWidth =
@@ -620,13 +620,8 @@ void Application::RenderFrame() {
presentResult.framePresented);
}
void Application::OnDeferredRenderMessage() {
m_hostRuntime.ClearDeferredRenderRequest();
RenderFrame();
}
void Application::OnPaintMessage() {
if (m_hwnd == nullptr) {
if (!m_renderReady || m_hwnd == nullptr) {
return;
}
@@ -747,8 +742,8 @@ std::string Application::DescribeInputEvents(
return stream.str();
}
void Application::OnResize() {
QueueCurrentClientResize();
void Application::OnResize(UINT width, UINT height) {
ApplyWindowResize(width, height);
}
void Application::OnEnterSizeMove() {
@@ -757,28 +752,16 @@ void Application::OnEnterSizeMove() {
void Application::OnExitSizeMove() {
m_hostRuntime.EndInteractiveResize();
QueueCurrentClientResize();
}
void Application::QueueWindowResize(UINT width, UINT height) {
m_hostRuntime.QueueWindowResize(width, height);
}
void Application::QueueCurrentClientResize() {
UINT width = 0u;
UINT height = 0u;
if (!QueryCurrentClientPixelSize(width, height)) {
return;
if (QueryCurrentClientPixelSize(width, height)) {
ApplyWindowResize(width, height);
}
QueueWindowResize(width, height);
}
bool Application::ApplyPendingWindowResize() {
UINT width = 0u;
UINT height = 0u;
if (!m_hostRuntime.ConsumePendingWindowResize(width, height)) {
return true;
bool Application::ApplyWindowResize(UINT width, UINT height) {
if (!m_renderReady || width == 0u || height == 0u) {
return false;
}
const Host::D3D12WindowRenderLoopResizeResult resizeResult =
@@ -834,7 +817,11 @@ void Application::OnDpiChanged(UINT dpi, const RECT& suggestedRect) {
windowWidth,
windowHeight,
SWP_NOZORDER | SWP_NOACTIVATE);
QueueCurrentClientResize();
UINT clientWidth = 0u;
UINT clientHeight = 0u;
if (QueryCurrentClientPixelSize(clientWidth, clientHeight)) {
ApplyWindowResize(clientWidth, clientHeight);
}
}
std::ostringstream trace = {};