refactor(editor): isolate engine service boundaries

This commit is contained in:
2026-04-29 03:19:46 +08:00
parent ef11651ec2
commit 313a571e43
60 changed files with 3804 additions and 2611 deletions

View File

@@ -175,7 +175,7 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
m_hInstance = hInstance;
m_resourceService = std::make_unique<Host::Win32EditorResourceService>(m_hInstance);
m_runtimePaths = ResolveRuntimePaths(m_resourceService->GetExecutableDirectory());
m_engineServices = App::CreateEngineEditorServices();
m_engineComposition = App::CreateEngineEditorComposition();
EnableDpiAwareness();
const std::filesystem::path logRoot = m_resourceService->GetExecutableDirectory() / "logs";
@@ -186,11 +186,13 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
SetUnhandledExceptionFilter(&Application::HandleUnhandledException);
AppendUIEditorRuntimeTrace("app", "initialize begin");
if (m_engineServices == nullptr) {
if (m_engineComposition == nullptr) {
AppendUIEditorRuntimeTrace("app", "engine services initialization failed");
return false;
}
if (!m_editorContext->Initialize(m_runtimePaths, *m_engineServices)) {
if (!m_editorContext->Initialize(
m_runtimePaths,
m_engineComposition->GetSceneBackendFactory())) {
AppendUIEditorRuntimeTrace(
"app",
"editor context initialization failed: " +
@@ -217,16 +219,17 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
m_runtimePaths);
m_renderRuntimeFactory =
std::make_unique<Host::D3D12EditorWindowRenderRuntimeFactory>();
App::EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory =
[engineServices = m_engineServices.get()]() {
App::EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory = []() {
return App::CreateEditorWorkspaceShellRuntime(
App::CreateEditorWorkspacePanelRuntimeSet(),
App::CreateEditorIconService(),
App::CreateEditorViewportRuntimeServices(engineServices));
App::CreateEditorViewportRuntimeServices());
};
m_windowManager = std::make_unique<App::EditorWindowManager>(
*m_editorContext,
*m_engineServices,
m_engineComposition->GetSceneViewportBridge(),
m_engineComposition->GetGameViewportBridge(),
m_engineComposition->GetShaderProvider(),
*m_windowSystem,
*m_renderRuntimeFactory,
*m_resourceService,
@@ -318,9 +321,9 @@ void Application::Shutdown() {
}
m_systemInteractionHost.reset();
if (m_engineServices != nullptr) {
m_engineServices->Shutdown();
m_engineServices.reset();
if (m_engineComposition != nullptr) {
m_engineComposition->GetLifecycle().Shutdown();
m_engineComposition.reset();
}
if (m_windowClassAtom != 0 && m_hInstance != nullptr) {
@@ -394,8 +397,8 @@ int Application::Run(HINSTANCE hInstance, int nCmdShow) {
}
if (m_windowManager != nullptr) {
if (m_engineServices != nullptr) {
m_engineServices->UpdateAsyncLoads();
if (m_engineComposition != nullptr) {
m_engineComposition->GetLifecycle().UpdateAsyncLoads();
}
m_windowManager->DestroyClosedWindows();
if (!m_windowManager->HasWindows()) {