2026-04-26 18:54:43 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Rendering/Host/UiTextureHost.h"
|
|
|
|
|
#include "Rendering/Host/ViewportRenderHost.h"
|
|
|
|
|
|
|
|
|
|
#include <XCEditor/Foundation/UIEditorTextMeasurement.h>
|
|
|
|
|
#include <XCEngine/Rendering/RenderContext.h>
|
|
|
|
|
#include <XCEngine/UI/DrawData.h>
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <filesystem>
|
2026-04-26 19:21:38 +08:00
|
|
|
#include <memory>
|
2026-04-26 18:54:43 +08:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine::UI::Editor::Rendering::Host {
|
|
|
|
|
|
2026-04-26 23:30:29 +08:00
|
|
|
enum class EditorWindowRenderRuntimeSurfaceKind : std::uint8_t {
|
|
|
|
|
Unknown = 0,
|
|
|
|
|
Win32Window,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class EditorWindowRenderRuntimeSurface {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~EditorWindowRenderRuntimeSurface() = default;
|
|
|
|
|
|
|
|
|
|
virtual EditorWindowRenderRuntimeSurfaceKind GetKind() const = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct EditorWindowRenderRuntimeInitializeParams {
|
|
|
|
|
std::shared_ptr<const EditorWindowRenderRuntimeSurface> surface = {};
|
2026-04-26 18:54:43 +08:00
|
|
|
std::uint32_t widthPixels = 0u;
|
|
|
|
|
std::uint32_t heightPixels = 0u;
|
2026-04-26 23:30:29 +08:00
|
|
|
|
|
|
|
|
bool IsValid() const {
|
|
|
|
|
return surface != nullptr && widthPixels > 0u && heightPixels > 0u;
|
|
|
|
|
}
|
2026-04-26 18:54:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct EditorWindowRenderRuntimeInitializeResult {
|
|
|
|
|
bool success = false;
|
|
|
|
|
bool hasViewportSurfacePresentation = false;
|
|
|
|
|
std::string errorMessage = {};
|
|
|
|
|
std::string warning = {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct EditorWindowRenderRuntimeResizeResult {
|
|
|
|
|
bool hasViewportSurfacePresentation = false;
|
|
|
|
|
std::string warning = {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct EditorWindowRenderRuntimeFrameContext {
|
|
|
|
|
bool canRenderViewports = false;
|
|
|
|
|
::XCEngine::Rendering::RenderContext renderContext = {};
|
|
|
|
|
std::string warning = {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct EditorWindowRenderRuntimePresentResult {
|
|
|
|
|
bool framePresented = false;
|
|
|
|
|
bool captureSucceeded = false;
|
|
|
|
|
std::string captureError = {};
|
|
|
|
|
std::string warning = {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class EditorWindowRenderRuntime {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~EditorWindowRenderRuntime() = default;
|
|
|
|
|
|
|
|
|
|
virtual bool IsReady() const = 0;
|
|
|
|
|
virtual void SetDpiScale(float dpiScale) = 0;
|
|
|
|
|
virtual UIEditorTextMeasurer& GetTextMeasurer() = 0;
|
|
|
|
|
virtual const UIEditorTextMeasurer& GetTextMeasurer() const = 0;
|
|
|
|
|
virtual UiTextureHost& GetTextureHost() = 0;
|
|
|
|
|
virtual ViewportRenderHost& GetViewportRenderHost() = 0;
|
|
|
|
|
|
|
|
|
|
virtual EditorWindowRenderRuntimeInitializeResult Initialize(
|
2026-04-26 23:30:29 +08:00
|
|
|
const EditorWindowRenderRuntimeInitializeParams& params) = 0;
|
2026-04-26 18:54:43 +08:00
|
|
|
virtual void WaitForGpuIdle() = 0;
|
|
|
|
|
virtual void Shutdown() = 0;
|
|
|
|
|
virtual EditorWindowRenderRuntimeResizeResult ApplyResize(
|
|
|
|
|
std::uint32_t width,
|
|
|
|
|
std::uint32_t height) = 0;
|
|
|
|
|
virtual EditorWindowRenderRuntimeFrameContext BeginFrame() = 0;
|
|
|
|
|
virtual EditorWindowRenderRuntimePresentResult Present(
|
|
|
|
|
const ::XCEngine::UI::UIDrawData& drawData,
|
|
|
|
|
const std::filesystem::path* captureOutputPath) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2026-04-26 19:21:38 +08:00
|
|
|
class EditorWindowRenderRuntimeFactory {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~EditorWindowRenderRuntimeFactory() = default;
|
|
|
|
|
|
|
|
|
|
virtual std::unique_ptr<EditorWindowRenderRuntime> CreateWindowRenderRuntime() = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2026-04-26 18:54:43 +08:00
|
|
|
} // namespace XCEngine::UI::Editor::Rendering::Host
|