editor: centralize product panel manifest

This commit is contained in:
2026-04-28 04:33:44 +08:00
parent ea765b9481
commit 8c66cdac07
12 changed files with 574 additions and 136 deletions

View File

@@ -1,6 +1,7 @@
#include "ViewportHostService.h"
#include "Panels/EditorPanelIds.h"
#include "Product/EditorProductManifest.h"
#include "Viewport/SceneViewportResourcePaths.h"
#include "ViewportRenderHost.h"
@@ -14,6 +15,30 @@ namespace {
using ::XCEngine::RHI::ResourceStates;
class PlaceholderViewportContentRenderer final : public IViewportContentRenderer {
public:
explicit PlaceholderViewportContentRenderer(std::string_view statusText)
: m_statusText(statusText) {}
ViewportRenderResult Render(
ViewportRenderTargets&,
::XCEngine::RHI::RHIDevice&,
const ::XCEngine::Rendering::RenderContext&) override {
ViewportRenderResult result = {};
result.rendered = false;
result.requiresFallbackClear = true;
result.statusText = m_statusText;
result.fallbackClearR = 0.07f;
result.fallbackClearG = 0.08f;
result.fallbackClearB = 0.10f;
result.fallbackClearA = 1.0f;
return result;
}
private:
std::string m_statusText = {};
};
} // namespace
ViewportHostService::ViewportHostService() = default;
@@ -22,10 +47,33 @@ ViewportHostService::~ViewportHostService() = default;
void ViewportHostService::Initialize(const std::filesystem::path& repoRoot) {
m_sceneViewportRuntime.Initialize(BuildSceneViewportShaderPaths(repoRoot));
SetContentRenderer(
kScenePanelId,
&m_sceneViewportRuntime,
SceneViewportRenderService::GetViewportResourceRequirements());
m_placeholderRenderers.clear();
for (const EditorProductPanelDescriptor& panel : GetEditorProductPanels()) {
if (panel.presentationKind != UIEditorPanelPresentationKind::ViewportShell) {
continue;
}
switch (panel.viewportRendererKind) {
case EditorProductViewportRendererKind::Scene:
SetContentRenderer(
panel.panelId,
&m_sceneViewportRuntime,
SceneViewportRenderService::GetViewportResourceRequirements());
break;
case EditorProductViewportRendererKind::Placeholder: {
auto placeholder =
std::make_unique<PlaceholderViewportContentRenderer>(
panel.viewportPlaceholderStatus);
SetContentRenderer(panel.panelId, placeholder.get(), {});
m_placeholderRenderers.push_back(std::move(placeholder));
break;
}
case EditorProductViewportRendererKind::None:
default:
SetContentRenderer(panel.panelId, nullptr, {});
break;
}
}
}
void ViewportHostService::AttachWindowRenderer(
@@ -60,7 +108,12 @@ void ViewportHostService::SetContentRenderer(
}
void ViewportHostService::Shutdown() {
SetContentRenderer(kScenePanelId, nullptr, {});
for (const EditorProductPanelDescriptor& panel : GetEditorProductPanels()) {
if (panel.presentationKind == UIEditorPanelPresentationKind::ViewportShell) {
SetContentRenderer(panel.panelId, nullptr, {});
}
}
m_placeholderRenderers.clear();
m_sceneViewportRuntime.Shutdown();
for (auto& [viewportId, entry] : m_entries) {
DestroyViewportEntry(entry);