Checkpoint current new editor host iteration
This commit is contained in:
@@ -36,6 +36,7 @@ constexpr const wchar_t* kWindowClassName = L"XCEditorShellHost";
|
||||
constexpr const wchar_t* kWindowTitle = L"Main Scene * - Main.xx - XCEngine Editor";
|
||||
constexpr UINT kDefaultDpi = 96u;
|
||||
constexpr float kBaseDpiScale = 96.0f;
|
||||
constexpr UINT kDeferredRenderMessage = WM_APP + 1u;
|
||||
|
||||
bool ResolveVerboseRuntimeTraceEnabled() {
|
||||
wchar_t buffer[8] = {};
|
||||
@@ -541,6 +542,8 @@ void Application::RenderFrame() {
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyPendingWindowResize();
|
||||
|
||||
RECT clientRect = {};
|
||||
GetClientRect(m_hwnd, &clientRect);
|
||||
const unsigned int pixelWidth =
|
||||
@@ -607,7 +610,7 @@ void Application::RenderFrame() {
|
||||
ApplyHostedContentCaptureRequests();
|
||||
ApplyCurrentCursor();
|
||||
m_editorWorkspace.Append(drawList);
|
||||
if (d3d12FrameBegun && !m_inInteractiveResize) {
|
||||
if (d3d12FrameBegun) {
|
||||
m_editorWorkspace.RenderRequestedViewports(m_windowRenderer.GetRenderContext());
|
||||
}
|
||||
} else {
|
||||
@@ -760,36 +763,51 @@ std::string Application::DescribeInputEvents(
|
||||
}
|
||||
|
||||
void Application::OnResize() {
|
||||
QueueCurrentClientResize();
|
||||
}
|
||||
|
||||
void Application::OnEnterSizeMove() {
|
||||
m_inInteractiveResize = true;
|
||||
}
|
||||
|
||||
void Application::OnExitSizeMove() {
|
||||
m_inInteractiveResize = false;
|
||||
QueueCurrentClientResize();
|
||||
}
|
||||
|
||||
void Application::QueueWindowResize(UINT width, UINT height) {
|
||||
if (width == 0u || height == 0u) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_pendingWindowResizeWidth = width;
|
||||
m_pendingWindowResizeHeight = height;
|
||||
m_hasPendingWindowResize = true;
|
||||
}
|
||||
|
||||
void Application::QueueCurrentClientResize() {
|
||||
UINT width = 0u;
|
||||
UINT height = 0u;
|
||||
if (!QueryCurrentClientPixelSize(width, height)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_renderer.Resize(width, height);
|
||||
CommitWindowResize();
|
||||
if (m_inInteractiveResize) {
|
||||
m_editorWorkspace.SetViewportSurfacePresentationEnabled(false);
|
||||
QueueWindowResize(width, height);
|
||||
}
|
||||
|
||||
bool Application::ApplyPendingWindowResize() {
|
||||
if (!m_hasPendingWindowResize) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Application::OnEnterSizeMove() {
|
||||
m_inInteractiveResize = true;
|
||||
m_editorWorkspace.SetViewportSurfacePresentationEnabled(false);
|
||||
}
|
||||
|
||||
void Application::OnExitSizeMove() {
|
||||
m_inInteractiveResize = false;
|
||||
CommitWindowResize();
|
||||
}
|
||||
|
||||
bool Application::CommitWindowResize() {
|
||||
UINT width = 0u;
|
||||
UINT height = 0u;
|
||||
if (!QueryCurrentClientPixelSize(width, height)) {
|
||||
const UINT width = m_pendingWindowResizeWidth;
|
||||
const UINT height = m_pendingWindowResizeHeight;
|
||||
m_hasPendingWindowResize = false;
|
||||
if (width == 0u || height == 0u) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_renderer.Resize(width, height);
|
||||
m_renderer.DetachWindowRenderer();
|
||||
const bool resizedWindowRenderer =
|
||||
m_windowRenderer.Resize(static_cast<int>(width), static_cast<int>(height));
|
||||
@@ -816,6 +834,15 @@ bool Application::CommitWindowResize() {
|
||||
return hasHealthyD3D12WindowInterop;
|
||||
}
|
||||
|
||||
void Application::RequestDeferredRenderFrame() {
|
||||
if (m_hwnd == nullptr || !IsWindow(m_hwnd) || m_renderFrameQueued) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_renderFrameQueued = true;
|
||||
PostMessageW(m_hwnd, kDeferredRenderMessage, 0, 0);
|
||||
}
|
||||
|
||||
bool Application::QueryCurrentClientPixelSize(UINT& outWidth, UINT& outHeight) const {
|
||||
outWidth = 0u;
|
||||
outHeight = 0u;
|
||||
@@ -844,16 +871,18 @@ void Application::OnDpiChanged(UINT dpi, const RECT& suggestedRect) {
|
||||
m_dpiScale = GetDpiScale();
|
||||
m_renderer.SetDpiScale(m_dpiScale);
|
||||
if (m_hwnd != nullptr) {
|
||||
const LONG windowWidth = suggestedRect.right - suggestedRect.left;
|
||||
const LONG windowHeight = suggestedRect.bottom - suggestedRect.top;
|
||||
SetWindowPos(
|
||||
m_hwnd,
|
||||
nullptr,
|
||||
suggestedRect.left,
|
||||
suggestedRect.top,
|
||||
suggestedRect.right - suggestedRect.left,
|
||||
suggestedRect.bottom - suggestedRect.top,
|
||||
windowWidth,
|
||||
windowHeight,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
CommitWindowResize();
|
||||
InvalidateRect(m_hwnd, nullptr, FALSE);
|
||||
QueueCurrentClientResize();
|
||||
RequestDeferredRenderFrame();
|
||||
}
|
||||
|
||||
std::ostringstream trace = {};
|
||||
@@ -1011,16 +1040,23 @@ LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT message, WPARAM wParam, LP
|
||||
case WM_EXITSIZEMOVE:
|
||||
if (application != nullptr) {
|
||||
application->OnExitSizeMove();
|
||||
application->RenderFrame();
|
||||
application->RequestDeferredRenderFrame();
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case WM_SIZE:
|
||||
if (application != nullptr && wParam != SIZE_MINIMIZED) {
|
||||
application->OnResize();
|
||||
application->RenderFrame();
|
||||
application->RequestDeferredRenderFrame();
|
||||
}
|
||||
return 0;
|
||||
case kDeferredRenderMessage:
|
||||
if (application != nullptr) {
|
||||
application->m_renderFrameQueued = false;
|
||||
application->RenderFrame();
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case WM_PAINT:
|
||||
if (application != nullptr) {
|
||||
PAINTSTRUCT paintStruct = {};
|
||||
|
||||
Reference in New Issue
Block a user