refactor(new_editor): tighten app dependency boundaries

This commit is contained in:
2026-04-19 02:48:41 +08:00
parent 7429f22fb1
commit c59cd83c38
86 changed files with 1754 additions and 1077 deletions

View File

@@ -1,5 +1,6 @@
#include "Platform/Win32/EditorWindow.h"
#include "Platform/Win32/EditorWindowConstants.h"
#include "Platform/Win32/EditorWindowInternalState.h"
#include "Platform/Win32/EditorWindowRuntimeInternal.h"
#include "Platform/Win32/EditorWindowStyle.h"
#include "State/EditorContext.h"
@@ -127,7 +128,7 @@ std::uint8_t ResolveExpectedShellCaptureButtons(
EditorWindowFrameTransferRequests EditorWindow::RenderFrame(
EditorContext& editorContext,
bool globalTabDragActive) {
if (!m_render.ready || m_window.hwnd == nullptr) {
if (!m_state->render.ready || m_state->window.hwnd == nullptr) {
return {};
}
@@ -158,13 +159,13 @@ EditorWindowFrameTransferRequests EditorWindow::RenderFrame(
AppendBorderlessWindowChrome(drawList, width);
const Host::D3D12WindowRenderLoopPresentResult presentResult =
m_render.windowRenderLoop.Present(drawData);
m_state->render.windowRenderLoop.Present(drawData);
if (!presentResult.warning.empty()) {
LogRuntimeTrace("present", presentResult.warning);
}
m_render.autoScreenshot.CaptureIfRequested(
m_render.renderer,
m_state->render.autoScreenshot.CaptureIfRequested(
m_state->render.renderer,
drawData,
pixelWidth,
pixelHeight,
@@ -175,15 +176,15 @@ EditorWindowFrameTransferRequests EditorWindow::RenderFrame(
EditorWindowFrameTransferRequests EditorWindow::OnPaintMessage(
EditorContext& editorContext,
bool globalTabDragActive) {
if (!m_render.ready || m_window.hwnd == nullptr) {
if (!m_state->render.ready || m_state->window.hwnd == nullptr) {
return {};
}
PAINTSTRUCT paintStruct = {};
BeginPaint(m_window.hwnd, &paintStruct);
BeginPaint(m_state->window.hwnd, &paintStruct);
const EditorWindowFrameTransferRequests transferRequests =
RenderFrame(editorContext, globalTabDragActive);
EndPaint(m_window.hwnd, &paintStruct);
EndPaint(m_state->window.hwnd, &paintStruct);
return transferRequests;
}
@@ -210,40 +211,40 @@ EditorWindowFrameTransferRequests EditorWindow::RenderRuntimeFrame(
const UIRect& workspaceBounds,
UIDrawList& drawList) {
SyncShellCapturedPointerButtonsFromSystemState();
std::vector<UIInputEvent> frameEvents = std::move(m_input.pendingEvents);
m_input.pendingEvents.clear();
std::vector<UIInputEvent> frameEvents = std::move(m_state->input.pendingEvents);
m_state->input.pendingEvents.clear();
if (!frameEvents.empty() && IsVerboseRuntimeTraceEnabled()) {
LogRuntimeTrace(
"input",
DescribeInputEvents(frameEvents) + " | " +
editorContext.DescribeWorkspaceState(
m_composition.workspaceController,
m_composition.shellRuntime.GetShellInteractionState()));
m_state->composition.workspaceController,
m_state->composition.shellRuntime.GetShellInteractionState()));
}
const Host::D3D12WindowRenderLoopFrameContext frameContext =
m_render.windowRenderLoop.BeginFrame();
m_state->render.windowRenderLoop.BeginFrame();
if (!frameContext.warning.empty()) {
LogRuntimeTrace("viewport", frameContext.warning);
}
editorContext.AttachTextMeasurer(m_render.renderer);
editorContext.AttachTextMeasurer(m_state->render.renderer);
const bool useDetachedTitleBarTabStrip = ShouldUseDetachedTitleBarTabStrip();
m_composition.shellRuntime.Update(
m_state->composition.shellRuntime.Update(
editorContext,
m_composition.workspaceController,
m_state->composition.workspaceController,
workspaceBounds,
frameEvents,
BuildCaptureStatusText(),
m_window.primary
m_state->window.primary
? EditorShellVariant::Primary
: EditorShellVariant::DetachedWindow,
useDetachedTitleBarTabStrip,
useDetachedTitleBarTabStrip ? kBorderlessTitleBarHeightDips : 0.0f);
const UIEditorShellInteractionFrame& shellFrame =
m_composition.shellRuntime.GetShellFrame();
m_state->composition.shellRuntime.GetShellFrame();
const UIEditorDockHostInteractionState& dockHostInteractionState =
m_composition.shellRuntime
m_state->composition.shellRuntime
.GetShellInteractionState()
.workspaceInteractionState
.dockHostInteractionState;
@@ -253,14 +254,15 @@ EditorWindowFrameTransferRequests EditorWindow::RenderRuntimeFrame(
BuildShellTransferRequests(globalTabDragActive, dockHostInteractionState, shellFrame);
ApplyHostCaptureRequests(shellFrame.result);
for (const WorkspaceTraceEntry& entry : m_composition.shellRuntime.GetTraceEntries()) {
for (const WorkspaceTraceEntry& entry :
m_state->composition.shellRuntime.GetTraceEntries()) {
LogRuntimeTrace(entry.channel, entry.message);
}
ApplyHostedContentCaptureRequests();
ApplyCurrentCursor();
m_composition.shellRuntime.Append(drawList);
m_state->composition.shellRuntime.Append(drawList);
if (frameContext.canRenderViewports) {
m_composition.shellRuntime.RenderRequestedViewports(frameContext.renderContext);
m_state->composition.shellRuntime.RenderRequestedViewports(frameContext.renderContext);
}
return transferRequests;
}
@@ -301,7 +303,7 @@ void EditorWindow::LogFrameInteractionTrace(
<< " commandExecuted="
<< (shellFrame.result.workspaceResult.dockHostResult.commandExecuted ? "true" : "false")
<< " active="
<< m_composition.workspaceController.GetWorkspace().activePanelId
<< m_state->composition.workspaceController.GetWorkspace().activePanelId
<< " message="
<< shellFrame.result.workspaceResult.dockHostResult.layoutResult.message;
LogRuntimeTrace("frame", frameTrace.str());
@@ -339,33 +341,33 @@ EditorWindowFrameTransferRequests EditorWindow::BuildShellTransferRequests(
}
std::string EditorWindow::BuildCaptureStatusText() const {
if (m_render.autoScreenshot.HasPendingCapture()) {
if (m_state->render.autoScreenshot.HasPendingCapture()) {
return "Shot pending...";
}
if (!m_render.autoScreenshot.GetLastCaptureError().empty()) {
return TruncateText(m_render.autoScreenshot.GetLastCaptureError(), 38u);
if (!m_state->render.autoScreenshot.GetLastCaptureError().empty()) {
return TruncateText(m_state->render.autoScreenshot.GetLastCaptureError(), 38u);
}
if (!m_render.autoScreenshot.GetLastCaptureSummary().empty()) {
return TruncateText(m_render.autoScreenshot.GetLastCaptureSummary(), 38u);
if (!m_state->render.autoScreenshot.GetLastCaptureSummary().empty()) {
return TruncateText(m_state->render.autoScreenshot.GetLastCaptureSummary(), 38u);
}
return {};
}
void EditorWindow::SyncShellCapturedPointerButtonsFromSystemState() {
m_input.modifierTracker.SyncFromSystemState();
m_state->input.modifierTracker.SyncFromSystemState();
const std::uint8_t expectedButtons =
ResolveExpectedShellCaptureButtons(m_composition.shellRuntime);
ResolveExpectedShellCaptureButtons(m_state->composition.shellRuntime);
if (expectedButtons == 0u ||
HasPendingPointerStateReconciliationEvent(m_input.pendingEvents)) {
HasPendingPointerStateReconciliationEvent(m_state->input.pendingEvents)) {
return;
}
const UIInputModifiers modifiers =
m_input.modifierTracker.GetCurrentModifiers();
m_state->input.modifierTracker.GetCurrentModifiers();
if ((ButtonMaskFromModifiers(modifiers) & expectedButtons) == expectedButtons) {
return;
}
@@ -383,12 +385,12 @@ void EditorWindow::ApplyHostCaptureRequests(const UIEditorShellInteractionResult
}
void EditorWindow::ApplyHostedContentCaptureRequests() {
if (m_composition.shellRuntime.WantsHostPointerCapture()) {
if (m_state->composition.shellRuntime.WantsHostPointerCapture()) {
AcquirePointerCapture(EditorWindowPointerCaptureOwner::HostedContent);
}
if (m_composition.shellRuntime.WantsHostPointerRelease() &&
!m_composition.shellRuntime.HasShellInteractiveCapture()) {
if (m_state->composition.shellRuntime.WantsHostPointerRelease() &&
!m_state->composition.shellRuntime.HasShellInteractiveCapture()) {
ReleasePointerCapture(EditorWindowPointerCaptureOwner::HostedContent);
}
}