ISampleBufferBase

Description

interface Tinman.Terrain.Buffers.ISampleBufferBase

Base interface for classes that represent value buffers that are organized as flat arrays with a common indexing scheme.

Subclasses provide arrays that store buffer samples. This array can be accessed as follows:

Samples[Offset + y * Stride + x * TupleSize + z] := value

where x and y are the coordinates of the buffer sample and z is the index of the tuple component to access.

Public / Methods

Apply​Transform


public method ApplyTransform → (5)

in : int32

[0..ISampleBufferBase.Width]
X-coordinate of the top-left sample of the region.

in : int32

[0..ISampleBufferBase.Height]
Y-coordinate of the top-left sample of the region.

width in : int32

[0..ISampleBufferBase.Width-x]
Width of the region to transform.

height in : int32

[0..ISampleBufferBase.Height-y]
Height of the region to transform.

transform in : Transform

The 2D transform to apply.

Perform an in-place Transform of the samples in the given buffer region.

For square regions (i.e., same width and height), all Transforms can be applied within the region. For rectangular regions, width and height might get swapped ( Transforms.WillSwapAxes) while the top-left sample of the given region remains in the same place.

If this sample buffer is not big enough to hold the swapped width or height, output samples will be discarded.

This method reads samples from the given input region and writes samples to the transformed output region. No other samples are accessed by this method.

Offset​At

2 overloads


[Pure]
public method OffsetAt1 → (1)

in : int32

[0..ISampleBufferBase.Height-1]
Y-coordinate of the row.

returns → int32

Buffer index of the sample.

Computes the buffer index for the given sample.

The returned buffer index may only be used to access the samples in the specified row (see in).


[Pure]
public method OffsetAt2 → (2)

in : int32

[0..ISampleBufferBase.Width-1]
X-coordinate of sample.

in : int32

[0..ISampleBufferBase.Height-1]
Y-coordinate of sample.

returns → int32

Buffer index of the sample.

Computes the buffer index for the given sample.

Restore


public method Restore → ()

This sample buffer has been taken out of a pool.

Shift


public method Shift → (3)

in : int32

Horizontal shift amount.

in : int32

Vertical shift amount.

callback opt : ICollector<Box2I> = null

Collector for sample buffer regions that have been invalidated by the shift.

Shifts the samples in this buffer by the given amount.

This method allows sample buffers to be used in a toroidal manner (i.e., as a two-dimensional ringbuffer).

Specifying a positive value for in will create space for new samples at the left buffer border, a negative value for in will create space at the right border.

Specifying a positive value for in will create space for new samples at the top buffer border, a negative value for in will create space at the bottom border.

The content of the samples in the additional space at the buffer border is unspecified and must be set by the caller.

Public / Attributes

Height


public attribute Height → (get)

value : int32

[>0]
The height of the buffer, in samples.

The height of the buffer, in samples.

Is​Packed


public attribute IsPacked → (get)

value : bool

true if this buffer is densely packed, false if not.

Returns whether this sample buffer is densely packed.

A packed sample buffer can be indexed with the following scheme:

Samples[(y * Width + x) * TupleSize + 0] := 1st value of sample at (x,y).
Samples[(y * Width + x) * TupleSize + 1] := 2nd value of sample at (x,y).
...
Samples[(y * Width + x) * TupleSize + TupleSize - 1] := last value of sample.

Thus, the samples of a densely packed buffer form a contiguous region in memory.

Is​Pooled


public attribute IsPooled → (get)

value : bool

true if this buffer is currently in a pool, false if not.

Is this sample buffer being held in a pool?

Using a sample buffer that is being held in a pool is an error and indicates incorrect use of IDeletable.Delete.

After calling IDeletable.Delete, a sample buffer is considered to be in a pool and IsPooled will return true.

After taking a sample buffer out of the pool, Restore must be called.

Offset


public attribute Offset → (get)

value : int32

[>=0]
The buffer offset.

Index of the top-left sample in the buffer.

Stride


public attribute Stride → (get)

value : int32

[>0]
The buffer stride, in samples.

Distance between two consecutive rows in the buffer.

Width


public attribute Width → (get)

value : int32

[>0]
The width of the buffer, in samples.

The width of the buffer, in samples.

Extensions

Assert​Not​Pooled


[Assertion]
public static method AssertNotPooled → (1)

source in : string @ Tag

The error source tag.

Asserts that ISampleBufferBase.IsPooled returns true.

Assert​Pooled


[Assertion]
public static method AssertPooled → (1)

source in : string @ Tag

The error source tag.

Asserts that ISampleBufferBase.IsPooled returns false.