XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESystem

【Rust】XFE系统,基于Rust和汇编

公开
关注 0 Fork 0 Star 0
UTF-8
namespace XFESystem.Desktop;

/// <summary>Explicit platform worker. Native implementations enable it only after their EH/GC preemption checks pass.</summary>
public interface IEditorBackgroundWorkScheduler
{
    bool TryQueue(Action work);
}

/// <summary>Each call returns worker-owned real font metrics/rasterization, with no shared display/font-cache writes.</summary>
public interface IEditorPreparationCanvasFactory
{
    IDesktopCanvas CreateEditorPreparationCanvas();
}

/// <summary>Private worker font caches. Only after publication may their owner
/// transfer them to an equivalent display canvas on the UI thread.</summary>
public interface IEditorPreparationCanvasHandoff
{
    void PrepareEditorText(string text, double fontSize, string fontFamily, int fontWeight);
    bool TryCompleteEditorPreparationHandoff(IDesktopCanvas target);
}

public sealed record EditorPreparationRequest(int WindowId, long Generation, string Source, string Path, int ViewportWidth, int ViewportHeight, long MonotonicMilliseconds = 0);
public sealed record EditorPreparationResult(IInteractiveBrowserSession? Page, string? Error, int WorkerThreadId, IDesktopCanvas? PreparedCanvas = null);

public interface IEditorPreparationOperation
{
    EditorPreparationRequest Request { get; }
    void Cancel();
    bool TryTakeResult(out EditorPreparationResult result);
    bool IsRetired => true;
    void AdvanceRetirement(long monotonicMilliseconds) { }
}

public interface IEditorPreparationService
{
    IEditorPreparationOperation Begin(EditorPreparationRequest request);
}

/// <summary>Safe UI-side snapshots. The actual engine and DOM remain owned by
/// the verified worker for their entire lifetime, including timers and input.</summary>
public interface IBackgroundEditorSession : IInteractiveBrowserSession
{
    bool IsRetired { get; }
    BackgroundEditorDiagnostics Diagnostics { get; }
    long RasterPaintCount { get; }
    long CachedPaintCount { get; }
    bool RequestEditorReadback(Action<string?, string?> completed);
    void Cancel();
}

public sealed record BackgroundEditorDiagnostics(string MonacoProof, string LastInputTrace,
    long LayoutPassCount, long ScrollLayoutReuseCount, long PackagedScriptCacheHits, long PackagedScriptPreparations,
    int WorkerThreadId, string? Error = null);