Class CellBuffer
A detached copy of a rectangular block of cells, used by effects that need to remember what a region looked like before they started writing to it.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public sealed class CellBuffer
Remarks
Buffers are rented from and returned to a TextModeEffectPlayer rather than allocated per effect, because effects are started and restarted often and a full-screen region is a few thousand cells. A rented buffer keeps whatever capacity it grew to, so repeated use of the same region size stops allocating entirely.
Cells are copied whole, including the packed atlas and metrics fields that GlyphAtlasCache stamped into them. An effect that only moves or recolors existing content therefore needs no glyph cache at all: it can copy captured cells straight back into the grid.
Properties
Capacity
Gets the allocated capacity in cells, which may exceed CellCount after the buffer has been reused for a smaller region.
Declaration
public int Capacity { get; }
Property Value
| Type | Description |
|---|---|
| int |
CellCount
Gets the number of cells currently held.
Declaration
public int CellCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Columns
Gets the number of columns currently held.
Declaration
public int Columns { get; }
Property Value
| Type | Description |
|---|---|
| int |
Rows
Gets the number of rows currently held.
Declaration
public int Rows { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Blit(CellGrid, int, int)
Copies this buffer back into a grid at the given position, marking the affected rows dirty.
Declaration
public void Blit(CellGrid grid, int row, int column)
Parameters
| Type | Name | Description |
|---|---|---|
| CellGrid | grid | The grid to write into. |
| int | row | Row index the buffer's top edge lands on. |
| int | column | Column index the buffer's left edge lands on. |
Remarks
Rows and columns that fall outside the grid are skipped, so a buffer may be written at a position that only partly overlaps the grid without further bounds checks.
Capture(CellGrid, in CellRect)
Copies a region of a grid into this buffer, resizing it to match.
Declaration
public CellRect Capture(CellGrid grid, in CellRect region)
Parameters
| Type | Name | Description |
|---|---|---|
| CellGrid | grid | The grid to read from. |
| CellRect | region | The block of cells to copy. |
Returns
| Type | Description |
|---|---|
| CellRect | The clamped region that was actually captured. |
Remarks
The region is clamped to the grid first, so the buffer ends up holding only cells that actually exist. Check Rows and Columns afterwards to learn what was captured.
Clear()
Marks the buffer as holding nothing, without releasing its capacity.
Declaration
public void Clear()
GetCell(int, int)
Reads a single cell from the buffer by its position within the captured region.
Declaration
public Cell GetCell(int localRow, int localColumn)
Parameters
| Type | Name | Description |
|---|---|---|
| int | localRow | Row index relative to the buffer's top edge. |
| int | localColumn | Column index relative to the buffer's left edge. |
Returns
| Type | Description |
|---|---|
| Cell | The cell, or a default cell when the coordinate lies outside the buffer. |
Resize(int, int)
Grows the buffer if needed so it can hold a region of the given size, and adopts that size.
Declaration
public void Resize(int rows, int columns)
Parameters
| Type | Name | Description |
|---|---|---|
| int | rows | Number of rows required. |
| int | columns | Number of columns required. |
Remarks
Existing contents are not preserved. Call Capture(CellGrid, in CellRect) after resizing.
SetCell(int, int, in Cell)
Writes a single cell into the buffer by its position within the captured region.
Declaration
public void SetCell(int localRow, int localColumn, in Cell cell)
Parameters
| Type | Name | Description |
|---|---|---|
| int | localRow | Row index relative to the buffer's top edge. |
| int | localColumn | Column index relative to the buffer's left edge. |
| Cell | cell | The cell to store. |
TrimCapacity()
Releases the backing storage so a pathologically large buffer does not stay resident.
Declaration
public void TrimCapacity()