Finalize library bootstrap status and stabilize async asset regressions

This commit is contained in:
2026-04-04 19:44:59 +08:00
parent 013e5a73b9
commit bcef1f145b
25 changed files with 3415 additions and 81 deletions

View File

@@ -0,0 +1,61 @@
#include <XCEngine/Resources/UI/UIDocuments.h>
namespace XCEngine {
namespace Resources {
namespace {
size_t MeasureNodeMemorySize(const UIDocumentNode& node) {
size_t size = sizeof(UIDocumentNode) + node.tagName.Length();
for (const UIDocumentAttribute& attribute : node.attributes) {
size += sizeof(UIDocumentAttribute);
size += attribute.name.Length();
size += attribute.value.Length();
}
for (const UIDocumentNode& child : node.children) {
size += MeasureNodeMemorySize(child);
}
return size;
}
size_t MeasureDiagnosticMemorySize(const UIDocumentDiagnostic& diagnostic) {
return sizeof(UIDocumentDiagnostic) + diagnostic.message.Length();
}
} // namespace
void UIDocumentResource::Release() {
m_document.Clear();
SetInvalid();
m_memorySize = 0;
}
void UIDocumentResource::SetDocumentModel(const UIDocumentModel& document) {
m_document = document;
RecalculateMemorySize();
}
void UIDocumentResource::SetDocumentModel(UIDocumentModel&& document) {
m_document = std::move(document);
RecalculateMemorySize();
}
void UIDocumentResource::RecalculateMemorySize() {
size_t size = sizeof(*this);
size += m_document.sourcePath.Length();
size += m_document.displayName.Length();
size += MeasureNodeMemorySize(m_document.rootNode);
for (const Containers::String& dependency : m_document.dependencies) {
size += sizeof(Containers::String) + dependency.Length();
}
for (const UIDocumentDiagnostic& diagnostic : m_document.diagnostics) {
size += MeasureDiagnosticMemorySize(diagnostic);
}
m_memorySize = size;
}
} // namespace Resources
} // namespace XCEngine