using System; using Robust.Shared.Maths; using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; namespace Robust.Client.Graphics { /// /// Represents a mutable texture that can be modified and deleted. /// public abstract class OwnedTexture : Texture, IDisposable { protected OwnedTexture(Vector2i size) : base(size) { } /// /// Modifies a sub area of the texture with new data. /// /// The top left corner of the area to modify. /// The image from which to copy pixel data. /// The rectangle inside from which to copy. /// /// The type of pixels being used. /// This must match the type used when creating the texture. /// public abstract void SetSubImage(Vector2i topLeft, Image sourceImage, in UIBox2i sourceRegion) where T : unmanaged, IPixel; /// /// Modifies a sub area of the texture with new data. /// /// The top left corner of the area to modify. /// The image to paste onto the texture. /// /// The type of pixels being used. /// This must match the type used when creating the texture. /// public void SetSubImage(Vector2i topLeft, Image sourceImage) where T : unmanaged, IPixel { SetSubImage(topLeft, sourceImage, UIBox2i.FromDimensions(0, 0, sourceImage.Width, sourceImage.Height)); } public abstract void SetSubImage(Vector2i topLeft, Vector2i size, ReadOnlySpan buffer) where T : unmanaged, IPixel; public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { } ~OwnedTexture() { Dispose(false); } } }