Add XCUI new editor sandbox phase 1
This commit is contained in:
140
new_editor/src/Application.h
Normal file
140
new_editor/src/Application.h
Normal file
@@ -0,0 +1,140 @@
|
||||
#pragma once
|
||||
|
||||
#include "panels/XCUIDemoPanel.h"
|
||||
#include "panels/XCUILayoutLabPanel.h"
|
||||
|
||||
#include "Platform/D3D12WindowRenderer.h"
|
||||
#include "Rendering/MainWindowNativeBackdropRenderer.h"
|
||||
#include "UI/ImGuiBackendBridge.h"
|
||||
#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;
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE imguiCpuHandle = {};
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE imguiGpuHandle = {};
|
||||
ImTextureID imguiTextureId = {};
|
||||
::XCEngine::RHI::ResourceStates colorState = ::XCEngine::RHI::ResourceStates::Common;
|
||||
|
||||
bool IsReady() const {
|
||||
return !debugName.empty() &&
|
||||
colorTexture != nullptr &&
|
||||
colorView != nullptr &&
|
||||
imguiTextureId != ImTextureID{} &&
|
||||
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();
|
||||
void InitializeImGui();
|
||||
void ShutdownImGui();
|
||||
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;
|
||||
::XCEngine::Editor::UI::ImGuiBackendBridge m_imguiBackend;
|
||||
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
|
||||
Reference in New Issue
Block a user