This commit is contained in:
Soreepeong 2024-02-22 18:07:42 +09:00
parent 71b84bcf40
commit 2c013f39ca
3 changed files with 7 additions and 13 deletions

View file

@ -1,4 +1,3 @@
using System.Buffers;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -54,7 +53,6 @@ internal sealed class FileSystemSharableTexture : SharableTexture
/// <inheritdoc/>
protected override void ReleaseResources()
{
this.DisposeSuppressingWrap = null;
_ = this.UnderlyingWrap?.ToContentDisposedTask(true);
this.UnderlyingWrap = null;
}

View file

@ -55,7 +55,6 @@ internal sealed class GamePathSharableTexture : SharableTexture
/// <inheritdoc/>
protected override void ReleaseResources()
{
this.DisposeSuppressingWrap = null;
_ = this.UnderlyingWrap?.ToContentDisposedTask(true);
this.UnderlyingWrap = null;
}
@ -74,8 +73,6 @@ internal sealed class GamePathSharableTexture : SharableTexture
if (dm.GetFile<TexFile>(this.path) is not { } file)
throw new FileNotFoundException();
cancellationToken.ThrowIfCancellationRequested();
var t = tm.NoThrottleGetFromTexFile(file);
this.DisposeSuppressingWrap = new(t);
return t;
return tm.NoThrottleGetFromTexFile(file);
}
}

View file

@ -23,6 +23,7 @@ internal abstract class SharableTexture : IRefCountable, TextureLoadThrottler.IT
private long selfReferenceExpiry;
private IDalamudTextureWrap? availableOnAccessWrapForApi9;
private CancellationTokenSource? cancellationTokenSource;
private DisposeSuppressingTextureWrap? disposeSuppressingWrap;
/// <summary>
/// Initializes a new instance of the <see cref="SharableTexture"/> class.
@ -102,11 +103,6 @@ internal abstract class SharableTexture : IRefCountable, TextureLoadThrottler.IT
/// </summary>
public bool ContentQueried { get; private set; }
/// <summary>
/// Gets or sets the dispose-suppressing wrap for <see cref="UnderlyingWrap"/>.
/// </summary>
protected DisposeSuppressingTextureWrap? DisposeSuppressingWrap { get; set; }
/// <summary>
/// Gets a cancellation token for cancelling load.
/// Intended to be called from implementors' constructors and <see cref="ReviveResources"/>.
@ -168,6 +164,7 @@ internal abstract class SharableTexture : IRefCountable, TextureLoadThrottler.IT
this.cancellationTokenSource?.Cancel();
this.cancellationTokenSource = null;
this.disposeSuppressingWrap = null;
this.ReleaseResources();
this.resourceReleased = true;
@ -238,7 +235,9 @@ internal abstract class SharableTexture : IRefCountable, TextureLoadThrottler.IT
// Release the reference for rendering, after rendering ImGui.
Service<InterfaceManager>.Get().EnqueueDeferredDispose(this);
return this.DisposeSuppressingWrap;
return this.UnderlyingWrap?.IsCompletedSuccessfully is true
? this.disposeSuppressingWrap ??= new(this.UnderlyingWrap.Result)
: null;
}
}
@ -458,7 +457,7 @@ internal abstract class SharableTexture : IRefCountable, TextureLoadThrottler.IT
return t;
this.inner.UnderlyingWrap?.Wait();
return this.inner.DisposeSuppressingWrap ?? Service<DalamudAssetManager>.Get().Empty4X4;
return this.inner.disposeSuppressingWrap ?? Service<DalamudAssetManager>.Get().Empty4X4;
}
}
}