mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 04:13:40 +01:00
cleanup
This commit is contained in:
parent
35f3802471
commit
b52d4724e9
4 changed files with 15 additions and 60 deletions
|
|
@ -13,30 +13,15 @@ internal sealed class FileSystemSharedImmediateTexture : SharedImmediateTexture
|
|||
|
||||
/// <summary>Initializes a new instance of the <see cref="FileSystemSharedImmediateTexture"/> class.</summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="holdSelfReference">If set to <c>true</c>, this class will hold a reference to self.
|
||||
/// Otherwise, it is expected that the caller to hold the reference.</param>
|
||||
private FileSystemSharedImmediateTexture(string path, bool holdSelfReference)
|
||||
: base(holdSelfReference)
|
||||
{
|
||||
this.path = path;
|
||||
if (holdSelfReference)
|
||||
this.ReviveResources();
|
||||
}
|
||||
private FileSystemSharedImmediateTexture(string path) => this.path = path;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string SourcePathForDebug => this.path;
|
||||
|
||||
/// <summary>Creates a new instance of <see cref="GamePathSharedImmediateTexture"/>.
|
||||
/// The new instance will hold a reference to itself.</summary>
|
||||
/// <summary>Creates a new placeholder instance of <see cref="GamePathSharedImmediateTexture"/>.</summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>The new instance.</returns>
|
||||
public static SharedImmediateTexture CreateImmediate(string path) => new FileSystemSharedImmediateTexture(path, true);
|
||||
|
||||
/// <summary>Creates a new instance of <see cref="GamePathSharedImmediateTexture"/>.
|
||||
/// The caller is expected to manage ownership of the new instance.</summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>The new instance.</returns>
|
||||
public static SharedImmediateTexture CreateAsync(string path) => new FileSystemSharedImmediateTexture(path, false);
|
||||
public static SharedImmediateTexture CreatePlaceholder(string path) => new FileSystemSharedImmediateTexture(path);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString() =>
|
||||
|
|
|
|||
|
|
@ -16,30 +16,15 @@ internal sealed class GamePathSharedImmediateTexture : SharedImmediateTexture
|
|||
|
||||
/// <summary>Initializes a new instance of the <see cref="GamePathSharedImmediateTexture"/> class.</summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="holdSelfReference">If set to <c>true</c>, this class will hold a reference to self.
|
||||
/// Otherwise, it is expected that the caller to hold the reference.</param>
|
||||
private GamePathSharedImmediateTexture(string path, bool holdSelfReference)
|
||||
: base(holdSelfReference)
|
||||
{
|
||||
this.path = path;
|
||||
if (holdSelfReference)
|
||||
this.ReviveResources();
|
||||
}
|
||||
private GamePathSharedImmediateTexture(string path) => this.path = path;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string SourcePathForDebug => this.path;
|
||||
|
||||
/// <summary>Creates a new instance of <see cref="GamePathSharedImmediateTexture"/>.
|
||||
/// The new instance will hold a reference to itself.</summary>
|
||||
/// <summary>Creates a new placeholder instance of <see cref="GamePathSharedImmediateTexture"/>.</summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>The new instance.</returns>
|
||||
public static SharedImmediateTexture CreateImmediate(string path) => new GamePathSharedImmediateTexture(path, true);
|
||||
|
||||
/// <summary>Creates a new instance of <see cref="GamePathSharedImmediateTexture"/>.
|
||||
/// The caller is expected to manage ownership of the new instance.</summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>The new instance.</returns>
|
||||
public static SharedImmediateTexture CreateAsync(string path) => new GamePathSharedImmediateTexture(path, false);
|
||||
public static SharedImmediateTexture CreatePlaceholder(string path) => new GamePathSharedImmediateTexture(path);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString() => $"{nameof(GamePathSharedImmediateTexture)}#{this.InstanceIdForDebug}({this.path})";
|
||||
|
|
|
|||
|
|
@ -27,30 +27,15 @@ internal abstract class SharedImmediateTexture
|
|||
private NotOwnedTextureWrap? nonOwningWrap;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="SharedImmediateTexture"/> class.</summary>
|
||||
/// <param name="holdSelfReference">If set to <c>true</c>, this class will hold a reference to self.
|
||||
/// Otherwise, it is expected that the caller to hold the reference.</param>
|
||||
protected SharedImmediateTexture(bool holdSelfReference)
|
||||
/// <remarks>The new instance is a placeholder instance.</remarks>
|
||||
protected SharedImmediateTexture()
|
||||
{
|
||||
this.InstanceIdForDebug = Interlocked.Increment(ref instanceCounter);
|
||||
|
||||
if (holdSelfReference)
|
||||
{
|
||||
this.refCount = 1;
|
||||
this.selfReferenceExpiry = Environment.TickCount64 + SelfReferenceDurationTicks;
|
||||
this.ContentQueried = true;
|
||||
this.IsOpportunistic = true;
|
||||
this.resourceReleased = false;
|
||||
this.cancellationTokenSource = new();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.refCount = 0;
|
||||
this.selfReferenceExpiry = SelfReferenceExpiryExpired;
|
||||
this.ContentQueried = false;
|
||||
this.IsOpportunistic = false;
|
||||
this.resourceReleased = true;
|
||||
}
|
||||
|
||||
this.refCount = 0;
|
||||
this.selfReferenceExpiry = SelfReferenceExpiryExpired;
|
||||
this.ContentQueried = false;
|
||||
this.IsOpportunistic = true;
|
||||
this.resourceReleased = true;
|
||||
this.FirstRequestedTick = this.LatestRequestedTick = Environment.TickCount64;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -158,12 +158,12 @@ internal sealed class TextureManager : IServiceType, IDisposable, ITextureProvid
|
|||
/// <inheritdoc cref="ITextureProvider.GetFromGame"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public SharedImmediateTexture GetFromGame(string path) =>
|
||||
this.gamePathTextures.GetOrAdd(path, GamePathSharedImmediateTexture.CreateImmediate);
|
||||
this.gamePathTextures.GetOrAdd(path, GamePathSharedImmediateTexture.CreatePlaceholder);
|
||||
|
||||
/// <inheritdoc cref="ITextureProvider.GetFromFile"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public SharedImmediateTexture GetFromFile(string path) =>
|
||||
this.fileSystemTextures.GetOrAdd(path, FileSystemSharedImmediateTexture.CreateImmediate);
|
||||
this.fileSystemTextures.GetOrAdd(path, FileSystemSharedImmediateTexture.CreatePlaceholder);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue