Split XCUI hosted preview ImGui presenter seam

This commit is contained in:
2026-04-05 06:34:15 +08:00
parent 6159eef3af
commit 9525053624
7 changed files with 142 additions and 83 deletions

View File

@@ -0,0 +1,45 @@
#pragma once
#include "XCUIBackend/ImGuiTransitionBackend.h"
#include "XCUIBackend/XCUIHostedPreviewPresenter.h"
#include <memory>
namespace XCEngine {
namespace Editor {
namespace XCUIBackend {
class ImGuiXCUIHostedPreviewPresenter final : public IXCUIHostedPreviewPresenter {
public:
bool Present(const XCUIHostedPreviewFrame& frame) override {
m_lastStats = {};
if (frame.drawData == nullptr) {
return false;
}
m_backend.BeginFrame();
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.flushedDrawListCount = m_backend.GetLastFlushedDrawListCount();
m_lastStats.flushedCommandCount = m_backend.GetLastFlushedCommandCount();
return m_lastStats.presented;
}
const XCUIHostedPreviewStats& GetLastStats() const override {
return m_lastStats;
}
private:
ImGuiTransitionBackend m_backend = {};
XCUIHostedPreviewStats m_lastStats = {};
};
inline std::unique_ptr<IXCUIHostedPreviewPresenter> CreateImGuiXCUIHostedPreviewPresenter() {
return std::make_unique<ImGuiXCUIHostedPreviewPresenter>();
}
} // namespace XCUIBackend
} // namespace Editor
} // namespace XCEngine