make it consistent

This commit is contained in:
Soreepeong 2024-02-28 22:16:40 +09:00
parent ca986b46a2
commit b34a901702
4 changed files with 12 additions and 12 deletions

View file

@ -44,6 +44,6 @@ internal sealed class FileSystemSharedImmediateTexture : SharedImmediateTexture
private async Task<IDalamudTextureWrap> CreateTextureAsync(CancellationToken cancellationToken) private async Task<IDalamudTextureWrap> CreateTextureAsync(CancellationToken cancellationToken)
{ {
var tm = await Service<TextureManager>.GetAsync(); var tm = await Service<TextureManager>.GetAsync();
return tm.NoThrottleGetFromImage(await File.ReadAllBytesAsync(this.path, cancellationToken)); return tm.NoThrottleCreateFromImage(await File.ReadAllBytesAsync(this.path, cancellationToken));
} }
} }

View file

@ -50,6 +50,6 @@ internal sealed class GamePathSharedImmediateTexture : SharedImmediateTexture
if (dm.GetFile<TexFile>(this.path) is not { } file) if (dm.GetFile<TexFile>(this.path) is not { } file)
throw new FileNotFoundException(); throw new FileNotFoundException();
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
return tm.NoThrottleGetFromTexFile(file); return tm.NoThrottleCreateFromTexFile(file);
} }
} }

View file

@ -59,6 +59,6 @@ internal sealed class ManifestResourceSharedImmediateTexture : SharedImmediateTe
var tm = await Service<TextureManager>.GetAsync(); var tm = await Service<TextureManager>.GetAsync();
var ms = new MemoryStream(stream.CanSeek ? (int)stream.Length : 0); var ms = new MemoryStream(stream.CanSeek ? (int)stream.Length : 0);
await stream.CopyToAsync(ms, cancellationToken); await stream.CopyToAsync(ms, cancellationToken);
return tm.NoThrottleGetFromImage(ms.GetBuffer().AsMemory(0, (int)ms.Length)); return tm.NoThrottleCreateFromImage(ms.GetBuffer().AsMemory(0, (int)ms.Length));
} }
} }

View file

@ -221,7 +221,7 @@ internal sealed class TextureManager : IServiceType, IDisposable, ITextureProvid
CancellationToken cancellationToken = default) => CancellationToken cancellationToken = default) =>
this.textureLoadThrottler.CreateLoader( this.textureLoadThrottler.CreateLoader(
new TextureLoadThrottler.ReadOnlyThrottleBasisProvider(), new TextureLoadThrottler.ReadOnlyThrottleBasisProvider(),
ct => Task.Run(() => this.NoThrottleGetFromImage(bytes.ToArray()), ct), ct => Task.Run(() => this.NoThrottleCreateFromImage(bytes.ToArray()), ct),
cancellationToken); cancellationToken);
/// <inheritdoc/> /// <inheritdoc/>
@ -339,7 +339,7 @@ internal sealed class TextureManager : IServiceType, IDisposable, ITextureProvid
CancellationToken cancellationToken = default) => CancellationToken cancellationToken = default) =>
this.textureLoadThrottler.CreateLoader( this.textureLoadThrottler.CreateLoader(
new TextureLoadThrottler.ReadOnlyThrottleBasisProvider(), new TextureLoadThrottler.ReadOnlyThrottleBasisProvider(),
ct => Task.Run(() => this.NoThrottleGetFromTexFile(file), ct), ct => Task.Run(() => this.NoThrottleCreateFromTexFile(file), ct),
cancellationToken); cancellationToken);
/// <inheritdoc/> /// <inheritdoc/>
@ -465,11 +465,11 @@ internal sealed class TextureManager : IServiceType, IDisposable, ITextureProvid
} }
} }
/// <summary>Gets a texture from the given image. Skips the load throttler; intended to be used from implementation /// <summary>Creates a texture from the given bytes of an image file. Skips the load throttler; intended to be used
/// of <see cref="SharedImmediateTexture"/>s.</summary> /// from implementation of <see cref="SharedImmediateTexture"/>s.</summary>
/// <param name="bytes">The data.</param> /// <param name="bytes">The data.</param>
/// <returns>The loaded texture.</returns> /// <returns>The loaded texture.</returns>
internal IDalamudTextureWrap NoThrottleGetFromImage(ReadOnlyMemory<byte> bytes) internal IDalamudTextureWrap NoThrottleCreateFromImage(ReadOnlyMemory<byte> bytes)
{ {
ObjectDisposedException.ThrowIf(this.disposing, this); ObjectDisposedException.ThrowIf(this.disposing, this);
@ -493,7 +493,7 @@ internal sealed class TextureManager : IServiceType, IDisposable, ITextureProvid
// Note: FileInfo and FilePath are not used from TexFile; skip it. // Note: FileInfo and FilePath are not used from TexFile; skip it.
try try
{ {
return this.NoThrottleGetFromTexFile(tf); return this.NoThrottleCreateFromTexFile(tf);
} }
catch (Exception e) catch (Exception e)
{ {
@ -506,11 +506,11 @@ internal sealed class TextureManager : IServiceType, IDisposable, ITextureProvid
?? throw texFileAttemptException ?? new("Failed to load image because of an unknown reason.")); ?? throw texFileAttemptException ?? new("Failed to load image because of an unknown reason."));
} }
/// <summary>Gets a texture from the given <see cref="TexFile"/>. Skips the load throttler; intended to be used from /// <summary>Creates a texture from the given <see cref="TexFile"/>. Skips the load throttler; intended to be used
/// implementation of <see cref="SharedImmediateTexture"/>s.</summary> /// from implementation of <see cref="SharedImmediateTexture"/>s.</summary>
/// <param name="file">The data.</param> /// <param name="file">The data.</param>
/// <returns>The loaded texture.</returns> /// <returns>The loaded texture.</returns>
internal IDalamudTextureWrap NoThrottleGetFromTexFile(TexFile file) internal IDalamudTextureWrap NoThrottleCreateFromTexFile(TexFile file)
{ {
ObjectDisposedException.ThrowIf(this.disposing, this); ObjectDisposedException.ThrowIf(this.disposing, this);