diff --git a/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs b/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs index 9a7d84deb..dc0cb0f0f 100644 --- a/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs +++ b/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs @@ -26,6 +26,10 @@ internal sealed partial class TextureManager /// ISharedImmediateTexture ITextureProvider.GetFromFile(string path) => this.Shared.GetFromFile(path); + + /// + ISharedImmediateTexture ITextureProvider.GetFromFile(FileInfo file) => + this.Shared.GetFromFile(file); /// ISharedImmediateTexture ITextureProvider.GetFromManifestResource(Assembly assembly, string name) => @@ -97,13 +101,18 @@ internal sealed partial class TextureManager this.gameDict.GetOrAdd(path, GamePathSharedImmediateTexture.CreatePlaceholder) .PublicUseInstance; - /// + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public SharedImmediateTexture.PureImpl GetFromFile(string path) => - this.fileDict.GetOrAdd(path, FileSystemSharedImmediateTexture.CreatePlaceholder) + this.GetFromFile(new FileInfo(path)); + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public SharedImmediateTexture.PureImpl GetFromFile(FileInfo file) => + this.fileDict.GetOrAdd(file.FullName, FileSystemSharedImmediateTexture.CreatePlaceholder) .PublicUseInstance; - /// + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public SharedImmediateTexture.PureImpl GetFromManifestResource(Assembly assembly, string name) => this.manifestResourceDict.GetOrAdd( diff --git a/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs b/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs index bfba6f65b..9107754a3 100644 --- a/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs +++ b/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs @@ -289,6 +289,14 @@ internal sealed class TextureManagerPluginScoped shared.AddOwnerPlugin(this.plugin); return shared; } + + /// + public ISharedImmediateTexture GetFromFile(FileInfo file) + { + var shared = this.ManagerOrThrow.Shared.GetFromFile(file); + shared.AddOwnerPlugin(this.plugin); + return shared; + } /// public ISharedImmediateTexture GetFromManifestResource(Assembly assembly, string name) diff --git a/Dalamud/Plugin/Services/ITextureProvider.cs b/Dalamud/Plugin/Services/ITextureProvider.cs index 3fd3ab9d8..7541f8f3b 100644 --- a/Dalamud/Plugin/Services/ITextureProvider.cs +++ b/Dalamud/Plugin/Services/ITextureProvider.cs @@ -212,6 +212,15 @@ public interface ITextureProvider /// Caching the returned object is not recommended. Performance benefit will be minimal. /// ISharedImmediateTexture GetFromFile(string path); + + /// Gets a shared texture corresponding to the given file on the filesystem. + /// The file on the filesystem to load. + /// The shared texture that you may use to obtain the loaded texture wrap and load states. + /// + /// This function does not throw exceptions. + /// Caching the returned object is not recommended. Performance benefit will be minimal. + /// + ISharedImmediateTexture GetFromFile(FileInfo file); /// Gets a shared texture corresponding to the given file of the assembly manifest resources. /// The assembly containing manifest resources.