Update docs and exposed API

This commit is contained in:
Soreepeong 2023-12-10 14:39:22 +09:00
parent 7eb4bf8ab4
commit e7c7cdaa29
6 changed files with 128 additions and 95 deletions

View file

@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reactive.Disposables;
using System.Threading;
using System.Threading.Tasks;
@ -203,6 +204,9 @@ internal sealed partial class FontAtlasFactory
private Task<FontAtlasBuiltData> buildTask = EmptyTask;
private FontAtlasBuiltData builtData;
private int buildSuppressionCounter;
private bool buildSuppressionSuppressed;
private int buildIndex;
private bool buildQueued;
private bool disposed = false;
@ -356,6 +360,19 @@ internal sealed partial class FontAtlasFactory
GC.SuppressFinalize(this);
}
/// <inheritdoc/>
public IDisposable SuppressAutoRebuild()
{
this.buildSuppressionCounter++;
return Disposable.Create(
() =>
{
this.buildSuppressionCounter--;
if (this.buildSuppressionSuppressed)
this.OnRebuildRecommend();
});
}
/// <inheritdoc/>
public IFontHandle NewGameFontHandle(GameFontStyle style) => this.gameFontHandleManager.NewFontHandle(style);
@ -363,15 +380,6 @@ internal sealed partial class FontAtlasFactory
public IFontHandle NewDelegateFontHandle(FontAtlasBuildStepDelegate buildStepDelegate) =>
this.delegateFontHandleManager.NewFontHandle(buildStepDelegate);
/// <inheritdoc/>
public void FreeFontHandle(IFontHandle handle)
{
foreach (var manager in this.fontHandleManagers)
{
manager.FreeFontHandle(handle);
}
}
/// <inheritdoc/>
public void BuildFontsOnNextFrame()
{
@ -688,6 +696,13 @@ internal sealed partial class FontAtlasFactory
if (this.disposed)
return;
if (this.buildSuppressionCounter > 0)
{
this.buildSuppressionSuppressed = true;
return;
}
this.buildSuppressionSuppressed = false;
this.factory.Framework.RunOnFrameworkThread(
() =>
{