Table of Contents

Class SurfacePixelMemoryManager

Namespace
Sdl3Sharp.Video
Assembly
Sdl3Sharp.dll

Manages and represents the pixel memory of a locked Surface

public sealed class SurfacePixelMemoryManager : NativeMemoryManagerBase, IDisposable
Inheritance
SurfacePixelMemoryManager
Implements
Inherited Members

Properties

IsPinned

Gets a value indicating whether the Surface is currently locked (pinned)

public override bool IsPinned { get; }

Property Value

bool

true, if the Surface is currently locked (pinned); otherwise, false (Surface is null in that case)

Length

Gets the number of bytes in the allocated memory region this NativeMemoryManagerBase represents

public override nuint Length { get; }

Property Value

nuint

The number of bytes in the allocated memory region this NativeMemoryManagerBase represents

Memory

Gets a NativeMemory representing the pixel memory of the locked Surface

public override NativeMemory Memory { get; }

Property Value

NativeMemory

A NativeMemory representing the pixel memory of the locked Surface, or Empty if the Surface is not locked

Remarks

The pixel memory data is in the pixel format specified by the Format property of the Surface.

Please keep the Pitch per vertical pixel row in mind when processing the continuous pixel memory.

Pointer

Gets a pointer to the start of the allocated memory region this NativeMemoryManagerBase represents

public override nint Pointer { get; }

Property Value

nint

A pointer to the start of the allocated memory region this NativeMemoryManagerBase represents

Surface

Gets the locked Surface

public Surface? Surface { get; }

Property Value

Surface

The locked Surface, or null if the Surface is not locked

Methods

DecreasePinCounter(ulong)

Decreases the pin counter

protected override ulong DecreasePinCounter(ulong pinCounter)

Parameters

pinCounter ulong

The current pin counter

Returns

ulong

The new pin counter

Remarks

Override this method to implement custom pin counter decreasing step logic. You can even just ignore pinning altogether and always return the given pinCounter.

Notice that custom implementations of this method should ensure that the returned value is less than or equal to the given pinCounter. Also, when implementing this method, remember that the pin counter stepping must work in conjunction with IncreasePinCounter(ulong). Furthermore, there's no underflow preventing logic in the consumers of this method, so custom implementations should ensure that underflow doesn't happen.

Dispose(bool)

Disposes the SurfacePixelMemoryManager, unlocking the associated Surface

protected override void Dispose(bool disposing)

Parameters

disposing bool

A value indicating whether this method is called from Dispose() (true) or from the finalizer (false)

Remarks

Calling this method will unlock the associated Surface, if it's still locked, making its pixel memory inaccessible until it is locked again.

See Also

IncreasePinCounter(ulong)

Increases the pin counter

protected override ulong IncreasePinCounter(ulong pinCounter)

Parameters

pinCounter ulong

The current pin counter

Returns

ulong

The new pin counter

Remarks

Override this method to implement custom pin counter increasing step logic. You can even just ignore pinning altogether and always return the given pinCounter.

Notice that custom implementations of this method should ensure that the returned value is greater than or equal to the given pinCounter. Also, when implementing this method, remember that the pin counter stepping must work in conjunction with DecreasePinCounter(ulong). Furthermore, there's no overflow preventing logic in the consumers of this method, so custom implementations should ensure that overflow doesn't happen.