68 lines
2.1 KiB
C++
68 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include "ProductViewportRenderTargets.h"
|
|
|
|
#include <Host/D3D12WindowRenderer.h>
|
|
#include <Host/D3D12ShaderResourceDescriptorAllocator.h>
|
|
|
|
#include <XCEngine/Rendering/RenderContext.h>
|
|
#include <XCEngine/UI/Types.h>
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace XCEngine::UI::Editor::App {
|
|
|
|
class ProductViewportHostService {
|
|
public:
|
|
void AttachWindowRenderer(Host::D3D12WindowRenderer& windowRenderer);
|
|
void DetachWindowRenderer();
|
|
void SetSurfacePresentationEnabled(bool enabled);
|
|
|
|
void Shutdown();
|
|
void BeginFrame();
|
|
|
|
ProductViewportFrame RequestViewport(
|
|
ProductViewportKind kind,
|
|
const ::XCEngine::UI::UISize& requestedSize);
|
|
|
|
void RenderRequestedViewports(
|
|
const ::XCEngine::Rendering::RenderContext& renderContext);
|
|
|
|
private:
|
|
struct ViewportEntry {
|
|
ProductViewportKind kind = ProductViewportKind::Scene;
|
|
std::uint32_t requestedWidth = 0;
|
|
std::uint32_t requestedHeight = 0;
|
|
bool requestedThisFrame = false;
|
|
bool renderedThisFrame = false;
|
|
ProductViewportRenderTargets renderTargets = {};
|
|
std::string statusText = {};
|
|
};
|
|
|
|
ViewportEntry& GetEntry(ProductViewportKind kind);
|
|
const ViewportEntry& GetEntry(ProductViewportKind kind) const;
|
|
void DestroyViewportEntry(ViewportEntry& entry);
|
|
bool EnsureViewportResources(ViewportEntry& entry);
|
|
void ClearViewport(
|
|
ViewportEntry& entry,
|
|
const ::XCEngine::Rendering::RenderContext& renderContext,
|
|
float r,
|
|
float g,
|
|
float b,
|
|
float a);
|
|
ProductViewportFrame BuildFrame(
|
|
const ViewportEntry& entry,
|
|
const ::XCEngine::UI::UISize& requestedSize) const;
|
|
|
|
Host::D3D12WindowRenderer* m_windowRenderer = nullptr;
|
|
::XCEngine::RHI::RHIDevice* m_device = nullptr;
|
|
Host::D3D12ShaderResourceDescriptorAllocator m_textureDescriptorAllocator = {};
|
|
ProductViewportRenderTargetManager m_renderTargetManager = {};
|
|
bool m_surfacePresentationEnabled = false;
|
|
std::array<ViewportEntry, 2> m_entries = {};
|
|
};
|
|
|
|
} // namespace XCEngine::UI::Editor::App
|