Refactor editor host resource boundary
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include "Runtime/EditorWindowRuntimeController.h"
|
||||
|
||||
#include "EditorResources.h"
|
||||
#include "EmbeddedPngLoader.h"
|
||||
#include "EditorHostResourceService.h"
|
||||
#include "TextFormat.h"
|
||||
|
||||
#include <XCEditor/Docking/UIEditorDockHostTransfer.h>
|
||||
@@ -17,7 +16,6 @@
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
using App::LoadEmbeddedPngTexture;
|
||||
using App::TruncateText;
|
||||
|
||||
namespace {
|
||||
@@ -29,13 +27,29 @@ void LogRuntimeTrace(std::string_view channel, std::string_view message) {
|
||||
AppendUIEditorRuntimeTrace(channel, message);
|
||||
}
|
||||
|
||||
bool LoadHostPngTexture(
|
||||
Host::EditorHostResourceService& resourceService,
|
||||
Rendering::Host::UiTextureHost& textureHost,
|
||||
Host::EditorHostPngResourceKind resourceKind,
|
||||
::XCEngine::UI::UITextureHandle& outTexture,
|
||||
std::string& outError) {
|
||||
Host::EditorHostResourceBytes bytes = {};
|
||||
if (!resourceService.TryLoadPngResource(resourceKind, bytes, outError)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return textureHost.LoadTextureFromMemory(bytes.data, bytes.size, outTexture, outError);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EditorWindowRuntimeController::EditorWindowRuntimeController(
|
||||
EditorContext& editorContext,
|
||||
Host::EditorHostResourceService& resourceService,
|
||||
std::unique_ptr<EditorWindowContentController> contentController,
|
||||
std::unique_ptr<Rendering::Host::EditorWindowRenderRuntime> renderRuntime)
|
||||
: m_editorContext(editorContext)
|
||||
, m_resourceService(resourceService)
|
||||
, m_renderRuntime(std::move(renderRuntime))
|
||||
, m_contentController(std::move(contentController)) {}
|
||||
|
||||
@@ -156,6 +170,7 @@ bool EditorWindowRuntimeController::Initialize(
|
||||
.repoRoot = repoRoot,
|
||||
.editorContext = m_editorContext,
|
||||
.textureHost = m_renderRuntime->GetTextureHost(),
|
||||
.resourceService = m_resourceService,
|
||||
.textMeasurer = m_renderRuntime->GetTextMeasurer(),
|
||||
.viewportRenderer = m_renderRuntime->GetViewportRenderHost(),
|
||||
});
|
||||
@@ -163,9 +178,10 @@ bool EditorWindowRuntimeController::Initialize(
|
||||
initializeResult.hasViewportSurfacePresentation);
|
||||
|
||||
std::string titleBarLogoError = {};
|
||||
if (!LoadEmbeddedPngTexture(
|
||||
if (!LoadHostPngTexture(
|
||||
m_resourceService,
|
||||
m_renderRuntime->GetTextureHost(),
|
||||
IDR_PNG_LOGO_ICON,
|
||||
Host::EditorHostPngResourceKind::LogoIcon,
|
||||
m_titleBarLogoIcon,
|
||||
titleBarLogoError)) {
|
||||
LogRuntimeTrace("icons", "titlebar logo_icon.png: " + titleBarLogoError);
|
||||
@@ -183,7 +199,9 @@ bool EditorWindowRuntimeController::Initialize(
|
||||
ResetFrameTiming();
|
||||
m_ready = true;
|
||||
|
||||
m_screenshotController.Initialize(captureRoot);
|
||||
m_screenshotController.Initialize(
|
||||
captureRoot,
|
||||
m_resourceService.GetExecutableDirectory());
|
||||
if (autoCaptureOnStartup) {
|
||||
m_screenshotController.RequestCapture("startup");
|
||||
m_contentController->NotifyStartupCaptureRequested(m_editorContext);
|
||||
|
||||
Reference in New Issue
Block a user