Implement DrawListTextureWrap (#2036)

* Implement DrawListTextureWrap

* Fix unloading

* minor fixes

* Add CreateFromClipboardAsync

---------

Co-authored-by: goat <16760685+goaaats@users.noreply.github.com>
This commit is contained in:
srkizer 2025-05-10 05:47:42 +09:00 committed by GitHub
parent a12c63d6a2
commit 4dce0c00e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 2821 additions and 35 deletions

View file

@ -9,6 +9,8 @@ using Dalamud.Interface.Internal.Windows.Data.Widgets;
using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures.TextureWraps;
using ImGuiNET;
using Lumina.Data.Files;
namespace Dalamud.Plugin.Services;
@ -45,6 +47,14 @@ public interface ITextureProvider
bool cpuWrite,
string? debugName = null);
/// <summary>Creates a texture that can be drawn from an <see cref="ImDrawList"/> or an <see cref="ImDrawData"/>.
/// </summary>
/// <param name="debugName">Name for debug display purposes.</param>
/// <returns>A new draw list texture.</returns>
/// <remarks>No new resource is allocated upfront; it will be done when <see cref="IDrawListTextureWrap.Size"/> is
/// set with positive values for both components.</remarks>
IDrawListTextureWrap CreateDrawListTexture(string? debugName = null);
/// <summary>Creates a texture from the given existing texture, cropping and converting pixel format as needed.
/// </summary>
/// <param name="wrap">The source texture wrap. The passed value may be disposed once this function returns,
@ -169,6 +179,14 @@ public interface ITextureProvider
string? debugName = null,
CancellationToken cancellationToken = default);
/// <summary>Creates a texture from clipboard.</summary>
/// <param name="debugName">Name for debug display purposes.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A <see cref="Task"/> representing the status of the operation.</returns>
Task<IDalamudTextureWrap> CreateFromClipboardAsync(
string? debugName = null,
CancellationToken cancellationToken = default);
/// <summary>Gets the supported bitmap decoders.</summary>
/// <returns>The supported bitmap decoders.</returns>
/// <remarks>
@ -192,6 +210,11 @@ public interface ITextureProvider
/// </remarks>
ISharedImmediateTexture GetFromGameIcon(in GameIconLookup lookup);
/// <summary>Gets a value indicating whether the current desktop clipboard contains an image that can be attempted
/// to read using <see cref="CreateFromClipboardAsync"/>.</summary>
/// <returns><c>true</c> if it is the case.</returns>
bool HasClipboardImage();
/// <summary>Gets a shared texture corresponding to the given game resource icon specifier.</summary>
/// <remarks>
/// <para>This function does not throw exceptions.</para>

View file

@ -106,4 +106,17 @@ public interface ITextureReadbackProvider
IReadOnlyDictionary<string, object>? props = null,
bool leaveWrapOpen = false,
CancellationToken cancellationToken = default);
/// <summary>Copies the texture to clipboard.</summary>
/// <param name="wrap">Texture wrap to copy.</param>
/// <param name="preferredFileNameWithoutExtension">Preferred file name.</param>
/// <param name="leaveWrapOpen">Whether to leave <paramref name="wrap"/> non-disposed when the returned
/// <see cref="Task{TResult}"/> completes.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A <see cref="Task"/> representing the status of the operation.</returns>
Task CopyToClipboardAsync(
IDalamudTextureWrap wrap,
string? preferredFileNameWithoutExtension = null,
bool leaveWrapOpen = false,
CancellationToken cancellationToken = default);
}