From 31b5505d8987a4beb21f14d47dd700ab763b1e8d Mon Sep 17 00:00:00 2001 From: winscripter <142818255+winscripter@users.noreply.github.com> Date: Wed, 15 Jul 2026 14:51:15 +0400 Subject: [PATCH] Implement JxlMemoryManager For now JxlMemoryManager will be a wrapper around MemoryPool. --- .../Formats/Jxl/Ac/JxlAcStrategyImage.cs | 1 + .../Formats/Jxl/Memory/IJxlMemoryManager.cs | 12 ++++++++++++ .../Formats/Jxl/Memory/JxlMemoryManager.cs | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 src/ImageSharp/Formats/Jxl/Memory/IJxlMemoryManager.cs create mode 100644 src/ImageSharp/Formats/Jxl/Memory/JxlMemoryManager.cs diff --git a/src/ImageSharp/Formats/Jxl/Ac/JxlAcStrategyImage.cs b/src/ImageSharp/Formats/Jxl/Ac/JxlAcStrategyImage.cs index 0ffeabe32b..f41d186e19 100644 --- a/src/ImageSharp/Formats/Jxl/Ac/JxlAcStrategyImage.cs +++ b/src/ImageSharp/Formats/Jxl/Ac/JxlAcStrategyImage.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Diagnostics; +using SixLabors.ImageSharp.Formats.Jxl.Memory; namespace SixLabors.ImageSharp.Formats.Jxl.Ac; diff --git a/src/ImageSharp/Formats/Jxl/Memory/IJxlMemoryManager.cs b/src/ImageSharp/Formats/Jxl/Memory/IJxlMemoryManager.cs new file mode 100644 index 0000000000..c808388d28 --- /dev/null +++ b/src/ImageSharp/Formats/Jxl/Memory/IJxlMemoryManager.cs @@ -0,0 +1,12 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +using System.Buffers; + +namespace SixLabors.ImageSharp.Formats.Jxl.Memory; + +internal interface IJxlMemoryManager +{ + IMemoryOwner Allocate(int size); + IMemoryOwner Allocate(int size); +} diff --git a/src/ImageSharp/Formats/Jxl/Memory/JxlMemoryManager.cs b/src/ImageSharp/Formats/Jxl/Memory/JxlMemoryManager.cs new file mode 100644 index 0000000000..778ef59106 --- /dev/null +++ b/src/ImageSharp/Formats/Jxl/Memory/JxlMemoryManager.cs @@ -0,0 +1,18 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +using System.Buffers; + +namespace SixLabors.ImageSharp.Formats.Jxl.Memory; + +/// +/// Allows allocation and deallocation of managed memory. +/// +internal sealed class JxlMemoryManager : IJxlMemoryManager +{ + public static readonly JxlMemoryManager Instance = new(); + + public IMemoryOwner Allocate(int size) => MemoryPool.Shared.Rent(size); + + public IMemoryOwner Allocate(int size) => this.Allocate(size); +}