Refactor editor rendering contracts
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include <utility>
|
||||
#include "Panels/EditorPanelIds.h"
|
||||
#include <XCEngine/Input/InputTypes.h>
|
||||
#include "Assets/BuiltInIcons.h"
|
||||
#include "Assets/EditorIconService.h"
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "EditorShellDrawComposer.h"
|
||||
|
||||
#include "WorkspacePanels/EditorWorkspacePanelRuntime.h"
|
||||
#include "Assets/BuiltInIcons.h"
|
||||
#include "Assets/EditorIconService.h"
|
||||
|
||||
#include <XCEditor/Foundation/UIEditorTheme.h>
|
||||
#include <XCEditor/Shell/UIEditorShellInteraction.h>
|
||||
@@ -18,16 +18,16 @@ using ::XCEngine::UI::UIDrawList;
|
||||
|
||||
class BuiltInIconResolver final : public UIEditorShellIconResolver {
|
||||
public:
|
||||
explicit BuiltInIconResolver(const BuiltInIcons& icons)
|
||||
: m_icons(icons) {}
|
||||
explicit BuiltInIconResolver(const EditorIconService& iconService)
|
||||
: m_iconService(iconService) {}
|
||||
|
||||
const ::XCEngine::UI::UITextureHandle* TryResolveIcon(
|
||||
std::uint8_t iconKind) const override {
|
||||
return &m_icons.Resolve(static_cast<BuiltInIconKind>(iconKind));
|
||||
return &m_iconService.Resolve(static_cast<BuiltInIconKind>(iconKind));
|
||||
}
|
||||
|
||||
private:
|
||||
const BuiltInIcons& m_icons;
|
||||
const EditorIconService& m_iconService;
|
||||
};
|
||||
|
||||
UIEditorShellComposeModel BuildShellComposeModelFromFrame(
|
||||
@@ -90,7 +90,7 @@ void EditorShellDrawComposer::Append(
|
||||
const auto& palette = ResolveUIEditorShellInteractionPalette();
|
||||
const UIEditorShellComposeModel shellComposeModel =
|
||||
BuildShellComposeModelFromFrame(context.shellFrame);
|
||||
const BuiltInIconResolver iconResolver(context.builtInIcons);
|
||||
const BuiltInIconResolver iconResolver(context.iconService);
|
||||
|
||||
AppendDrawPacket(
|
||||
drawData,
|
||||
|
||||
@@ -11,13 +11,13 @@ struct UIEditorShellInteractionState;
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class BuiltInIcons;
|
||||
class EditorIconService;
|
||||
class EditorWorkspacePanelRuntimeSet;
|
||||
|
||||
struct EditorShellDrawComposerContext {
|
||||
const UIEditorShellInteractionFrame& shellFrame;
|
||||
const UIEditorShellInteractionState& shellInteractionState;
|
||||
const BuiltInIcons& builtInIcons;
|
||||
const EditorIconService& iconService;
|
||||
const EditorWorkspacePanelRuntimeSet& workspacePanels;
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ bool IsViewportPanel(std::string_view panelId) {
|
||||
}
|
||||
|
||||
void ApplyViewportFrameToPresentation(
|
||||
const ViewportFrame& viewportFrame,
|
||||
const EditorViewportFrame& viewportFrame,
|
||||
UIEditorWorkspacePanelPresentationModel& presentation) {
|
||||
presentation.viewportShellModel.frame.texture = viewportFrame.texture;
|
||||
presentation.viewportShellModel.frame.requestedSize = viewportFrame.requestedSize;
|
||||
@@ -28,7 +28,7 @@ void ApplyViewportFrameToPresentation(
|
||||
}
|
||||
|
||||
void ApplyViewportFrameToShellModel(
|
||||
const ViewportFrame& viewportFrame,
|
||||
const EditorViewportFrame& viewportFrame,
|
||||
UIEditorViewportShellModel& shellModel) {
|
||||
shellModel.frame.texture = viewportFrame.texture;
|
||||
shellModel.frame.requestedSize = viewportFrame.requestedSize;
|
||||
@@ -51,7 +51,7 @@ UIEditorWorkspacePanelPresentationModel* FindMutableWorkspacePresentation(
|
||||
|
||||
void ApplyViewportFramesToShellFrame(
|
||||
UIEditorShellInteractionFrame& shellFrame,
|
||||
ViewportHostService& viewportHostService) {
|
||||
EditorViewportRuntimeServices& viewportRuntimeServices) {
|
||||
auto applyToViewportFrames =
|
||||
[&](std::vector<UIEditorWorkspaceViewportComposeFrame>& viewportFrames) {
|
||||
for (UIEditorWorkspaceViewportComposeFrame& viewportComposeFrame : viewportFrames) {
|
||||
@@ -59,8 +59,8 @@ void ApplyViewportFramesToShellFrame(
|
||||
continue;
|
||||
}
|
||||
|
||||
const ViewportFrame viewportFrame =
|
||||
viewportHostService.RequestViewport(
|
||||
const EditorViewportFrame viewportFrame =
|
||||
viewportRuntimeServices.RequestViewport(
|
||||
viewportComposeFrame.panelId,
|
||||
viewportComposeFrame.viewportShellFrame.requestedViewportSize);
|
||||
ApplyViewportFrameToShellModel(
|
||||
@@ -128,7 +128,7 @@ void EditorShellInteractionEngine::Update(
|
||||
const Widgets::UIEditorDockHostLayout preUpdateDockLayout =
|
||||
context.shellFrame.workspaceInteractionFrame.dockHostFrame.layout;
|
||||
|
||||
context.viewportHostService.BeginFrame();
|
||||
context.viewportRuntimeServices.BeginFrame();
|
||||
const std::vector<UIInputEvent> shellEvents =
|
||||
context.hostedContentCaptureActive
|
||||
? FilterShellInputEventsForHostedContentCapture(context.inputEvents)
|
||||
@@ -160,7 +160,7 @@ void EditorShellInteractionEngine::Update(
|
||||
metrics);
|
||||
}
|
||||
|
||||
ApplyViewportFramesToShellFrame(context.shellFrame, context.viewportHostService);
|
||||
ApplyViewportFramesToShellFrame(context.shellFrame, context.viewportRuntimeServices);
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Viewport/ViewportHostService.h"
|
||||
#include "Viewport/EditorViewportRuntimeServices.h"
|
||||
|
||||
#include <XCEditor/Shell/UIEditorShellInteraction.h>
|
||||
#include <XCEditor/Workspace/UIEditorWorkspaceController.h>
|
||||
@@ -33,7 +33,7 @@ struct EditorShellInteractionEngineContext {
|
||||
bool useDetachedTitleBarTabStrip = false;
|
||||
float detachedTitleBarTabHeight = 0.0f;
|
||||
float detachedWindowChromeHeight = 0.0f;
|
||||
ViewportHostService& viewportHostService;
|
||||
EditorViewportRuntimeServices& viewportRuntimeServices;
|
||||
};
|
||||
|
||||
class EditorShellInteractionEngine final {
|
||||
|
||||
@@ -4,40 +4,57 @@
|
||||
#include <XCEditor/Shell/UIEditorShellCapturePolicy.h>
|
||||
#include <XCEngine/Rendering/RenderContext.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <utility>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
EditorShellRuntime::EditorShellRuntime(EditorWorkspacePanelRuntimeSet workspacePanels)
|
||||
: m_workspacePanels(std::move(workspacePanels)) {}
|
||||
EditorShellRuntime::EditorShellRuntime(
|
||||
EditorWorkspacePanelRuntimeSet workspacePanels,
|
||||
std::unique_ptr<EditorIconService> iconService,
|
||||
std::unique_ptr<EditorViewportRuntimeServices> viewportRuntimeServices)
|
||||
: m_iconService(std::move(iconService))
|
||||
, m_viewportRuntimeServices(std::move(viewportRuntimeServices))
|
||||
, m_workspacePanels(std::move(workspacePanels)) {}
|
||||
|
||||
void EditorShellRuntime::Initialize(
|
||||
const std::filesystem::path& repoRoot,
|
||||
Rendering::Host::UiTextureHost& textureHost,
|
||||
Host::EditorHostResourceService& resourceService,
|
||||
UIEditorTextMeasurer& textMeasurer) {
|
||||
m_textureHost = &textureHost;
|
||||
m_builtInIcons.Initialize(textureHost, resourceService);
|
||||
assert(m_iconService != nullptr);
|
||||
assert(m_viewportRuntimeServices != nullptr);
|
||||
if (m_iconService == nullptr || m_viewportRuntimeServices == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_iconService->Initialize(textureHost, resourceService);
|
||||
m_viewportRuntimeServices->Initialize(repoRoot);
|
||||
m_workspacePanels.Initialize(
|
||||
EditorWorkspacePanelInitializationContext{
|
||||
.repoRoot = repoRoot,
|
||||
.textureHost = textureHost,
|
||||
.textMeasurer = textMeasurer,
|
||||
.builtInIcons = m_builtInIcons,
|
||||
.viewportHostService = m_viewportHostService,
|
||||
.iconService = *m_iconService,
|
||||
.sceneViewportRuntime = &m_viewportRuntimeServices->GetSceneViewportRuntime(),
|
||||
});
|
||||
}
|
||||
|
||||
void EditorShellRuntime::AttachViewportWindowRenderer(Rendering::Host::ViewportRenderHost& renderer) {
|
||||
m_viewportHostService.AttachWindowRenderer(renderer);
|
||||
if (m_viewportRuntimeServices != nullptr) {
|
||||
m_viewportRuntimeServices->AttachWindowRenderer(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorShellRuntime::DetachViewportWindowRenderer() {
|
||||
m_viewportHostService.DetachWindowRenderer();
|
||||
if (m_viewportRuntimeServices != nullptr) {
|
||||
m_viewportRuntimeServices->DetachWindowRenderer();
|
||||
}
|
||||
}
|
||||
|
||||
void EditorShellRuntime::SetViewportSurfacePresentationEnabled(bool enabled) {
|
||||
m_viewportHostService.SetSurfacePresentationEnabled(enabled);
|
||||
if (m_viewportRuntimeServices != nullptr) {
|
||||
m_viewportRuntimeServices->SetSurfacePresentationEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorShellRuntime::Shutdown() {
|
||||
@@ -45,20 +62,14 @@ void EditorShellRuntime::Shutdown() {
|
||||
m_shellInteractionState = {};
|
||||
m_splitterDragCorrectionState = {};
|
||||
m_traceEntries.clear();
|
||||
if (m_textureHost != nullptr) {
|
||||
m_workspacePanels.Shutdown(
|
||||
EditorWorkspacePanelShutdownContext{
|
||||
.textureHost = *m_textureHost,
|
||||
.viewportHostService = m_viewportHostService,
|
||||
});
|
||||
m_workspacePanels = {};
|
||||
m_builtInIcons.Shutdown();
|
||||
m_textureHost = nullptr;
|
||||
} else {
|
||||
m_workspacePanels = {};
|
||||
m_builtInIcons.Shutdown();
|
||||
m_workspacePanels.Shutdown(EditorWorkspacePanelShutdownContext{});
|
||||
m_workspacePanels = {};
|
||||
if (m_iconService != nullptr) {
|
||||
m_iconService->Shutdown();
|
||||
}
|
||||
if (m_viewportRuntimeServices != nullptr) {
|
||||
m_viewportRuntimeServices->Shutdown();
|
||||
}
|
||||
m_viewportHostService.Shutdown();
|
||||
}
|
||||
|
||||
void EditorShellRuntime::ResetInteractionState() {
|
||||
@@ -82,7 +93,8 @@ const std::vector<WorkspaceTraceEntry>& EditorShellRuntime::GetTraceEntries() co
|
||||
}
|
||||
|
||||
const std::string& EditorShellRuntime::GetBuiltInIconError() const {
|
||||
return m_builtInIcons.GetLastError();
|
||||
static const std::string kEmptyError = {};
|
||||
return m_iconService != nullptr ? m_iconService->GetLastError() : kEmptyError;
|
||||
}
|
||||
|
||||
void EditorShellRuntime::SetExternalDockHostDropPreview(
|
||||
@@ -144,8 +156,13 @@ bool EditorShellRuntime::HasInteractiveCapture() const {
|
||||
}
|
||||
|
||||
std::unique_ptr<EditorWorkspaceShellRuntime> CreateEditorWorkspaceShellRuntime(
|
||||
EditorWorkspacePanelRuntimeSet workspacePanels) {
|
||||
return std::make_unique<EditorShellRuntime>(std::move(workspacePanels));
|
||||
EditorWorkspacePanelRuntimeSet workspacePanels,
|
||||
std::unique_ptr<EditorIconService> iconService,
|
||||
std::unique_ptr<EditorViewportRuntimeServices> viewportRuntimeServices) {
|
||||
return std::make_unique<EditorShellRuntime>(
|
||||
std::move(workspacePanels),
|
||||
std::move(iconService),
|
||||
std::move(viewportRuntimeServices));
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
@@ -154,15 +171,21 @@ namespace XCEngine::UI::Editor::App {
|
||||
|
||||
void EditorShellRuntime::RenderRequestedViewports(
|
||||
const ::XCEngine::Rendering::RenderContext& renderContext) {
|
||||
m_viewportHostService.RenderRequestedViewports(renderContext);
|
||||
if (m_viewportRuntimeServices != nullptr) {
|
||||
m_viewportRuntimeServices->RenderRequestedViewports(renderContext);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorShellRuntime::Append(::XCEngine::UI::UIDrawData& drawData) const {
|
||||
if (m_iconService == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_drawComposer.Append(
|
||||
EditorShellDrawComposerContext{
|
||||
.shellFrame = m_shellFrame,
|
||||
.shellInteractionState = m_shellInteractionState,
|
||||
.builtInIcons = m_builtInIcons,
|
||||
.iconService = *m_iconService,
|
||||
.workspacePanels = m_workspacePanels,
|
||||
},
|
||||
drawData);
|
||||
@@ -182,6 +205,10 @@ void EditorShellRuntime::Update(
|
||||
bool useDetachedTitleBarTabStrip,
|
||||
float detachedTitleBarTabHeight,
|
||||
float detachedWindowChromeHeight) {
|
||||
if (m_viewportRuntimeServices == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto buildDefinition = [&]() {
|
||||
return m_sessionCoordinator.PrepareShellDefinition(
|
||||
EditorShellSessionCoordinatorContext{
|
||||
@@ -206,7 +233,7 @@ void EditorShellRuntime::Update(
|
||||
.useDetachedTitleBarTabStrip = useDetachedTitleBarTabStrip,
|
||||
.detachedTitleBarTabHeight = detachedTitleBarTabHeight,
|
||||
.detachedWindowChromeHeight = detachedWindowChromeHeight,
|
||||
.viewportHostService = m_viewportHostService,
|
||||
.viewportRuntimeServices = *m_viewportRuntimeServices,
|
||||
});
|
||||
m_sessionCoordinator.FinalizeFrame(frameServices, workspaceController, m_shellFrame.result);
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#include "EditorShellHostedPanelCoordinator.h"
|
||||
#include "EditorShellInteractionEngine.h"
|
||||
#include "EditorShellSessionCoordinator.h"
|
||||
#include "Assets/EditorIconService.h"
|
||||
#include "Viewport/EditorViewportRuntimeServices.h"
|
||||
#include "Windowing/EditorWorkspaceShellRuntime.h"
|
||||
#include "WorkspacePanels/EditorWorkspacePanelRuntime.h"
|
||||
#include "Assets/BuiltInIcons.h"
|
||||
#include "Viewport/ViewportHostService.h"
|
||||
|
||||
#include <XCEditor/Shell/UIEditorShellInteraction.h>
|
||||
#include <XCEditor/Docking/UIEditorDockHostTransfer.h>
|
||||
@@ -45,8 +45,10 @@ namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class EditorShellRuntime final : public EditorWorkspaceShellRuntime {
|
||||
public:
|
||||
EditorShellRuntime() = default;
|
||||
explicit EditorShellRuntime(EditorWorkspacePanelRuntimeSet workspacePanels);
|
||||
EditorShellRuntime(
|
||||
EditorWorkspacePanelRuntimeSet workspacePanels,
|
||||
std::unique_ptr<EditorIconService> iconService,
|
||||
std::unique_ptr<EditorViewportRuntimeServices> viewportRuntimeServices);
|
||||
|
||||
void Initialize(
|
||||
const std::filesystem::path& repoRoot,
|
||||
@@ -95,9 +97,8 @@ public:
|
||||
bool HasInteractiveCapture() const override;
|
||||
|
||||
private:
|
||||
ViewportHostService m_viewportHostService = {};
|
||||
BuiltInIcons m_builtInIcons = {};
|
||||
Rendering::Host::UiTextureHost* m_textureHost = nullptr;
|
||||
std::unique_ptr<EditorIconService> m_iconService = {};
|
||||
std::unique_ptr<EditorViewportRuntimeServices> m_viewportRuntimeServices = {};
|
||||
EditorWorkspacePanelRuntimeSet m_workspacePanels = {};
|
||||
UIEditorShellInteractionState m_shellInteractionState = {};
|
||||
UIEditorShellInteractionFrame m_shellFrame = {};
|
||||
@@ -110,7 +111,9 @@ private:
|
||||
};
|
||||
|
||||
std::unique_ptr<EditorWorkspaceShellRuntime> CreateEditorWorkspaceShellRuntime(
|
||||
EditorWorkspacePanelRuntimeSet workspacePanels);
|
||||
EditorWorkspacePanelRuntimeSet workspacePanels,
|
||||
std::unique_ptr<EditorIconService> iconService,
|
||||
std::unique_ptr<EditorViewportRuntimeServices> viewportRuntimeServices);
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
|
||||
Reference in New Issue
Block a user