Browse Source

Implement JxlMemoryManager

For now JxlMemoryManager will be a wrapper around MemoryPool<T>.
pull/3153/head
winscripter 2 days ago
parent
commit
31b5505d89
  1. 1
      src/ImageSharp/Formats/Jxl/Ac/JxlAcStrategyImage.cs
  2. 12
      src/ImageSharp/Formats/Jxl/Memory/IJxlMemoryManager.cs
  3. 18
      src/ImageSharp/Formats/Jxl/Memory/JxlMemoryManager.cs

1
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;

12
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<T> Allocate<T>(int size);
IMemoryOwner<byte> Allocate(int size);
}

18
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;
/// <summary>
/// Allows allocation and deallocation of managed memory.
/// </summary>
internal sealed class JxlMemoryManager : IJxlMemoryManager
{
public static readonly JxlMemoryManager Instance = new();
public IMemoryOwner<T> Allocate<T>(int size) => MemoryPool<T>.Shared.Rent(size);
public IMemoryOwner<byte> Allocate(int size) => this.Allocate<byte>(size);
}
Loading…
Cancel
Save