From c6e0973fe7caceca8bb55a133cb793d026196bc3 Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Sun, 5 Apr 2026 06:38:34 +0800 Subject: [PATCH] Tighten XCUI hosted preview frame contract --- docs/plan/XCUI_Phase_Status_2026-04-05.md | 4 +++- new_editor/src/XCUIBackend/ImGuiXCUIHostedPreviewPresenter.h | 4 +++- new_editor/src/XCUIBackend/XCUIHostedPreviewPresenter.h | 3 --- new_editor/src/panels/XCUIDemoPanel.cpp | 1 - new_editor/src/panels/XCUILayoutLabPanel.cpp | 1 - tests/NewEditor/test_xcui_hosted_preview_presenter.cpp | 2 -- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/docs/plan/XCUI_Phase_Status_2026-04-05.md b/docs/plan/XCUI_Phase_Status_2026-04-05.md index 221ac33e..b89288e2 100644 --- a/docs/plan/XCUI_Phase_Status_2026-04-05.md +++ b/docs/plan/XCUI_Phase_Status_2026-04-05.md @@ -68,12 +68,13 @@ Current gap: - The editor bridge layer now has smoke coverage for swapchain after-UI rendering hooks and SRV-backed ImGui texture descriptor registration. - `Application` no longer owns the ImGui backend directly; window presentation now routes through `IWindowUICompositor` with an `ImGuiWindowUICompositor` implementation, which currently delegates to `IEditorHostCompositor` / `ImGuiHostCompositor`. - The generic hosted-preview presenter contract no longer owns `ImGuiTransitionBackend`; the ImGui presenter now sits in a separate `ImGuiXCUIHostedPreviewPresenter` header while the native queue/surface registry remains XCUI-generic. +- The generic hosted-preview frame contract no longer carries an ImGui draw-list pointer; the legacy ImGui presenter resolves its inline draw target from the active ImGui window context instead of pushing that type through the XCUI contract. - `XCNewEditor` builds successfully to `build/new_editor/bin/Debug/XCNewEditor.exe`. Current gap: - The shell is still ImGui-hosted. -- The hosted-preview frame submission contract still carries an ImGui draw-list target for the legacy inline presenter path. +- Legacy hosted preview still depends on an active ImGui window context for inline presentation. - Editor-specialized widgets are still incomplete at the shared-module level: the authored prototypes exist, but virtualization, selection models, command routing, property editing models, toolbar/menu chrome, and icon-atlas widgets are not yet extracted into reusable XCUI modules. ## Validated This Phase @@ -140,6 +141,7 @@ Current gap: - Hosted preview contracts were tightened again: - generic preview surface metadata stays on XCUI-owned value types - `ImGuiTransitionBackend` moved behind `ImGuiXCUIHostedPreviewPresenter` + - generic preview frame submission no longer carries an ImGui draw-list pointer - panel/runtime callers still preserve the same legacy and native-preview behavior - `new_editor` panel/shell diagnostics improvements for hosted preview state. - XCUI asset document loading changed to prefer direct source compilation before `ResourceManager` fallback for the sandbox path, fixing the LayoutLab crash. diff --git a/new_editor/src/XCUIBackend/ImGuiXCUIHostedPreviewPresenter.h b/new_editor/src/XCUIBackend/ImGuiXCUIHostedPreviewPresenter.h index 09150c8e..7a6faa05 100644 --- a/new_editor/src/XCUIBackend/ImGuiXCUIHostedPreviewPresenter.h +++ b/new_editor/src/XCUIBackend/ImGuiXCUIHostedPreviewPresenter.h @@ -3,6 +3,8 @@ #include "XCUIBackend/ImGuiTransitionBackend.h" #include "XCUIBackend/XCUIHostedPreviewPresenter.h" +#include + #include namespace XCEngine { @@ -21,7 +23,7 @@ public: m_backend.Submit(*frame.drawData); m_lastStats.submittedDrawListCount = m_backend.GetPendingDrawListCount(); m_lastStats.submittedCommandCount = m_backend.GetPendingCommandCount(); - m_lastStats.presented = m_backend.EndFrame(frame.targetDrawList); + m_lastStats.presented = m_backend.EndFrame(ImGui::GetWindowDrawList()); m_lastStats.flushedDrawListCount = m_backend.GetLastFlushedDrawListCount(); m_lastStats.flushedCommandCount = m_backend.GetLastFlushedCommandCount(); return m_lastStats.presented; diff --git a/new_editor/src/XCUIBackend/XCUIHostedPreviewPresenter.h b/new_editor/src/XCUIBackend/XCUIHostedPreviewPresenter.h index 43698572..0cce20a2 100644 --- a/new_editor/src/XCUIBackend/XCUIHostedPreviewPresenter.h +++ b/new_editor/src/XCUIBackend/XCUIHostedPreviewPresenter.h @@ -10,15 +10,12 @@ #include #include -struct ImDrawList; - namespace XCEngine { namespace Editor { namespace XCUIBackend { struct XCUIHostedPreviewFrame { const ::XCEngine::UI::UIDrawData* drawData = nullptr; - ImDrawList* targetDrawList = nullptr; ::XCEngine::UI::UIRect canvasRect = {}; ::XCEngine::UI::UISize logicalSize = {}; const char* debugName = nullptr; diff --git a/new_editor/src/panels/XCUIDemoPanel.cpp b/new_editor/src/panels/XCUIDemoPanel.cpp index 52a48f20..da32f26a 100644 --- a/new_editor/src/panels/XCUIDemoPanel.cpp +++ b/new_editor/src/panels/XCUIDemoPanel.cpp @@ -298,7 +298,6 @@ void XCUIDemoPanel::Render() { if (m_hostedPreviewEnabled && m_previewPresenter != nullptr) { ::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewFrame previewFrame = {}; previewFrame.drawData = &frame.drawData; - previewFrame.targetDrawList = drawList; previewFrame.canvasRect = canvasRect; previewFrame.logicalSize = UI::UISize(canvasRect.width, canvasRect.height); previewFrame.debugName = kPreviewDebugName; diff --git a/new_editor/src/panels/XCUILayoutLabPanel.cpp b/new_editor/src/panels/XCUILayoutLabPanel.cpp index 35413586..67458533 100644 --- a/new_editor/src/panels/XCUILayoutLabPanel.cpp +++ b/new_editor/src/panels/XCUILayoutLabPanel.cpp @@ -247,7 +247,6 @@ void XCUILayoutLabPanel::Render() { if (m_hostedPreviewEnabled && m_previewPresenter != nullptr) { ::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewFrame previewFrame = {}; previewFrame.drawData = &frame.drawData; - previewFrame.targetDrawList = ImGui::GetWindowDrawList(); previewFrame.canvasRect = input.canvasRect; previewFrame.logicalSize = UI::UISize(input.canvasRect.width, input.canvasRect.height); previewFrame.debugName = kPreviewDebugName; diff --git a/tests/NewEditor/test_xcui_hosted_preview_presenter.cpp b/tests/NewEditor/test_xcui_hosted_preview_presenter.cpp index b835072a..edc79e7b 100644 --- a/tests/NewEditor/test_xcui_hosted_preview_presenter.cpp +++ b/tests/NewEditor/test_xcui_hosted_preview_presenter.cpp @@ -103,7 +103,6 @@ TEST(XCUIHostedPreviewPresenterTest, PresentFlushesDrawDataIntoProvidedImGuiDraw XCUIHostedPreviewFrame frame = {}; frame.drawData = &drawData; - frame.targetDrawList = targetDrawList; const bool presented = presenter->Present(frame); const XCUIHostedPreviewStats& stats = presenter->GetLastStats(); @@ -254,7 +253,6 @@ TEST(XCUIHostedPreviewPresenterTest, QueuedNativePresenterRejectsMissingDrawData XCUIHostedPreviewFrame frame = {}; frame.debugName = "Missing DrawData"; - frame.targetDrawList = reinterpret_cast(1); EXPECT_FALSE(presenter->Present(frame));