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.
-
void clearTransform()
Record a clear-transform 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 drawLine(Point p1, Point p2, const Paint &p)
Record a line-drawing operation using a Paint.
- Parameters:
p1 – Start point.
p2 – End point.
p – Paint describing style, color, blend, opacity.
-
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 drawPolyline(const Point *pts, i32 count, const Paint &p)
Record a polyline-drawing operation using a Paint.
- Parameters:
pts – Array of vertices.
count – Number of points.
p – Paint describing style, color, blend, opacity.
-
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 drawText(Point pos, std::string_view text, const Paint &p)
Record a text-drawing operation using a Paint.
- Parameters:
pos – Position of the text baseline.
text – UTF-8 text to draw.
p – Paint describing style, color, blend, opacity.
-
void fillCircle(f32 cx, f32 cy, f32 radius, Color c)
Record a fill-circle operation.
- Parameters:
cx – Center X.
cy – Center Y.
radius – Circle radius.
c – Fill color.
-
void fillCircle(f32 cx, f32 cy, f32 radius, const Paint &p)
Record a fill-circle operation using a Paint.
- Parameters:
cx – Center X.
cy – Center Y.
radius – Circle radius.
p – Paint describing style, color, blend, opacity.
-
void fillRect(Rect r, Color c)
Record a fill-rectangle operation.
- Parameters:
r – Rectangle to fill.
c – Fill color.
-
void fillRect(Rect r, const Paint &p)
Record a fill-rectangle operation using a Paint.
- Parameters:
r – Rectangle to fill.
p – Paint describing style, color, blend, opacity.
-
void fillRoundRect(Rect r, f32 rx, f32 ry, Color c)
Record a fill-rounded-rectangle operation.
- Parameters:
r – The rectangle.
rx – Corner radius in X.
ry – Corner radius in Y.
c – Fill color.
-
void fillRoundRect(Rect r, f32 rx, f32 ry, const Paint &p)
Record a fill-rounded-rectangle operation using a Paint.
- Parameters:
r – The rectangle.
rx – Corner radius in X.
ry – Corner radius in Y.
p – Paint describing style, color, blend, opacity.
-
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 setTransform(const Matrix &m)
Record a set-transform operation.
- Parameters:
m – The transformation matrix.
-
void strokeCircle(f32 cx, f32 cy, f32 radius, Color c, f32 width)
Record a stroke-circle operation.
- Parameters:
cx – Center X.
cy – Center Y.
radius – Circle radius.
c – Stroke color.
width – Stroke line width.
-
void strokeCircle(f32 cx, f32 cy, f32 radius, const Paint &p)
Record a stroke-circle operation using a Paint.
- Parameters:
cx – Center X.
cy – Center Y.
radius – Circle radius.
p – Paint describing style, color, blend, opacity.
-
void strokeRect(Rect r, Color c, f32 width)
Record a stroke-rectangle operation.
- Parameters:
r – Rectangle to stroke.
c – Stroke color.
width – Stroke line width.
-
void strokeRect(Rect r, const Paint &p)
Record a stroke-rectangle operation using a Paint.
- Parameters:
r – Rectangle to stroke.
p – Paint describing style, color, blend, opacity.
-
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 Matrix *getMatrix(u32 offset) const
Retrieve a stored matrix by offset.
- Parameters:
offset – Byte offset returned by storeMatrix().
- Returns:
Pointer to the Matrix.
-
const Point *getPoints(u32 offset) const
Retrieve stored points by offset.
- Parameters:
offset – Byte offset returned by storePoints().
- Returns:
Pointer to the first Point.
-
void getRoundRect(u32 offset, Rect &r, f32 &rx, f32 &ry) const
Retrieve stored rounded rectangle data.
- Parameters:
offset – Byte offset returned by storeRoundRect().
r – Output rectangle.
rx – Output corner radius in X.
ry – Output corner radius in Y.
-
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.
-
u32 storeMatrix(const Matrix &m)
Store a matrix in the arena.
- Parameters:
m – The matrix to store.
- Returns:
Byte offset to the stored matrix.
-
u32 storePoints(const Point *pts, i32 count)
Store a points array in the arena.
- Parameters:
pts – Pointer to the points array.
count – Number of points.
- Returns:
Byte offset to the stored points.
-
explicit DrawOpArena(size_t initialCapacity = 4096)