2026-04-05 04:55:25 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "panels/XCUIDemoPanel.h"
|
|
|
|
|
#include "panels/XCUILayoutLabPanel.h"
|
|
|
|
|
|
|
|
|
|
#include "Platform/D3D12WindowRenderer.h"
|
|
|
|
|
#include "Rendering/MainWindowNativeBackdropRenderer.h"
|
2026-04-05 06:15:24 +08:00
|
|
|
#include "XCUIBackend/IWindowUICompositor.h"
|
2026-04-05 04:55:25 +08:00
|
|
|
#include "XCUIBackend/XCUIHostedPreviewPresenter.h"
|
|
|
|
|
#include "XCUIBackend/XCUIInputBridge.h"
|
|
|
|
|
#include "XCUIBackend/XCUILayoutLabRuntime.h"
|
|
|
|
|
#include "XCUIBackend/XCUIRHIRenderBackend.h"
|
|
|
|
|
#include "XCUIBackend/XCUIStandaloneTextAtlasProvider.h"
|
|
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace NewEditor {
|
|
|
|
|
|
|
|
|
|
class Application {
|
|
|
|
|
public:
|
|
|
|
|
int Run(HINSTANCE instance, int nCmdShow);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
struct HostedPreviewPanelDiagnostics {
|
|
|
|
|
std::string debugName = {};
|
|
|
|
|
std::string debugSource = {};
|
|
|
|
|
bool visible = false;
|
|
|
|
|
bool hostedPreviewEnabled = false;
|
|
|
|
|
bool nativeRequested = false;
|
|
|
|
|
bool nativePresenterBound = false;
|
|
|
|
|
bool descriptorAvailable = false;
|
|
|
|
|
bool surfaceImageAvailable = false;
|
|
|
|
|
bool surfaceAllocated = false;
|
|
|
|
|
bool surfaceReady = false;
|
|
|
|
|
bool presentedThisFrame = false;
|
|
|
|
|
bool queuedToNativePassThisFrame = false;
|
|
|
|
|
std::uint32_t surfaceWidth = 0;
|
|
|
|
|
std::uint32_t surfaceHeight = 0;
|
|
|
|
|
float logicalWidth = 0.0f;
|
|
|
|
|
float logicalHeight = 0.0f;
|
|
|
|
|
std::size_t queuedFrameIndex = 0;
|
|
|
|
|
std::size_t submittedDrawListCount = 0;
|
|
|
|
|
std::size_t submittedCommandCount = 0;
|
|
|
|
|
std::size_t flushedDrawListCount = 0;
|
|
|
|
|
std::size_t flushedCommandCount = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct HostedPreviewOffscreenSurface {
|
|
|
|
|
std::string debugName = {};
|
|
|
|
|
std::uint32_t width = 0;
|
|
|
|
|
std::uint32_t height = 0;
|
|
|
|
|
::XCEngine::RHI::RHITexture* colorTexture = nullptr;
|
|
|
|
|
::XCEngine::RHI::RHIResourceView* colorView = nullptr;
|
2026-04-05 06:43:51 +08:00
|
|
|
::XCEngine::Editor::XCUIBackend::UITextureRegistration textureRegistration = {};
|
2026-04-05 04:55:25 +08:00
|
|
|
::XCEngine::RHI::ResourceStates colorState = ::XCEngine::RHI::ResourceStates::Common;
|
|
|
|
|
|
|
|
|
|
bool IsReady() const {
|
|
|
|
|
return !debugName.empty() &&
|
|
|
|
|
colorTexture != nullptr &&
|
|
|
|
|
colorView != nullptr &&
|
2026-04-05 06:43:51 +08:00
|
|
|
textureRegistration.IsValid() &&
|
2026-04-05 04:55:25 +08:00
|
|
|
width > 0u &&
|
|
|
|
|
height > 0u;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static LRESULT CALLBACK StaticWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
|
|
|
|
|
bool CreateMainWindow(HINSTANCE instance, int nCmdShow);
|
|
|
|
|
bool InitializeRenderer();
|
2026-04-05 06:15:24 +08:00
|
|
|
void InitializeWindowCompositor();
|
|
|
|
|
void ShutdownWindowCompositor();
|
2026-04-05 04:55:25 +08:00
|
|
|
void ShutdownRenderer();
|
|
|
|
|
void DestroyHostedPreviewSurfaces();
|
|
|
|
|
void SyncHostedPreviewSurfaces();
|
|
|
|
|
std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIHostedPreviewPresenter> CreateHostedPreviewPresenter(
|
|
|
|
|
bool nativePreview);
|
|
|
|
|
void ConfigureHostedPreviewPresenters();
|
|
|
|
|
HostedPreviewPanelDiagnostics BuildHostedPreviewPanelDiagnostics(
|
|
|
|
|
const char* debugName,
|
|
|
|
|
const char* fallbackDebugSource,
|
|
|
|
|
bool visible,
|
|
|
|
|
bool hostedPreviewEnabled,
|
|
|
|
|
bool nativeRequested,
|
|
|
|
|
bool nativePresenterBound,
|
|
|
|
|
const ::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewStats& previewStats) const;
|
|
|
|
|
HostedPreviewOffscreenSurface* FindHostedPreviewSurface(const std::string& debugName);
|
|
|
|
|
const HostedPreviewOffscreenSurface* FindHostedPreviewSurface(const std::string& debugName) const;
|
|
|
|
|
HostedPreviewOffscreenSurface& FindOrAddHostedPreviewSurface(const std::string& debugName);
|
|
|
|
|
bool EnsureHostedPreviewSurface(
|
|
|
|
|
HostedPreviewOffscreenSurface& previewSurface,
|
|
|
|
|
std::uint32_t width,
|
|
|
|
|
std::uint32_t height);
|
|
|
|
|
bool RenderHostedPreviewOffscreenSurface(
|
|
|
|
|
HostedPreviewOffscreenSurface& previewSurface,
|
|
|
|
|
const ::XCEngine::Rendering::RenderContext& renderContext,
|
|
|
|
|
const ::XCEngine::UI::UIDrawData& drawData);
|
|
|
|
|
void RenderShellChrome();
|
|
|
|
|
void RenderHostedPreviewHud();
|
|
|
|
|
void RenderQueuedHostedPreviews(
|
|
|
|
|
const ::XCEngine::Rendering::RenderContext& renderContext,
|
|
|
|
|
const ::XCEngine::Rendering::RenderSurface& surface);
|
|
|
|
|
void Frame();
|
|
|
|
|
|
|
|
|
|
HWND m_hwnd = nullptr;
|
|
|
|
|
::XCEngine::Editor::Platform::D3D12WindowRenderer m_windowRenderer;
|
2026-04-05 06:15:24 +08:00
|
|
|
std::unique_ptr<::XCEngine::Editor::XCUIBackend::IWindowUICompositor> m_windowCompositor;
|
2026-04-05 04:55:25 +08:00
|
|
|
std::unique_ptr<XCUIDemoPanel> m_demoPanel;
|
|
|
|
|
std::unique_ptr<XCUILayoutLabPanel> m_layoutLabPanel;
|
|
|
|
|
::XCEngine::Editor::XCUIBackend::XCUIWin32InputSource m_xcuiInputSource;
|
|
|
|
|
::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewQueue m_hostedPreviewQueue;
|
|
|
|
|
::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewSurfaceRegistry m_hostedPreviewSurfaceRegistry;
|
|
|
|
|
::XCEngine::Editor::XCUIBackend::XCUIStandaloneTextAtlasProvider m_hostedPreviewTextAtlasProvider;
|
|
|
|
|
::XCEngine::Editor::XCUIBackend::XCUIRHIRenderBackend m_hostedPreviewRenderBackend;
|
|
|
|
|
std::vector<HostedPreviewOffscreenSurface> m_hostedPreviewSurfaces = {};
|
|
|
|
|
::XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime m_nativeOverlayRuntime;
|
|
|
|
|
MainWindowNativeBackdropRenderer m_nativeBackdropRenderer;
|
|
|
|
|
bool m_showImGuiDemoWindow = false;
|
|
|
|
|
bool m_showNativeBackdrop = true;
|
|
|
|
|
bool m_pulseNativeBackdropAccent = true;
|
|
|
|
|
bool m_showNativeXCUIOverlay = true;
|
|
|
|
|
bool m_showHostedPreviewHud = true;
|
|
|
|
|
bool m_showNativeDemoPanelPreview = true;
|
|
|
|
|
bool m_showNativeLayoutLabPreview = false;
|
|
|
|
|
bool m_running = false;
|
|
|
|
|
bool m_renderReady = false;
|
|
|
|
|
std::chrono::steady_clock::time_point m_startTime = {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace NewEditor
|
|
|
|
|
} // namespace XCEngine
|