mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-18 05:47:43 +01:00
Move save get/save functions to ITextureReadbackProvider
This commit is contained in:
parent
fa5e708a43
commit
5ad8edbc04
7 changed files with 135 additions and 120 deletions
|
|
@ -45,7 +45,7 @@ internal sealed partial class TextureManager
|
|||
/// <inheritdoc/>
|
||||
public Task<IDalamudTextureWrap> CreateFromExistingTextureAsync(
|
||||
IDalamudTextureWrap wrap,
|
||||
ExistingTextureModificationArgs args = default,
|
||||
TextureModificationArgs args = default,
|
||||
bool leaveWrapOpen = false,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
|
|
@ -94,9 +94,9 @@ internal sealed partial class TextureManager
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<(RawImageSpecification Specification, byte[] RawData)> GetRawDataFromExistingTextureAsync(
|
||||
public async Task<(RawImageSpecification Specification, byte[] RawData)> GetRawImageAsync(
|
||||
IDalamudTextureWrap wrap,
|
||||
ExistingTextureModificationArgs args = default,
|
||||
TextureModificationArgs args = default,
|
||||
bool leaveWrapOpen = false,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
|
|
@ -197,7 +197,7 @@ internal sealed partial class TextureManager
|
|||
|
||||
private async Task<ComPtr<ID3D11Texture2D>> NoThrottleCreateFromExistingTextureAsync(
|
||||
IDalamudTextureWrap wrap,
|
||||
ExistingTextureModificationArgs args)
|
||||
TextureModificationArgs args)
|
||||
{
|
||||
args.ThrowOnInvalidValues();
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ internal sealed partial class TextureManager
|
|||
|
||||
using var istream = ManagedIStream.Create(stream, leaveStreamOpen);
|
||||
|
||||
var (specs, bytes) = await this.GetRawDataFromExistingTextureAsync(
|
||||
var (specs, bytes) = await this.GetRawImageAsync(
|
||||
wrap,
|
||||
new()
|
||||
{
|
||||
|
|
@ -164,7 +164,7 @@ internal sealed partial class TextureManager
|
|||
this.Wic.GetSupportedDecoderInfos();
|
||||
|
||||
/// <inheritdoc/>
|
||||
IEnumerable<IBitmapCodecInfo> ITextureProvider.GetSupportedImageEncoderInfos() =>
|
||||
IEnumerable<IBitmapCodecInfo> ITextureReadbackProvider.GetSupportedImageEncoderInfos() =>
|
||||
this.Wic.GetSupportedEncoderInfos();
|
||||
|
||||
/// <summary>Creates a texture from the given bytes of an image file. Skips the load throttler; intended to be used
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ namespace Dalamud.Interface.Textures.Internal;
|
|||
[ResolveVia<ITextureProvider>]
|
||||
[ResolveVia<ITextureSubstitutionProvider>]
|
||||
#pragma warning restore SA1015
|
||||
internal sealed partial class TextureManager : IServiceType, IDisposable, ITextureProvider, ITextureSubstitutionProvider
|
||||
internal sealed partial class TextureManager
|
||||
: IServiceType, IDisposable, ITextureProvider, ITextureSubstitutionProvider, ITextureReadbackProvider
|
||||
{
|
||||
private static readonly ModuleLog Log = new(nameof(TextureManager));
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ using TerraFX.Interop.DirectX;
|
|||
|
||||
namespace Dalamud.Interface.Textures;
|
||||
|
||||
/// <summary>Describes how to modify an existing texture.</summary>
|
||||
public record struct ExistingTextureModificationArgs()
|
||||
/// <summary>Describes how to modify a texture.</summary>
|
||||
public record struct TextureModificationArgs()
|
||||
{
|
||||
/// <summary>Gets or sets a value indicating whether to make the texture opaque.</summary>
|
||||
/// <remarks>If <c>true</c>, then the alpha channel values will be filled with 1.0.</remarks>
|
||||
|
|
@ -52,10 +52,10 @@ public record struct ExistingTextureModificationArgs()
|
|||
/// <summary>Gets the effective value of <see cref="Uv1"/>.</summary>
|
||||
internal Vector2 Uv1Effective => this.Uv1 == Vector2.Zero ? Vector2.One : this.Uv1;
|
||||
|
||||
/// <summary>Test if this instance of <see cref="ExistingTextureModificationArgs"/> does not instruct to change the
|
||||
/// <summary>Test if this instance of <see cref="TextureModificationArgs"/> does not instruct to change the
|
||||
/// underlying data of a texture.</summary>
|
||||
/// <param name="desc">The texture description to test against.</param>
|
||||
/// <returns><c>true</c> if this instance of <see cref="ExistingTextureModificationArgs"/> does not instruct to
|
||||
/// <returns><c>true</c> if this instance of <see cref="TextureModificationArgs"/> does not instruct to
|
||||
/// change the underlying data of a texture.</returns>
|
||||
internal bool IsCompleteSourceCopy(in D3D11_TEXTURE2D_DESC desc) =>
|
||||
this.Uv0 == Vector2.Zero
|
||||
Loading…
Add table
Add a link
Reference in a new issue