Reuse panel frame composition in native XCUI shell

This commit is contained in:
2026-04-05 17:41:31 +08:00
parent 63b5f12b93
commit 3db09ea5d0
10 changed files with 651 additions and 954 deletions

View File

@@ -7,11 +7,47 @@
#include "XCUIBackend/XCUIPanelCanvasHost.h"
#include "XCUIBackend/XCUIDemoRuntime.h"
#include <cstdint>
#include <memory>
#include <string>
namespace XCEngine {
namespace NewEditor {
struct XCUIDemoPanelFrameComposeOptions {
float canvasHeight = 0.0f;
float canvasTopInset = 0.0f;
bool hostedPreviewEnabled = true;
bool showCanvasHud = true;
bool showDebugRects = true;
std::uint64_t timestampNanoseconds = 0;
const char* canvasChildId = "XCUIDemoCanvasHost";
const ::XCEngine::Editor::XCUIBackend::XCUIInputBridgeFrameSnapshot* inputSnapshot = nullptr;
bool useDefaultPlaceholder = true;
const char* placeholderTitle = nullptr;
const char* placeholderSubtitle = nullptr;
bool drawPreviewFrame = true;
const char* badgeTitle = nullptr;
const char* badgeSubtitle = nullptr;
};
struct XCUIDemoPanelFrameComposition {
::XCEngine::Editor::XCUIBackend::XCUIPanelCanvasSession canvasSession = {};
::XCEngine::Editor::XCUIBackend::XCUIInputBridgeFrameSnapshot inputSnapshot = {};
::XCEngine::Editor::XCUIBackend::XCUIInputBridgeFrameDelta inputDelta = {};
::XCEngine::Editor::XCUIBackend::XCUIDemoInputState input = {};
const ::XCEngine::Editor::XCUIBackend::XCUIDemoFrameResult* frame = nullptr;
::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewStats previewStats = {};
::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewSurfaceDescriptor hostedSurfaceDescriptor = {};
::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewSurfaceImage hostedSurfaceImage = {};
bool hostedPreviewEnabled = false;
bool nativeHostedPreview = false;
bool hasHostedSurfaceDescriptor = false;
bool showHostedSurfaceImage = false;
std::string previewPathLabel = {};
std::string previewStateLabel = {};
};
class XCUIDemoPanel : public Panel {
public:
explicit XCUIDemoPanel(
@@ -23,6 +59,8 @@ public:
~XCUIDemoPanel() override = default;
void Render() override;
const XCUIDemoPanelFrameComposition& ComposeFrame(
const XCUIDemoPanelFrameComposeOptions& options = XCUIDemoPanelFrameComposeOptions());
void SetHostedPreviewEnabled(bool enabled);
void SetHostedPreviewPresenter(
std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIHostedPreviewPresenter> previewPresenter);
@@ -32,6 +70,8 @@ public:
bool IsUsingNativeHostedPreview() const;
const ::XCEngine::Editor::XCUIBackend::XCUIDemoFrameResult& GetFrameResult() const;
const ::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewStats& GetLastPreviewStats() const;
const XCUIDemoPanelFrameComposition& GetLastFrameComposition() const;
bool GetLastReloadSucceeded() const { return m_lastReloadSucceeded; }
private:
bool m_lastReloadSucceeded = false;
@@ -44,6 +84,7 @@ private:
std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIHostedPreviewPresenter> m_previewPresenter;
std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIPanelCanvasHost> m_canvasHost;
::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewStats m_lastPreviewStats = {};
XCUIDemoPanelFrameComposition m_lastFrameComposition = {};
};
} // namespace NewEditor