editor: narrow core host contract surface
This commit is contained in:
97
editor/app/Host/Interfaces/EditorWindowRenderRuntime.h
Normal file
97
editor/app/Host/Interfaces/EditorWindowRenderRuntime.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include "UiTextureHost.h"
|
||||
#include "ViewportRenderHost.h"
|
||||
|
||||
#include <XCEditor/Foundation/UIEditorTextMeasurement.h>
|
||||
#include <XCEngine/Rendering/RenderContext.h>
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace XCEngine::UI::Editor::Rendering::Host {
|
||||
|
||||
enum class EditorWindowRenderRuntimeSurfaceKind : std::uint8_t {
|
||||
Unknown = 0,
|
||||
Win32Window,
|
||||
};
|
||||
|
||||
struct EditorWindowRenderRuntimeSurface {
|
||||
EditorWindowRenderRuntimeSurfaceKind kind = EditorWindowRenderRuntimeSurfaceKind::Unknown;
|
||||
std::uintptr_t nativeHandle = 0u;
|
||||
|
||||
bool IsValid() const {
|
||||
return kind != EditorWindowRenderRuntimeSurfaceKind::Unknown && nativeHandle != 0u;
|
||||
}
|
||||
};
|
||||
|
||||
struct EditorWindowRenderRuntimeInitializeParams {
|
||||
EditorWindowRenderRuntimeSurface surface = {};
|
||||
std::uint32_t widthPixels = 0u;
|
||||
std::uint32_t heightPixels = 0u;
|
||||
|
||||
bool IsValid() const {
|
||||
return surface.IsValid() && widthPixels > 0u && heightPixels > 0u;
|
||||
}
|
||||
};
|
||||
|
||||
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(
|
||||
const EditorWindowRenderRuntimeInitializeParams& params) = 0;
|
||||
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;
|
||||
};
|
||||
|
||||
class EditorWindowRenderRuntimeFactory {
|
||||
public:
|
||||
virtual ~EditorWindowRenderRuntimeFactory() = default;
|
||||
|
||||
virtual std::unique_ptr<EditorWindowRenderRuntime> CreateWindowRenderRuntime() = 0;
|
||||
};
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Rendering::Host
|
||||
Reference in New Issue
Block a user