Add XCUI window compositor seam
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "Application.h"
|
||||
|
||||
#include "XCUIBackend/ImGuiWindowUICompositor.h"
|
||||
|
||||
#include <XCEngine/Core/Asset/ResourceManager.h>
|
||||
|
||||
#include <imgui.h>
|
||||
@@ -179,7 +181,7 @@ int Application::Run(HINSTANCE instance, int nCmdShow) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
InitializeImGui();
|
||||
InitializeWindowCompositor();
|
||||
m_demoPanel = std::make_unique<XCUIDemoPanel>(
|
||||
&m_xcuiInputSource,
|
||||
CreateHostedPreviewPresenter(m_showNativeDemoPanelPreview));
|
||||
@@ -210,7 +212,7 @@ int Application::Run(HINSTANCE instance, int nCmdShow) {
|
||||
|
||||
m_demoPanel.reset();
|
||||
m_layoutLabPanel.reset();
|
||||
ShutdownImGui();
|
||||
ShutdownWindowCompositor();
|
||||
ShutdownRenderer();
|
||||
resourceManager.Shutdown();
|
||||
return static_cast<int>(message.wParam);
|
||||
@@ -232,7 +234,8 @@ LRESULT CALLBACK Application::StaticWndProc(HWND hwnd, UINT message, WPARAM wPar
|
||||
LRESULT Application::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
m_xcuiInputSource.HandleWindowMessage(hwnd, message, wParam, lParam);
|
||||
|
||||
if (::XCEngine::Editor::UI::ImGuiBackendBridge::HandleWindowMessage(hwnd, message, wParam, lParam)) {
|
||||
if (m_windowCompositor != nullptr &&
|
||||
m_windowCompositor->HandleWindowMessage(hwnd, message, wParam, lParam)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -313,28 +316,22 @@ bool Application::InitializeRenderer() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
void Application::InitializeImGui() {
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||
|
||||
ConfigureFonts();
|
||||
ImGui::StyleColorsDark();
|
||||
m_imguiBackend.Initialize(
|
||||
m_hwnd,
|
||||
m_windowRenderer.GetDevice(),
|
||||
m_windowRenderer.GetCommandQueue(),
|
||||
m_windowRenderer.GetSrvHeap(),
|
||||
m_windowRenderer.GetSrvDescriptorSize(),
|
||||
m_windowRenderer.GetSrvDescriptorCount());
|
||||
void Application::InitializeWindowCompositor() {
|
||||
m_windowCompositor = ::XCEngine::Editor::XCUIBackend::CreateImGuiWindowUICompositor();
|
||||
if (m_windowCompositor != nullptr) {
|
||||
m_windowCompositor->Initialize(
|
||||
m_hwnd,
|
||||
m_windowRenderer,
|
||||
[]() { ConfigureFonts(); });
|
||||
}
|
||||
}
|
||||
|
||||
void Application::ShutdownImGui() {
|
||||
void Application::ShutdownWindowCompositor() {
|
||||
DestroyHostedPreviewSurfaces();
|
||||
m_imguiBackend.Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
if (m_windowCompositor != nullptr) {
|
||||
m_windowCompositor->Shutdown();
|
||||
m_windowCompositor.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::ShutdownRenderer() {
|
||||
@@ -347,7 +344,11 @@ void Application::ShutdownRenderer() {
|
||||
void Application::DestroyHostedPreviewSurfaces() {
|
||||
for (HostedPreviewOffscreenSurface& previewSurface : m_hostedPreviewSurfaces) {
|
||||
if (previewSurface.imguiCpuHandle.ptr != 0) {
|
||||
m_imguiBackend.FreeTextureDescriptor(previewSurface.imguiCpuHandle, previewSurface.imguiGpuHandle);
|
||||
if (m_windowCompositor != nullptr) {
|
||||
m_windowCompositor->FreeTextureDescriptor(
|
||||
previewSurface.imguiCpuHandle,
|
||||
previewSurface.imguiGpuHandle);
|
||||
}
|
||||
}
|
||||
ShutdownAndDelete(previewSurface.colorView);
|
||||
ShutdownAndDelete(previewSurface.colorTexture);
|
||||
@@ -435,7 +436,11 @@ bool Application::EnsureHostedPreviewSurface(
|
||||
}
|
||||
|
||||
if (previewSurface.imguiCpuHandle.ptr != 0) {
|
||||
m_imguiBackend.FreeTextureDescriptor(previewSurface.imguiCpuHandle, previewSurface.imguiGpuHandle);
|
||||
if (m_windowCompositor != nullptr) {
|
||||
m_windowCompositor->FreeTextureDescriptor(
|
||||
previewSurface.imguiCpuHandle,
|
||||
previewSurface.imguiGpuHandle);
|
||||
}
|
||||
}
|
||||
ShutdownAndDelete(previewSurface.colorView);
|
||||
ShutdownAndDelete(previewSurface.colorTexture);
|
||||
@@ -474,7 +479,8 @@ bool Application::EnsureHostedPreviewSurface(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_imguiBackend.CreateTextureDescriptor(
|
||||
if (m_windowCompositor == nullptr ||
|
||||
!m_windowCompositor->CreateTextureDescriptor(
|
||||
m_windowRenderer.GetRHIDevice(),
|
||||
previewSurface.colorTexture,
|
||||
&previewSurface.imguiCpuHandle,
|
||||
@@ -867,24 +873,27 @@ void Application::Frame() {
|
||||
m_hostedPreviewQueue.BeginFrame();
|
||||
m_hostedPreviewSurfaceRegistry.BeginFrame();
|
||||
SyncHostedPreviewSurfaces();
|
||||
m_imguiBackend.BeginFrame();
|
||||
RenderShellChrome();
|
||||
if (m_demoPanel) {
|
||||
m_demoPanel->RenderIfVisible();
|
||||
}
|
||||
if (m_layoutLabPanel) {
|
||||
m_layoutLabPanel->RenderIfVisible();
|
||||
}
|
||||
if (m_showImGuiDemoWindow) {
|
||||
ImGui::ShowDemoWindow(&m_showImGuiDemoWindow);
|
||||
if (m_windowCompositor == nullptr) {
|
||||
m_xcuiInputSource.ClearFrameTransients();
|
||||
return;
|
||||
}
|
||||
|
||||
SyncHostedPreviewSurfaces();
|
||||
|
||||
ImGui::Render();
|
||||
m_windowRenderer.Render(
|
||||
m_imguiBackend,
|
||||
m_windowCompositor->RenderFrame(
|
||||
kClearColor,
|
||||
[this]() {
|
||||
RenderShellChrome();
|
||||
if (m_demoPanel) {
|
||||
m_demoPanel->RenderIfVisible();
|
||||
}
|
||||
if (m_layoutLabPanel) {
|
||||
m_layoutLabPanel->RenderIfVisible();
|
||||
}
|
||||
if (m_showImGuiDemoWindow) {
|
||||
ImGui::ShowDemoWindow(&m_showImGuiDemoWindow);
|
||||
}
|
||||
|
||||
SyncHostedPreviewSurfaces();
|
||||
},
|
||||
[this](
|
||||
const ::XCEngine::Rendering::RenderContext& renderContext,
|
||||
const ::XCEngine::Rendering::RenderSurface& surface) {
|
||||
|
||||
Reference in New Issue
Block a user