Recording
-
class Recording
Immutable command buffer containing recorded draw operations.
Created by Recorder::finish(). Operations can be traversed in original order via accept() or in sorted order via dispatch().
Public Functions
Construct a Recording from operations, arena, and images.
- Parameters:
ops – Vector of compact draw operations.
arena – Arena holding variable-length data.
images – Vector of referenced images.
-
void accept(DrawOpVisitor &visitor) const
Traverse operations in original recording order.
- Parameters:
visitor – The visitor to receive each operation.
-
inline const DrawOpArena &arena() const
Get the data arena.
-
void dispatch(DrawOpVisitor &visitor, const class DrawPass &pass) const
Dispatch operations in sorted order defined by a draw pass.
- Parameters:
visitor – The visitor to receive each operation.
pass – The draw pass defining execution order.
-
const Image *getImage(u32 index) const
Get an image by index.
- Parameters:
index – Index into the images list.
- Returns:
Pointer to the Image, or nullptr if out of range.
-
inline const std::vector<CompactDrawOp> &ops() const
Get the list of recorded operations.
-
class Recorder
Records draw operations into a compact command buffer.
Call drawing methods to accumulate operations, then finish() to produce an immutable Recording.
Public Functions
-
void clearClip()
Record a clear-clip operation.
Record an image-drawing operation.
- Parameters:
image – Shared pointer to the image.
x – X position.
y – Y position.
-
void drawLine(Point p1, Point p2, Color c, f32 width)
Record a line-drawing operation.
- Parameters:
p1 – Start point.
p2 – End point.
c – Line color.
width – Line width.
-
void drawPolyline(const Point *pts, i32 count, Color c, f32 width)
Record a polyline-drawing operation.
- Parameters:
pts – Array of vertices.
count – Number of points.
c – Line color.
width – Line width.
-
void drawText(Point p, std::string_view text, Color c)
Record a text-drawing operation.
- Parameters:
p – Position of the text baseline.
text – UTF-8 text to draw.
c – Text color.
-
void fillRect(Rect r, Color c)
Record a fill-rectangle operation.
- Parameters:
r – Rectangle to fill.
c – Fill color.
-
std::unique_ptr<Recording> finish()
Finish recording and produce an immutable Recording.
- Returns:
Unique pointer to the completed Recording.
-
void reset()
Reset the recorder, discarding all accumulated operations.
-
void setClip(Rect r)
Record a set-clip operation.
- Parameters:
r – The clipping rectangle.
-
void clearClip()
-
class DrawOpArena
Arena allocator for variable-length DrawOp data (strings, point arrays).
Public Functions
-
explicit DrawOpArena(size_t initialCapacity = 4096)
Construct an arena with the given initial capacity.
- Parameters:
initialCapacity – Initial byte capacity (default 4096).
-
u32 allocate(size_t bytes)
Allocate raw storage.
- Parameters:
bytes – Number of bytes to allocate.
- Returns:
Byte offset into the arena.
-
const Point *getPoints(u32 offset) const
Retrieve stored points by offset.
- Parameters:
offset – Byte offset returned by storePoints().
- Returns:
Pointer to the first Point.
-
const char *getString(u32 offset) const
Retrieve a stored string by offset.
- Parameters:
offset – Byte offset returned by storeString().
- Returns:
Pointer to the null-terminated string.
-
void reset()
Reset the arena, discarding all stored data.
-
explicit DrawOpArena(size_t initialCapacity = 4096)