Refactor editor rendering contracts
This commit is contained in:
60
editor/app/Core/Assets/EditorIconService.h
Normal file
60
editor/app/Core/Assets/EditorIconService.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include "HostFwd.h"
|
||||
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
namespace XCEngine::UI::Editor::Rendering::Host {
|
||||
|
||||
class UiTextureHost;
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Rendering::Host
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
enum class BuiltInIconKind : std::uint8_t {
|
||||
Folder = 0,
|
||||
GameObject,
|
||||
Scene,
|
||||
CameraGizmo,
|
||||
DirectionalLightGizmo,
|
||||
PointLightGizmo,
|
||||
SpotLightGizmo,
|
||||
PlayButton,
|
||||
PauseButton,
|
||||
StepButton,
|
||||
ViewMoveTool,
|
||||
ViewMoveToolActive,
|
||||
MoveTool,
|
||||
MoveToolActive,
|
||||
RotateTool,
|
||||
RotateToolActive,
|
||||
ScaleTool,
|
||||
ScaleToolActive,
|
||||
TransformTool,
|
||||
TransformToolActive
|
||||
};
|
||||
|
||||
class EditorIconService {
|
||||
public:
|
||||
virtual ~EditorIconService() = default;
|
||||
|
||||
virtual void Initialize(
|
||||
Rendering::Host::UiTextureHost& renderer,
|
||||
Host::EditorHostResourceService& resourceService) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual void BeginFrame() = 0;
|
||||
|
||||
[[nodiscard]] virtual const ::XCEngine::UI::UITextureHandle& Resolve(
|
||||
BuiltInIconKind kind) const = 0;
|
||||
[[nodiscard]] virtual const ::XCEngine::UI::UITextureHandle* ResolveAssetPreview(
|
||||
const std::filesystem::path& assetPath,
|
||||
const std::filesystem::path& projectRoot) = 0;
|
||||
[[nodiscard]] virtual const std::string& GetLastError() const = 0;
|
||||
};
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
41
editor/app/Core/Viewport/EditorViewportPicking.h
Normal file
41
editor/app/Core/Viewport/EditorViewportPicking.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/Rendering/Picking/ObjectIdCodec.h>
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
enum class ViewportObjectIdPickStatus : std::uint8_t {
|
||||
Unavailable = 0,
|
||||
Success,
|
||||
ReadbackFailed
|
||||
};
|
||||
|
||||
struct ViewportObjectIdPickResult {
|
||||
ViewportObjectIdPickStatus status = ViewportObjectIdPickStatus::Unavailable;
|
||||
std::uint64_t frameSerial = 0u;
|
||||
::XCEngine::Rendering::RenderObjectId renderObjectId =
|
||||
::XCEngine::Rendering::kInvalidRenderObjectId;
|
||||
std::uint64_t resolvedEntityId = 0u;
|
||||
|
||||
bool HasResolvedSample() const {
|
||||
return status == ViewportObjectIdPickStatus::Success;
|
||||
}
|
||||
|
||||
bool HasResolvedEntity() const {
|
||||
return HasResolvedSample() && resolvedEntityId != 0u;
|
||||
}
|
||||
};
|
||||
|
||||
class IViewportObjectPickerService {
|
||||
public:
|
||||
virtual ~IViewportObjectPickerService() = default;
|
||||
|
||||
virtual ViewportObjectIdPickResult PickObject(
|
||||
const ::XCEngine::UI::UISize& viewportSize,
|
||||
const ::XCEngine::UI::UIPoint& viewportMousePosition) const = 0;
|
||||
};
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
50
editor/app/Core/Viewport/EditorViewportRuntimeServices.h
Normal file
50
editor/app/Core/Viewport/EditorViewportRuntimeServices.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include "Scene/SceneViewportRenderRequest.h"
|
||||
#include "Viewport/EditorViewportPicking.h"
|
||||
#include "Viewport/EditorViewportTypes.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <string_view>
|
||||
|
||||
namespace XCEngine::Rendering {
|
||||
|
||||
class RenderContext;
|
||||
|
||||
} // namespace XCEngine::Rendering
|
||||
|
||||
namespace XCEngine::UI::Editor::Rendering::Host {
|
||||
|
||||
class ViewportRenderHost;
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Rendering::Host
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class EditorSceneViewportRuntime {
|
||||
public:
|
||||
virtual ~EditorSceneViewportRuntime() = default;
|
||||
|
||||
virtual void SetRenderRequest(SceneViewportRenderRequest request) = 0;
|
||||
[[nodiscard]] virtual const IViewportObjectPickerService& GetObjectPicker() const = 0;
|
||||
};
|
||||
|
||||
class EditorViewportRuntimeServices {
|
||||
public:
|
||||
virtual ~EditorViewportRuntimeServices() = default;
|
||||
|
||||
virtual void Initialize(const std::filesystem::path& repoRoot) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual void AttachWindowRenderer(Rendering::Host::ViewportRenderHost& windowRenderer) = 0;
|
||||
virtual void DetachWindowRenderer() = 0;
|
||||
virtual void SetSurfacePresentationEnabled(bool enabled) = 0;
|
||||
virtual void BeginFrame() = 0;
|
||||
[[nodiscard]] virtual EditorViewportFrame RequestViewport(
|
||||
std::string_view viewportId,
|
||||
const ::XCEngine::UI::UISize& requestedSize) = 0;
|
||||
virtual void RenderRequestedViewports(
|
||||
const ::XCEngine::Rendering::RenderContext& renderContext) = 0;
|
||||
[[nodiscard]] virtual EditorSceneViewportRuntime& GetSceneViewportRuntime() = 0;
|
||||
};
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
24
editor/app/Core/Viewport/EditorViewportTypes.h
Normal file
24
editor/app/Core/Viewport/EditorViewportTypes.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
struct EditorViewportResourceRequirements {
|
||||
bool requiresDepthSampling = false;
|
||||
bool requiresObjectIdSurface = false;
|
||||
bool requiresSelectionMaskSurface = false;
|
||||
};
|
||||
|
||||
struct EditorViewportFrame {
|
||||
::XCEngine::UI::UITextureHandle texture = {};
|
||||
::XCEngine::UI::UISize requestedSize = {};
|
||||
::XCEngine::UI::UISize renderSize = {};
|
||||
bool hasTexture = false;
|
||||
bool wasRequested = false;
|
||||
std::string statusText = {};
|
||||
};
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Assets/EditorIconService.h"
|
||||
#include "Commands/EditorEditCommandRoute.h"
|
||||
#include "State/EditorSession.h"
|
||||
#include "Panels/EditorPanelServices.h"
|
||||
#include "Viewport/EditorViewportRuntimeServices.h"
|
||||
|
||||
#include <XCEditor/Foundation/UIEditorTextMeasurement.h>
|
||||
#include <XCEditor/Panels/UIEditorHostedPanelDispatch.h>
|
||||
@@ -25,17 +27,8 @@ struct UIInputEvent;
|
||||
|
||||
} // namespace XCEngine::UI
|
||||
|
||||
namespace XCEngine::UI::Editor::Rendering::Host {
|
||||
|
||||
class UiTextureHost;
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Rendering::Host
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class BuiltInIcons;
|
||||
class ViewportHostService;
|
||||
|
||||
enum class EditorWorkspacePanelCursorKind : std::uint8_t {
|
||||
Arrow = 0,
|
||||
ResizeEW
|
||||
@@ -54,16 +47,12 @@ struct EditorWorkspacePanelFrameEvent {
|
||||
|
||||
struct EditorWorkspacePanelInitializationContext {
|
||||
const std::filesystem::path& repoRoot;
|
||||
Rendering::Host::UiTextureHost& textureHost;
|
||||
UIEditorTextMeasurer& textMeasurer;
|
||||
BuiltInIcons& builtInIcons;
|
||||
ViewportHostService& viewportHostService;
|
||||
EditorIconService& iconService;
|
||||
EditorSceneViewportRuntime* sceneViewportRuntime = nullptr;
|
||||
};
|
||||
|
||||
struct EditorWorkspacePanelShutdownContext {
|
||||
Rendering::Host::UiTextureHost& textureHost;
|
||||
ViewportHostService& viewportHostService;
|
||||
};
|
||||
struct EditorWorkspacePanelShutdownContext {};
|
||||
|
||||
struct EditorWorkspacePanelUpdateContext {
|
||||
EditorPanelServices& services;
|
||||
|
||||
Reference in New Issue
Block a user