Dalamud/Dalamud/Interface/Internal/DalamudTextureWrap.cs

54 lines
1.3 KiB
C#

using System;
using ImGuiScene;
namespace Dalamud.Interface.Internal;
/// <summary>
/// Safety harness for ImGuiScene textures that will defer destruction until
/// the end of the frame.
/// </summary>
public class DalamudTextureWrap : TextureWrap
{
private readonly TextureWrap wrappedWrap;
/// <summary>
/// Initializes a new instance of the <see cref="DalamudTextureWrap"/> class.
/// </summary>
/// <param name="wrappingWrap">The texture wrap to wrap.</param>
internal DalamudTextureWrap(TextureWrap wrappingWrap)
{
this.wrappedWrap = wrappingWrap;
}
/// <summary>
/// Gets the ImGui handle of the texture.
/// </summary>
public IntPtr ImGuiHandle => this.wrappedWrap.ImGuiHandle;
/// <summary>
/// Gets the width of the texture.
/// </summary>
public int Width => this.wrappedWrap.Width;
/// <summary>
/// Gets the height of the texture.
/// </summary>
public int Height => this.wrappedWrap.Height;
/// <summary>
/// Queue the texture to be disposed once the frame ends.
/// </summary>
public void Dispose()
{
Service<InterfaceManager>.Get().EnqueueDeferredDispose(this);
}
/// <summary>
/// Actually dispose the wrapped texture.
/// </summary>
internal void RealDispose()
{
this.wrappedWrap.Dispose();
}
}