mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 20:33:40 +01:00
Inline as seen fit
This commit is contained in:
parent
55b5c5094a
commit
b16fa5cb46
3 changed files with 24 additions and 13 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
@ -210,10 +211,12 @@ internal abstract class SharedImmediateTexture
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public IDalamudTextureWrap GetWrap() => this.GetWrap(Service<DalamudAssetManager>.Get().Empty4X4);
|
public IDalamudTextureWrap GetWrap() => this.GetWrap(Service<DalamudAssetManager>.Get().Empty4X4);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
[return: NotNullIfNotNull(nameof(defaultWrap))]
|
[return: NotNullIfNotNull(nameof(defaultWrap))]
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public IDalamudTextureWrap? GetWrap(IDalamudTextureWrap? defaultWrap)
|
public IDalamudTextureWrap? GetWrap(IDalamudTextureWrap? defaultWrap)
|
||||||
{
|
{
|
||||||
if (!this.TryGetWrap(out var texture, out _))
|
if (!this.TryGetWrap(out var texture, out _))
|
||||||
|
|
@ -222,6 +225,7 @@ internal abstract class SharedImmediateTexture
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool TryGetWrap([NotNullWhen(true)] out IDalamudTextureWrap? texture, out Exception? exception)
|
public bool TryGetWrap([NotNullWhen(true)] out IDalamudTextureWrap? texture, out Exception? exception)
|
||||||
{
|
{
|
||||||
ThreadSafety.AssertMainThread();
|
ThreadSafety.AssertMainThread();
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ internal class TextureLoadThrottler : IServiceType, IDisposable
|
||||||
private readonly Channel<object?> workTokenChannel = Channel.CreateUnbounded<object?>();
|
private readonly Channel<object?> workTokenChannel = Channel.CreateUnbounded<object?>();
|
||||||
private readonly List<WorkItem> workItemPending = new();
|
private readonly List<WorkItem> workItemPending = new();
|
||||||
|
|
||||||
|
private bool disposing;
|
||||||
|
|
||||||
[ServiceManager.ServiceConstructor]
|
[ServiceManager.ServiceConstructor]
|
||||||
private TextureLoadThrottler()
|
private TextureLoadThrottler()
|
||||||
{
|
{
|
||||||
|
|
@ -54,6 +56,10 @@ internal class TextureLoadThrottler : IServiceType, IDisposable
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
if (this.disposing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.disposing = true;
|
||||||
this.newItemChannel.Writer.Complete();
|
this.newItemChannel.Writer.Complete();
|
||||||
this.workTokenChannel.Writer.Complete();
|
this.workTokenChannel.Writer.Complete();
|
||||||
this.disposeCancellationTokenSource.Cancel();
|
this.disposeCancellationTokenSource.Cancel();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
@ -14,7 +15,6 @@ using Dalamud.IoC;
|
||||||
using Dalamud.IoC.Internal;
|
using Dalamud.IoC.Internal;
|
||||||
using Dalamud.Logging.Internal;
|
using Dalamud.Logging.Internal;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using Dalamud.Storage.Assets;
|
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
|
|
||||||
using Lumina.Data.Files;
|
using Lumina.Data.Files;
|
||||||
|
|
@ -26,8 +26,6 @@ using SharpDX.DXGI;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Internal;
|
namespace Dalamud.Interface.Internal;
|
||||||
|
|
||||||
// TODO API10: Remove keepAlive from public APIs
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Service responsible for loading and disposing ImGui texture wraps.
|
/// Service responsible for loading and disposing ImGui texture wraps.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -45,14 +43,11 @@ internal sealed class TextureManager : IServiceType, IDisposable, ITextureProvid
|
||||||
private const string IconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}.tex";
|
private const string IconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}.tex";
|
||||||
private const string HighResolutionIconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}_hr1.tex";
|
private const string HighResolutionIconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}_hr1.tex";
|
||||||
|
|
||||||
private static readonly ModuleLog Log = new("TEXM");
|
private static readonly ModuleLog Log = new(nameof(TextureManager));
|
||||||
|
|
||||||
[ServiceManager.ServiceDependency]
|
[ServiceManager.ServiceDependency]
|
||||||
private readonly Dalamud dalamud = Service<Dalamud>.Get();
|
private readonly Dalamud dalamud = Service<Dalamud>.Get();
|
||||||
|
|
||||||
[ServiceManager.ServiceDependency]
|
|
||||||
private readonly DalamudAssetManager dalamudAssetManager = Service<DalamudAssetManager>.Get();
|
|
||||||
|
|
||||||
[ServiceManager.ServiceDependency]
|
[ServiceManager.ServiceDependency]
|
||||||
private readonly DataManager dataManager = Service<DataManager>.Get();
|
private readonly DataManager dataManager = Service<DataManager>.Get();
|
||||||
|
|
||||||
|
|
@ -73,10 +68,7 @@ internal sealed class TextureManager : IServiceType, IDisposable, ITextureProvid
|
||||||
private bool disposing;
|
private bool disposing;
|
||||||
|
|
||||||
[ServiceManager.ServiceConstructor]
|
[ServiceManager.ServiceConstructor]
|
||||||
private TextureManager()
|
private TextureManager() => this.framework.Update += this.FrameworkOnUpdate;
|
||||||
{
|
|
||||||
this.framework.Update += this.FrameworkOnUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public event ITextureSubstitutionProvider.TextureDataInterceptorDelegate? InterceptTexDataLoad;
|
public event ITextureSubstitutionProvider.TextureDataInterceptorDelegate? InterceptTexDataLoad;
|
||||||
|
|
@ -118,7 +110,8 @@ internal sealed class TextureManager : IServiceType, IDisposable, ITextureProvid
|
||||||
this.fileSystemTextures.Clear();
|
this.fileSystemTextures.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region API9 compat
|
#region API9 compat
|
||||||
|
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
[Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)]
|
[Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)]
|
||||||
|
|
@ -162,27 +155,34 @@ internal sealed class TextureManager : IServiceType, IDisposable, ITextureProvid
|
||||||
IDalamudTextureWrap? ITextureProvider.GetTextureFromFile(FileInfo file, bool keepAlive) =>
|
IDalamudTextureWrap? ITextureProvider.GetTextureFromFile(FileInfo file, bool keepAlive) =>
|
||||||
this.GetFromFile(file.FullName).GetAvailableOnAccessWrapForApi9();
|
this.GetFromFile(file.FullName).GetAvailableOnAccessWrapForApi9();
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
#endregion
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <inheritdoc cref="ITextureProvider.GetFromGameIcon"/>
|
/// <inheritdoc cref="ITextureProvider.GetFromGameIcon"/>
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public SharedImmediateTexture GetFromGameIcon(in GameIconLookup lookup) =>
|
public SharedImmediateTexture GetFromGameIcon(in GameIconLookup lookup) =>
|
||||||
this.GetFromGame(this.lookupToPath.GetOrAdd(lookup, this.GetIconPathByValue));
|
this.GetFromGame(this.lookupToPath.GetOrAdd(lookup, this.GetIconPathByValue));
|
||||||
|
|
||||||
/// <inheritdoc cref="ITextureProvider.GetFromGame"/>
|
/// <inheritdoc cref="ITextureProvider.GetFromGame"/>
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public SharedImmediateTexture GetFromGame(string path) =>
|
public SharedImmediateTexture GetFromGame(string path) =>
|
||||||
this.gamePathTextures.GetOrAdd(path, GamePathSharedImmediateTexture.CreateImmediate);
|
this.gamePathTextures.GetOrAdd(path, GamePathSharedImmediateTexture.CreateImmediate);
|
||||||
|
|
||||||
/// <inheritdoc cref="ITextureProvider.GetFromFile"/>
|
/// <inheritdoc cref="ITextureProvider.GetFromFile"/>
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public SharedImmediateTexture GetFromFile(string path) =>
|
public SharedImmediateTexture GetFromFile(string path) =>
|
||||||
this.fileSystemTextures.GetOrAdd(path, FileSystemSharedImmediateTexture.CreateImmediate);
|
this.fileSystemTextures.GetOrAdd(path, FileSystemSharedImmediateTexture.CreateImmediate);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
ISharedImmediateTexture ITextureProvider.GetFromGameIcon(in GameIconLookup lookup) => this.GetFromGameIcon(lookup);
|
ISharedImmediateTexture ITextureProvider.GetFromGameIcon(in GameIconLookup lookup) => this.GetFromGameIcon(lookup);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
ISharedImmediateTexture ITextureProvider.GetFromGame(string path) => this.GetFromGame(path);
|
ISharedImmediateTexture ITextureProvider.GetFromGame(string path) => this.GetFromGame(path);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
ISharedImmediateTexture ITextureProvider.GetFromFile(string path) => this.GetFromFile(path);
|
ISharedImmediateTexture ITextureProvider.GetFromFile(string path) => this.GetFromFile(path);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
@ -519,6 +519,7 @@ internal sealed class TextureManager : IServiceType, IDisposable, ITextureProvid
|
||||||
v.ContentQueried && v.ReleaseSelfReference(false) == 0 && !v.HasRevivalPossibility;
|
v.ContentQueried && v.ReleaseSelfReference(false) == 0 && !v.HasRevivalPossibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private string GetIconPathByValue(GameIconLookup lookup) =>
|
private string GetIconPathByValue(GameIconLookup lookup) =>
|
||||||
this.TryGetIconPath(lookup, out var path) ? path : throw new FileNotFoundException();
|
this.TryGetIconPath(lookup, out var path) ? path : throw new FileNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue