mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Rename to CreateWrapSharingLowLevelResource
This commit is contained in:
parent
f6be80a5fb
commit
9629a555be
2 changed files with 16 additions and 8 deletions
|
|
@ -8,7 +8,7 @@ namespace Dalamud.Interface.Internal;
|
|||
/// Base TextureWrap interface for all Dalamud-owned texture wraps.
|
||||
/// Used to avoid referencing ImGuiScene.
|
||||
/// </summary>
|
||||
public interface IDalamudTextureWrap : IDisposable, ICloneable
|
||||
public interface IDalamudTextureWrap : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a texture handle suitable for direct use with ImGui functions.
|
||||
|
|
@ -31,17 +31,25 @@ public interface IDalamudTextureWrap : IDisposable, ICloneable
|
|||
Vector2 Size => new(this.Width, this.Height);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new reference to this texture wrap.
|
||||
/// Creates a new reference to the resource being pointed by this instance of <see cref="IDalamudTextureWrap"/>.
|
||||
/// </summary>
|
||||
/// <returns>The new reference to this texture wrap.</returns>
|
||||
/// <remarks>The default implementation will treat <see cref="ImGuiHandle"/> as an <see cref="IUnknown"/>.</remarks>
|
||||
new unsafe IDalamudTextureWrap Clone()
|
||||
/// <remarks>
|
||||
/// On calling this function, a new instance of <see cref="IDalamudTextureWrap"/> will be returned, but with
|
||||
/// the same <see cref="ImGuiHandle"/>. The new instance must be <see cref="IDisposable.Dispose"/>d, as the backing
|
||||
/// resource will stay alive until all the references are released. The old instance may be disposed as needed,
|
||||
/// once this function returns; the new instance will stay alive regardless of whether the old instance has been
|
||||
/// disposed.<br />
|
||||
/// Primary purpose of this function is to share textures across plugin boundaries. When texture wraps get passed
|
||||
/// across plugin boundaries for use for an indeterminate duration, the receiver should call this function to
|
||||
/// obtain a new reference to the texture received, so that it gets its own "copy" of the texture and the caller
|
||||
/// may dispose the texture anytime without any care for the receiver.<br />
|
||||
/// The default implementation will treat <see cref="ImGuiHandle"/> as an <see cref="IUnknown"/>.
|
||||
/// </remarks>
|
||||
unsafe IDalamudTextureWrap CreateWrapSharingLowLevelResource()
|
||||
{
|
||||
// Dalamud specific: IDalamudTextureWrap always points to an ID3D11ShaderResourceView.
|
||||
var handle = (IUnknown*)this.ImGuiHandle;
|
||||
return new UnknownTextureWrap(handle, this.Width, this.Height, true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
object ICloneable.Clone() => this.Clone();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ internal class TexWidget : IDataWindowWidget
|
|||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button($"Clone##{i}"))
|
||||
this.addedTextures.Add(tex.Clone());
|
||||
this.addedTextures.Add(tex.CreateWrapSharingLowLevelResource());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue