-
-
Couldn't load subscription status.
- Fork 888
Closed
Description
Goals
Thanks to #558, we are now able to expose System.Memory API-s allowing efficient interop operations. However, we need to distinguish between different use-cases, because they raise design problems of different difficulty levels. In some use-cases we have to decide whether we should expose Span<T>, Memory<T> or both.
"Official" guideline on System.Memory
Managed to find a WIP (?) documentation on Memory<T>. (It was mentioned in coreclr/#17340)
Tasks
- Basic
ReadOnlySpan<T>overloads of LoadPixelData (done in Expose Span methods on LoadPixelData and SavePixelData #567) -
ReadOnlySpan<T>overloads forImage.Load()andImage.DetectFormat(). See @jherby2k's proposal.- We can pin the span and use
UnmanagedMemoryStreamfor this.
- We can pin the span and use
- Integrate
System.Memory.IMemoryOwner<T>and/orSystem.Memory.MemoryManager<T>withSL.ImageSharp.Memory.IBuffer<T>- Prerequisite for using
Memory<T>, thus for the following 2 points Notice the name collision withUPDATE: SixLabors stuff is now calledSL.ImageSharp.Memory.MemoryManager<T>:PMemoryAllocator
- Prerequisite for using
-
Image.Wrap(existingMemoryArea)or similar.- Very useful for interop scenarios, see Library Inter-op extensions #435 or Passing Unmanaged Pointer as Pixels buffer in ImageSharp #88
Already added as internal, need to validate the API through a real-life use-case.DONE
- Expose
image.GetPixelSpan()andimage.GetPixelRowSpan()- Note: this API can lead to unintended heap capture issues many users fail to understand
- Expose
image.GetPixelSpan()andimage.GetPixelRowSpan()- Only if possible/allowed by the guideline. See these issues for more information about the blockers!
- We decided to not expose
Memory<T>for now
- Move the core memory management classes out of this repo. They should live in SixLabors.Core so we can integrate them across the whole SixLabors stack. (Migrate memory primitives to SixLabors.Core #619)
JimBobSquarePants, tocsoft, iamcarbon and Unknown6656paolofulgoni