ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
reflow_svg_internal.h File Reference

Cross-TU surface for the split minimal-SVG subset (#112). More...

#include <stddef.h>
#include <stdint.h>
#include "ra8_attributes.h"
Include dependency graph for reflow_svg_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  svg_pt_t
 A 2-D point in SVG user space (an x/y pair). More...
struct  svg_utf_t
 A user transform= as a full 2x3 affine matrix. More...
struct  svg_xform_t
 SVG-user-space -> framebuffer-box coordinate transform. More...
struct  svg_stop_t
 One gradient colour stop: an offset in [0,1] and an 0x00RRGGBB colour. More...
struct  svg_grad_t
 A parsed linear/radial gradient in objectBoundingBox units. More...
struct  svg_grads
 Bounded set of gradients scanned from the document before the render. More...

Typedefs

typedef struct svg_grads svg_grads_t
 Forward decl: the document's gradient set (defined after svg_xform_t).

Enumerations

enum  priv_svg_consts_t : uint32_t {
  k_svg_no_paint = 0xFFFFFFFFU ,
  k_svg_def_fill = 0x000000U ,
  k_svg_dec = 10U ,
  k_svg_hex_base = 16U ,
  k_svg_hex_a10 = 10U ,
  k_svg_hex_nib = 4U ,
  k_svg_hex_chan = 8U ,
  k_svg_hex3 = 3U ,
  k_svg_hex6 = 6U ,
  k_svg_viewbox_n = 4U ,
  k_svg_bom0 = 0xEFU ,
  k_svg_bom1 = 0xBBU ,
  k_svg_bom2 = 0xBFU ,
  k_svg_bom_len = 3U ,
  k_svg_poly_max = 64U ,
  k_svg_poly_min = 3U ,
  k_svg_path_args = 7U ,
  k_svg_path_ep = 2U ,
  k_svg_argc_quad = 4U ,
  k_svg_argc_cube = 6U ,
  k_svg_curve_seg = 12U ,
  k_svg_cube_ey = 5U ,
  k_svg_arc_rx = 0U ,
  k_svg_arc_ry = 1U ,
  k_svg_arc_rot = 2U ,
  k_svg_arc_large = 3U ,
  k_svg_arc_sweep = 4U ,
  k_svg_arc_ex = 5U ,
  k_svg_arc_ey = 6U ,
  k_svg_arc_seg_max = 24U ,
  k_svg_g_depth_max = 8U ,
  k_svg_circle_seg = 24U ,
  k_svg_rect_pts = 4U ,
  k_svg_grad_max = 8U ,
  k_svg_grad_stops = 8U ,
  k_svg_grad_id = 32U ,
  k_svg_grad_linear = 0U ,
  k_svg_grad_radial = 1U ,
  k_svg_chan_mask = 0xFFU ,
  k_svg_sh_r = 16U
}
 Parse + colour constants for the SVG subset. More...

Functions

bool priv_ra8_svgp_ws (char c)
 Test whether a character is XML whitespace.
char priv_ra8_svgp_lc (char c)
 ASCII-fold a character to lower case.
bool priv_ra8_svgp_starts_ci (const uint8_t *s, size_t len, size_t at, const char *lit)
 Case-insensitive prefix test of lit at at within s[0..len).
size_t priv_ra8_svgp_find_ci (const uint8_t *s, size_t len, size_t from, const char *lit)
 Find the first case-insensitive occurrence of lit in s[from..len).
int32_t priv_ra8_svgp_num (const uint8_t *s, size_t len, size_t *i)
 Parse the integer part of one SVG number at s[*i]; truncate fractions.
bool priv_ra8_svgp_attr (const uint8_t *s, size_t len, const char *name, size_t *voff, size_t *vlen)
 Find attribute name in tag span s[0..len); return its value slice.
int32_t priv_ra8_svgp_attr_num (const uint8_t *s, size_t len, const char *name, int32_t def)
 Read an SVG attribute as a signed integer, returning def when absent.
uint32_t priv_ra8_svgp_paint (const uint8_t *s, size_t len)
 Parse an SVG paint value ('#rgb'/'#rrggbb'/name/'none') to 0x00RRGGBB.
uint32_t priv_ra8_svgp_attr_paint (const uint8_t *s, size_t len, const char *name, uint32_t def)
 Read an SVG attribute as a paint colour, returning def when absent.
uint32_t priv_ra8_svgp_resolve_fill (const uint8_t *s, size_t len, const svg_xform_t *t, uint32_t def, int32_t *gi)
 Resolve a shape's 'fill': a solid colour, or a gradient index via gi.
float priv_ra8_svgp_numf (const uint8_t *s, size_t len, size_t *i)
 Parse one SVG floating-point number at s[*i], skipping separators.
bool priv_ra8_svgp_has_rot (const svg_xform_t *t)
 Test whether the user transform contains rotation or shear.
void priv_ra8_svgp_map_point (const svg_xform_t *t, int32_t ux, int32_t uy, int32_t *fx, int32_t *fy)
 Map a user-space point through the FULL affine, then viewBox->box.
int32_t priv_ra8_svgp_mx (const svg_xform_t *t, int32_t sx)
 Map a user-space x coordinate to a framebuffer x coordinate.
int32_t priv_ra8_svgp_my (const svg_xform_t *t, int32_t sy)
 Map a user-space y coordinate to a framebuffer y coordinate.
int32_t priv_ra8_svgp_sx (const svg_xform_t *t, int32_t sw)
 Scale a user-space length by the user x scale and the viewBox x ratio.
void priv_ra8_svgp_apply_xform (svg_xform_t *t, const uint8_t *tag, size_t tlen)
 Compose the 'transform=' attribute from tag onto t's user affine.
void priv_ra8_svgp_fill_poly (const int32_t *xs, const int32_t *ys, int32_t n, uint32_t color)
 Even-odd scanline fill of polygon (xs,ys)[0..n) with a solid colour.
void priv_ra8_svgp_fill_poly_grad (const int32_t *xs, const int32_t *ys, int32_t n, const svg_grad_t *g)
 Per-pixel gradient scanline fill of polygon (xs,ys)[0..n).
int32_t priv_match_grad (const svg_grads_t *grads, const uint8_t *val, size_t vlen)
 Match a 'url(#id)' paint value to a gradient index in the document set.
void priv_ra8_svgp_flatten_arc (const svg_xform_t *t, svg_pt_t p0, const int32_t *args, svg_pt_t p_end, int32_t *xs, int32_t *ys, int32_t *n)
 Flatten an SVG elliptical arc into the polygon vertex array.
void priv_ra8_svgp_draw_rect (const uint8_t *s, size_t len, const svg_xform_t *t)
 Draw one SVG 'rect' element using its fill colour or gradient.
void priv_ra8_svgp_draw_circle (const uint8_t *s, size_t len, const svg_xform_t *t)
 Draw one SVG 'circle' element using its fill colour or gradient.
void priv_ra8_svgp_draw_line (const uint8_t *s, size_t len, const svg_xform_t *t)
 Draw one SVG 'line' element using its stroke colour.
void priv_ra8_svgp_draw_polygon (const uint8_t *s, size_t len, const svg_xform_t *t)
 Draw one SVG 'polygon' element as a filled polygon.
void priv_ra8_svgp_draw_polyline (const uint8_t *s, size_t len, const svg_xform_t *t)
 Draw one SVG 'polyline' element as connected stroke line segments.
void priv_ra8_svgp_draw_path (const uint8_t *s, size_t len, const svg_xform_t *t)
 Draw one SVG 'path' element as a filled polygon.

Detailed Description

Cross-TU surface for the split minimal-SVG subset (#112).

The SVG subset implementation is split across five translation units that share one set of constants, geometry types, and pure leaf-level helpers:

  • reflow_svg.c – scan / attribute / colour-parsing core.
  • reflow_svg_xform.c – viewBox + 2x3 affine transform= coordinate map.
  • reflow_svg_shape.c – rect / circle / line / polygon / polyline draw, the scanline polygon fill, gradient evaluation, and the elliptical-arc flatten.
  • reflow_svg_path.c – the <path> d mini-language (Bezier curves).
  • reflow_svg_doc.c – the document walk, gradient definitions, and the public ra8_svg_render / ra8_svg_size API. Only the constants, geometry types, and helpers referenced by more than one of those TUs are declared here; every TU-private helper stays static in its defining file. There is no MMIO and no heap: the only side effect of the whole module is drawing through the bound ra8_gfx framebuffer.

[Ring 4 / Reflow] {World: NS}

Since
0.1.0

Definition in file reflow_svg_internal.h.

Typedef Documentation

◆ svg_grads_t

typedef struct svg_grads svg_grads_t

Forward decl: the document's gradient set (defined after svg_xform_t).

Definition at line 112 of file reflow_svg_internal.h.

Enumeration Type Documentation

◆ priv_svg_consts_t

enum priv_svg_consts_t : uint32_t

Parse + colour constants for the SVG subset.

Enumerator
k_svg_no_paint 

none / absent paint sentinel.

k_svg_def_fill 

SVG default fill is black.

k_svg_dec 

Decimal base.

k_svg_hex_base 

Hex base / "not a hex digit".

k_svg_hex_a10 

Value of hex 'a'/'A'.

k_svg_hex_nib 

Bits per hex nibble.

k_svg_hex_chan 

Bits per colour channel.

k_svg_hex3 

#rgb digit count.

k_svg_hex6 

#rrggbb digit count.

k_svg_viewbox_n 

viewBox number count.

k_svg_bom0 

UTF-8 BOM byte 0.

k_svg_bom1 

UTF-8 BOM byte 1.

k_svg_bom2 

UTF-8 BOM byte 2.

k_svg_bom_len 

UTF-8 BOM length.

k_svg_poly_max 

Max points / scanline crossings.

k_svg_poly_min 

Min points for a fillable polygon.

k_svg_path_args 

Max args of a path command (A).

k_svg_path_ep 

Endpoint pair size (x, y); M/L/T.

k_svg_argc_quad 

Arg count of S / Q.

k_svg_argc_cube 

Arg count of C.

k_svg_curve_seg 

Segments per cubic-Bezier flatten.

k_svg_cube_ey 

C endpoint-y argument index.

k_svg_arc_rx 

A arg index: semi-axis X.

k_svg_arc_ry 

A arg index: semi-axis Y.

k_svg_arc_rot 

A arg index: x-axis rotation.

k_svg_arc_large 

A arg index: large-arc flag.

k_svg_arc_sweep 

A arg index: sweep flag.

k_svg_arc_ex 

A arg index: endpoint X.

k_svg_arc_ey 

A arg index: endpoint Y.

k_svg_arc_seg_max 

Max segments per arc flatten.

k_svg_g_depth_max 

Max nested <g> transform depth.

k_svg_circle_seg 

N-gon segments for a transformed circle.

k_svg_rect_pts 

Corner count of a rectangle.

k_svg_grad_max 

Max gradients defined per document.

k_svg_grad_stops 

Max colour stops per gradient.

k_svg_grad_id 

Max gradient id length, bytes.

k_svg_grad_linear 

<linearGradient> kind.

k_svg_grad_radial 

<radialGradient> kind.

k_svg_chan_mask 

One 8-bit RGB channel mask.

k_svg_sh_r 

Red shift within 0x00RRGGBB.

Definition at line 40 of file reflow_svg_internal.h.

Function Documentation

◆ priv_match_grad()

int32_t priv_match_grad ( const svg_grads_t * grads,
const uint8_t * val,
size_t vlen )

Match a 'url(#id)' paint value to a gradient index in the document set.

Verifies that val begins with "url(#" via priv_ra8_svgp_starts_ci, extracts the id substring between '#' and ')', and linear-searches grads->g[0..n) comparing each gradient's id byte by byte. Returns -1 immediately when grads is NULL or the value is not a url() reference. Defined in reflow_svg.c. TU-external for MC/DC test access: the sole production caller invokes it only with a bound gradient set and a value that already passed the identical url(#) prefix check, so the guard's two conditions are reachable independently only through a direct test call.

Parameters
[in]gradsGradient set to search; may be NULL (returns -1).
[in]valByte span holding the raw attribute value; must not be NULL.
[in]vlenNumber of valid bytes in val.
Returns
int32_t Index into grads->g, or -1 on no match.
Return values
0..grads->n-1The gradient whose id matches the url(#id) reference.
-1grads is NULL, val is not "url(#...)", or no id match.
Precondition
val is a valid pointer to at least vlen bytes.
When grads is non-NULL, grads->n <= k_svg_grad_max.
Postcondition
val and grads are not modified.
The return value is always in [-1, grads->n-1].
Note
Test-access only. Not thread-safe in isolation; callers are single-threaded during SVG render.
MC/DC:
Decision: (grads == nullptr) || !priv_ra8_svgp_starts_ci(val, vlen, 0U, "url(#") (2 conditions); N+1 = 3 vectors:
  • V1: grads set, val "url(#g)" -> C1 F, C2 F -> match (control).
  • V2: grads NULL, val "url(#g)" -> C1 T -> -1 (varies grads).
  • V3: grads set, val "solid" -> C1 F, C2 T -> -1 (varies prefix).
Since
0.1.0

Match a 'url(#id)' paint value to a gradient index in the document set.

Definition at line 665 of file reflow_svg.c.

References svg_grads::g, svg_grad_t::id, svg_grads::n, priv_ra8_svgp_starts_ci(), and strlen().

Referenced by priv_ra8_svgp_resolve_fill().

◆ priv_ra8_svgp_apply_xform()

void priv_ra8_svgp_apply_xform ( svg_xform_t * t,
const uint8_t * tag,
size_t tlen )

Compose the 'transform=' attribute from tag onto t's user affine.

Looks up "transform", parses it, and composes it over the current user affine in t. Defined in reflow_svg_xform.c.

Parameters
[in,out]tTransform whose user affine is updated in place; must not be NULL.
[in]tagByte span of the element tag to search; must not be NULL.
[in]tlenTotal valid bytes in tag.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
tag is a valid pointer to at least tlen bytes.
Postcondition
When a 'transform=' attribute is found, t->ua .. t->uf reflect the newly composed affine.
When no 'transform=' attribute is found, t is unchanged.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Looks up the "transform" attribute in tag[0..tlen) using priv_ra8_svgp_attr. If absent, returns without modification. If found, parses the value via internal_parse_xform and composes the result over the current user affine in t using internal_utf_compose, then writes the composed components back to t->ua .. t->uf. The viewBox and box fields of t are not touched.

Parameters
[in,out]tTransform whose user affine is updated in place; must not be NULL.
[in]tagByte span of the element tag to search; must not be NULL.
[in]tlenTotal valid bytes in tag.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
tag is a valid pointer to at least tlen bytes.
Postcondition
When a 'transform=' attribute is found, t->ua .. t->uf reflect the newly composed affine.
When no 'transform=' attribute is found, t is unchanged.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 785 of file reflow_svg_xform.c.

References svg_utf_t::a, svg_utf_t::b, svg_utf_t::c, svg_utf_t::d, svg_utf_t::e, svg_utf_t::f, internal_parse_xform(), internal_utf_compose(), priv_ra8_svgp_attr(), svg_xform_t::ua, svg_xform_t::ub, svg_xform_t::uc, svg_xform_t::ud, svg_xform_t::ue, and svg_xform_t::uf.

Referenced by internal_dispatch_shape(), and internal_group_open().

◆ priv_ra8_svgp_attr()

bool priv_ra8_svgp_attr ( const uint8_t * s,
size_t len,
const char * name,
size_t * voff,
size_t * vlen )

Find attribute name in tag span s[0..len); return its value slice.

Locates the word-boundary-delimited name, then the quoted value; sets *voff / *vlen to the value content. Defined in reflow_svg.c.

Parameters
[in]sByte buffer containing the tag text; must not be NULL.
[in]lenTotal valid bytes in s.
[in]nameNUL-terminated ASCII attribute name; must not be NULL.
[out]voffSet to the byte offset of the first value character when found.
[out]vlenSet to the byte length of the value when found.
Returns
bool Whether the attribute was found and parsed.
Return values
trueAttribute name found; *voff and *vlen are valid.
falseAttribute not found, missing '=', or missing opening quote.
Precondition
s is a valid pointer to at least len bytes.
voff and vlen are valid non-NULL output pointers.
Postcondition
On true: *voff < len and *voff + *vlen <= len.
On false: *voff and *vlen are indeterminate.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Scans the tag byte span for the first occurrence of name that passes the word-boundary check via internal_attr_at. Once located, the scanner advances past the '=' separator and any surrounding whitespace to find the opening quote character ('"' or "'"). The matching closing quote is then located and the slice [*voff, *voff + *vlen) is set to the attribute value content between the two quote characters. Returns false if the name is not found, no '=' follows, or no opening quote is present.

Parameters
[in]sByte buffer containing the tag text; must not be NULL.
[in]lenTotal valid bytes in s.
[in]nameNUL-terminated ASCII attribute name to find; must not be NULL.
[out]voffSet to the byte offset of the first value character when found.
[out]vlenSet to the byte length of the value when found.
Returns
bool Whether the attribute was found and parsed.
Return values
trueAttribute name found; *voff and *vlen are valid.
falseAttribute not found, missing '=', or missing opening quote.
Precondition
s is a valid pointer to at least len bytes.
voff and vlen are valid non-NULL output pointers.
Postcondition
On true: *voff < len and *voff + *vlen <= len.
On false: *voff and *vlen are indeterminate and must not be used.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 364 of file reflow_svg.c.

References internal_attr_at(), priv_ra8_svgp_ws(), and strlen().

Referenced by internal_attr_numf(), internal_copy_attr_id(), internal_read_viewbox(), internal_stop_color(), internal_stop_offset(), priv_ra8_svgp_apply_xform(), priv_ra8_svgp_attr_num(), priv_ra8_svgp_attr_paint(), priv_ra8_svgp_draw_path(), priv_ra8_svgp_draw_polygon(), priv_ra8_svgp_draw_polyline(), priv_ra8_svgp_resolve_fill(), ra8_svg_image_href(), and ra8_svg_size().

◆ priv_ra8_svgp_attr_num()

int32_t priv_ra8_svgp_attr_num ( const uint8_t * s,
size_t len,
const char * name,
int32_t def )

Read an SVG attribute as a signed integer, returning def when absent.

Locates the value via priv_ra8_svgp_attr and parses it via priv_ra8_svgp_num. Defined in reflow_svg.c.

Parameters
[in]sByte buffer containing the SVG tag text; must not be NULL.
[in]lenTotal valid bytes in s.
[in]nameNUL-terminated ASCII attribute name; must not be NULL.
[in]defValue to return when the attribute is absent.
Returns
int32_t The parsed integer value, or def when absent.
Return values
defAttribute name was not found in s.
nThe signed integer parsed from the attribute value.
Precondition
s is a valid pointer to at least len bytes.
name is a valid NUL-terminated ASCII string.
Postcondition
s and name are not modified.
The return value equals def when the attribute is absent.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Read an SVG attribute as a signed integer, returning def when absent.

Calls priv_ra8_svgp_attr to locate the attribute value slice, then forwards that slice to priv_ra8_svgp_num starting at offset zero. If the attribute is absent, returns def without modifying any output. Fractional parts of the attribute value are truncated by priv_ra8_svgp_num. Useful for reading integer-valued SVG geometry attributes such as x, y, width, and height.

Parameters
[in]sByte buffer containing the SVG tag text; must not be NULL.
[in]lenTotal valid bytes in s.
[in]nameNUL-terminated ASCII attribute name; must not be NULL.
[in]defValue to return when the attribute is absent.
Returns
int32_t The parsed integer value, or def when the attribute is absent.
Return values
defAttribute name was not found in s.
nThe signed integer parsed from the attribute value.
Precondition
s is a valid pointer to at least len bytes.
name is a valid NUL-terminated ASCII string.
Postcondition
s and name are not modified.
The return value equals def when priv_ra8_svgp_attr returns false.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 424 of file reflow_svg.c.

References priv_ra8_svgp_attr(), and priv_ra8_svgp_num().

Referenced by internal_read_viewbox(), priv_ra8_svgp_draw_circle(), priv_ra8_svgp_draw_line(), priv_ra8_svgp_draw_rect(), and ra8_svg_size().

◆ priv_ra8_svgp_attr_paint()

uint32_t priv_ra8_svgp_attr_paint ( const uint8_t * s,
size_t len,
const char * name,
uint32_t def )

Read an SVG attribute as a paint colour, returning def when absent.

Locates the value via priv_ra8_svgp_attr and parses it via priv_ra8_svgp_paint. Defined in reflow_svg.c.

Parameters
[in]sByte buffer containing the SVG tag text; must not be NULL.
[in]lenTotal valid bytes in s.
[in]nameNUL-terminated ASCII attribute name; must not be NULL.
[in]defDefault paint value returned when the attribute is absent.
Returns
uint32_t The parsed paint colour, or def when absent.
Return values
defAttribute name was not found in s.
0x000000..0xFFFFFFSuccessfully parsed solid paint colour.
(uint32_t)k_svg_no_paintAttribute present but parses to no-paint.
Precondition
s is a valid pointer to at least len bytes.
name is a valid NUL-terminated ASCII string.
Postcondition
s and name are not modified.
The return value equals def when the attribute is absent.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Read an SVG attribute as a paint colour, returning def when absent.

Calls priv_ra8_svgp_attr to locate the attribute value slice, then forwards that slice to priv_ra8_svgp_paint. If the attribute is absent, returns def unchanged. Useful for reading 'fill' and 'stroke' attributes where a sentinel of k_svg_no_paint means the shape uses no paint for that role.

Parameters
[in]sByte buffer containing the SVG tag text; must not be NULL.
[in]lenTotal valid bytes in s.
[in]nameNUL-terminated ASCII attribute name; must not be NULL.
[in]defDefault paint value returned when the attribute is absent.
Returns
uint32_t The parsed paint colour, or def when the attribute is absent.
Return values
defAttribute name was not found in s.
0x000000..0xFFFFFFSuccessfully parsed solid paint colour.
(uint32_t)k_svg_no_paintAttribute present but parses to no-paint.
Precondition
s is a valid pointer to at least len bytes.
name is a valid NUL-terminated ASCII string.
Postcondition
s and name are not modified.
The return value equals def when the attribute is absent.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 654 of file reflow_svg.c.

References priv_ra8_svgp_attr(), and priv_ra8_svgp_paint().

Referenced by priv_ra8_svgp_draw_line(), and priv_ra8_svgp_draw_polyline().

◆ priv_ra8_svgp_draw_circle()

void priv_ra8_svgp_draw_circle ( const uint8_t * s,
size_t len,
const svg_xform_t * t )

Draw one SVG 'circle' element using its fill colour or gradient.

Axis-aligned solid circles use the ra8_gfx_circle fast-path; rotated circles are approximated by an N-gon and scanline-filled. Defined in reflow_svg_shape.c.

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s (the tag span length).
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
All pixels inside the circle boundary are painted with the fill colour.
No pixels outside the circle boundary are modified.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Reads 'cx', 'cy', and 'r' attributes from the tag span s[0..len). Axis-aligned solid circles use the ra8_gfx_circle fast-path; under a rotating/shearing transform the circle is approximated by a k_svg_circle_seg N-gon whose vertices are mapped through the full affine, then scanline-filled by priv_ra8_svgp_fill_poly or priv_ra8_svgp_fill_poly_grad. Returns without drawing when both gi < 0 and fill == k_svg_no_paint.

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s (the tag span length).
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
All pixels inside the circle boundary are painted with the fill colour.
No pixels outside the circle boundary are modified.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 119 of file reflow_svg_shape.c.

References svg_grads::g, svg_xform_t::grads, k_svg_circle_seg, k_svg_def_fill, k_svg_no_paint, priv_ra8_svgp_attr_num(), priv_ra8_svgp_fill_poly(), priv_ra8_svgp_fill_poly_grad(), priv_ra8_svgp_has_rot(), priv_ra8_svgp_map_point(), priv_ra8_svgp_mx(), priv_ra8_svgp_my(), priv_ra8_svgp_resolve_fill(), priv_ra8_svgp_sx(), ra8_gfx_circle(), and s_svg_2pi.

Referenced by internal_dispatch_shape().

◆ priv_ra8_svgp_draw_line()

void priv_ra8_svgp_draw_line ( const uint8_t * s,
size_t len,
const svg_xform_t * t )

Draw one SVG 'line' element using its stroke colour.

Maps both endpoints through the affine and draws with ra8_gfx_line; 'fill' is ignored for lines. Defined in reflow_svg_shape.c.

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s (the tag span length).
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
The line from (x1,y1) to (x2,y2) is drawn in the stroke colour.
No drawing occurs when the stroke colour is k_svg_no_paint.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Reads 'stroke' paint, 'x1', 'y1', 'x2', and 'y2' attributes from the tag span s[0..len). Both endpoints are mapped through the full affine via priv_ra8_svgp_map_point and the result is forwarded to ra8_gfx_line. Returns without drawing when 'stroke' is absent or parses to k_svg_no_paint. Note: 'fill' is ignored for 'line' elements (SVG specification).

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s (the tag span length).
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
The line from (x1,y1) to (x2,y2) is drawn in the stroke colour.
No drawing occurs when the stroke colour is k_svg_no_paint.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 177 of file reflow_svg_shape.c.

References k_svg_no_paint, priv_ra8_svgp_attr_num(), priv_ra8_svgp_attr_paint(), priv_ra8_svgp_map_point(), and ra8_gfx_line().

Referenced by internal_dispatch_shape().

◆ priv_ra8_svgp_draw_path()

void priv_ra8_svgp_draw_path ( const uint8_t * s,
size_t len,
const svg_xform_t * t )

Draw one SVG 'path' element as a filled polygon.

Parses the 'd' mini-language into framebuffer vertices and fills them (solid or gradient). Defined in reflow_svg_path.c.

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s.
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
All pixels inside the path's filled boundary are painted with the fill colour.
No drawing occurs when fill is absent or the 'd' attribute is missing.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Resolves the fill (solid or gradient via priv_ra8_svgp_resolve_fill), reads the 'd' attribute, parses it into framebuffer-space vertices via internal_parse_path, and fills the resulting polygon with priv_ra8_svgp_fill_poly or priv_ra8_svgp_fill_poly_grad. Returns without drawing when fill is absent/none or the 'd' attribute is missing.

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s.
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
All pixels inside the path's filled boundary are painted with the fill colour.
No drawing occurs when fill is absent or the 'd' attribute is missing.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 753 of file reflow_svg_path.c.

References svg_grads::g, svg_xform_t::grads, internal_parse_path(), k_svg_def_fill, k_svg_no_paint, k_svg_poly_max, priv_ra8_svgp_attr(), priv_ra8_svgp_fill_poly(), priv_ra8_svgp_fill_poly_grad(), and priv_ra8_svgp_resolve_fill().

Referenced by internal_dispatch_shape().

◆ priv_ra8_svgp_draw_polygon()

void priv_ra8_svgp_draw_polygon ( const uint8_t * s,
size_t len,
const svg_xform_t * t )

Draw one SVG 'polygon' element as a filled polygon.

Parses 'points', maps vertices, and fills (solid or gradient). Defined in reflow_svg_shape.c.

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s.
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
All pixels inside the polygon boundary are painted with the fill colour.
No drawing occurs when fill is absent or 'points' is missing.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Resolves the fill (solid or gradient), reads the 'points' attribute, parses vertices into framebuffer space via internal_parse_points, and fills the resulting polygon with priv_ra8_svgp_fill_poly or priv_ra8_svgp_fill_poly_grad. Returns without drawing when the fill is absent/none or the 'points' attribute is not present.

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s.
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
All pixels inside the polygon boundary are painted with the fill colour.
No drawing occurs when fill is absent or 'points' is missing.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 601 of file reflow_svg_shape.c.

References svg_grads::g, svg_xform_t::grads, internal_parse_points(), k_svg_def_fill, k_svg_no_paint, k_svg_poly_max, priv_ra8_svgp_attr(), priv_ra8_svgp_fill_poly(), priv_ra8_svgp_fill_poly_grad(), and priv_ra8_svgp_resolve_fill().

Referenced by internal_dispatch_shape().

◆ priv_ra8_svgp_draw_polyline()

void priv_ra8_svgp_draw_polyline ( const uint8_t * s,
size_t len,
const svg_xform_t * t )

Draw one SVG 'polyline' element as connected stroke line segments.

Parses 'points', maps vertices, and connects them with ra8_gfx_line. Defined in reflow_svg_shape.c.

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s.
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
All (n-1) line segments between adjacent vertices are drawn in the stroke colour.
No drawing occurs when stroke is absent or 'points' is missing.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Reads the 'stroke' paint and the 'points' attribute. Parses vertex pairs into framebuffer space via internal_parse_points and connects adjacent vertices with ra8_gfx_line. Returns without drawing when the stroke colour is absent/none or the 'points' attribute is not present.

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s.
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
All (n-1) line segments between adjacent vertices are drawn in the stroke colour.
No drawing occurs when stroke is absent or 'points' is missing.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 644 of file reflow_svg_shape.c.

References internal_parse_points(), k_svg_no_paint, k_svg_poly_max, priv_ra8_svgp_attr(), priv_ra8_svgp_attr_paint(), and ra8_gfx_line().

Referenced by internal_dispatch_shape().

◆ priv_ra8_svgp_draw_rect()

void priv_ra8_svgp_draw_rect ( const uint8_t * s,
size_t len,
const svg_xform_t * t )

Draw one SVG 'rect' element using its fill colour or gradient.

Axis-aligned solid rects use the ra8_gfx_rect fast-path; rotated rects are scanline-filled. Defined in reflow_svg_shape.c.

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s (the tag span length).
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
All pixels inside the rect boundary are painted with the fill colour.
No pixels outside the rect boundary are modified.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Reads 'x', 'y', 'width', and 'height' attributes from the tag span s[0..len). Axis-aligned solid rects use the ra8_gfx_rect fast-path; under a rotating/shearing transform the 4 corners are mapped through the full affine via priv_ra8_svgp_map_point and the resulting quad is scanline-filled by priv_ra8_svgp_fill_poly or priv_ra8_svgp_fill_poly_grad. Returns without drawing when both gi < 0 and fill == k_svg_no_paint.

Parameters
[in]sByte span of the element tag; must not be NULL.
[in]lenTotal valid bytes in s (the tag span length).
[in]tActive coordinate transform; must not be NULL.
Precondition
s is a valid pointer to at least len bytes.
t is a valid non-NULL pointer to an initialised svg_xform_t.
Postcondition
All pixels inside the rect boundary are painted with the fill colour.
No pixels outside the rect boundary are modified.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 61 of file reflow_svg_shape.c.

References svg_grads::g, svg_xform_t::grads, k_svg_def_fill, k_svg_no_paint, k_svg_rect_pts, priv_ra8_svgp_attr_num(), priv_ra8_svgp_fill_poly(), priv_ra8_svgp_fill_poly_grad(), priv_ra8_svgp_has_rot(), priv_ra8_svgp_map_point(), priv_ra8_svgp_mx(), priv_ra8_svgp_my(), priv_ra8_svgp_resolve_fill(), priv_ra8_svgp_sx(), and ra8_gfx_rect().

Referenced by internal_dispatch_shape().

◆ priv_ra8_svgp_fill_poly()

void priv_ra8_svgp_fill_poly ( const int32_t * xs,
const int32_t * ys,
int32_t n,
uint32_t color )

Even-odd scanline fill of polygon (xs,ys)[0..n) with a solid colour.

Computes the bounding Y range and fills spans via ra8_gfx. Defined in reflow_svg_shape.c.

Parameters
[in]xsArray of n framebuffer X coordinates; must not be NULL.
[in]ysArray of n framebuffer Y coordinates; must not be NULL.
[in]nNumber of polygon vertices.
[in]colorFill colour in 0x00RRGGBB format.
Precondition
xs and ys are valid pointers to at least n elements.
n <= k_svg_poly_max.
Postcondition
All pixels inside the even-odd polygon boundary are painted color.
No drawing occurs when n < k_svg_poly_min.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Computes the bounding Y range of the polygon, then for each scanline Y in [ymin, ymax] calls internal_scanline_x to collect intercepts, sorts them via internal_sort_i32, and fills pairs of spans with ra8_gfx_line. Returns immediately for polygons with fewer than k_svg_poly_min vertices.

Parameters
[in]xsArray of n framebuffer X coordinates; must not be NULL.
[in]ysArray of n framebuffer Y coordinates; must not be NULL.
[in]nNumber of polygon vertices.
[in]colorFill colour in 0x00RRGGBB format.
Precondition
xs and ys are valid pointers to at least n elements.
n <= k_svg_poly_max.
Postcondition
All pixels inside the even-odd polygon boundary are painted color.
No drawing occurs when n < k_svg_poly_min.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 371 of file reflow_svg_shape.c.

References internal_scanline_x(), internal_sort_i32(), k_svg_poly_max, k_svg_poly_min, and ra8_gfx_line().

Referenced by priv_ra8_svgp_draw_circle(), priv_ra8_svgp_draw_path(), priv_ra8_svgp_draw_polygon(), and priv_ra8_svgp_draw_rect().

◆ priv_ra8_svgp_fill_poly_grad()

void priv_ra8_svgp_fill_poly_grad ( const int32_t * xs,
const int32_t * ys,
int32_t n,
const svg_grad_t * g )

Per-pixel gradient scanline fill of polygon (xs,ys)[0..n).

Evaluates g at each pixel's bounding-box-relative position and writes it with ra8_gfx_pixel. Defined in reflow_svg_shape.c.

Parameters
[in]xsArray of n framebuffer X coordinates; must not be NULL.
[in]ysArray of n framebuffer Y coordinates; must not be NULL.
[in]nNumber of polygon vertices.
[in]gGradient descriptor to evaluate per pixel; must not be NULL.
Precondition
xs and ys are valid pointers to at least n elements.
g is a valid non-NULL pointer with g->nstops >= 1.
Postcondition
All pixels inside the even-odd polygon boundary are painted with the gradient colour evaluated at their bounding-box-relative position.
No drawing occurs when n < k_svg_poly_min.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Computes the bounding box of the polygon, then for each scanline Y in [ymin, ymax] collects edge intercepts via internal_scanline_x and sorts them. For each filled span, iterates over pixels and evaluates the gradient at the bounding-box-relative position ((x-xmin)/bw, (y-ymin)/bh) via internal_grad_eval. Each pixel is written individually with ra8_gfx_pixel. Returns immediately when n < k_svg_poly_min.

Parameters
[in]xsArray of n framebuffer X coordinates; must not be NULL.
[in]ysArray of n framebuffer Y coordinates; must not be NULL.
[in]nNumber of polygon vertices.
[in]gGradient descriptor to evaluate per pixel; must not be NULL.
Precondition
xs and ys are valid pointers to at least n elements.
g is a valid non-NULL pointer with g->nstops >= 1.
Postcondition
All pixels inside the even-odd polygon boundary are painted with the gradient colour evaluated at their bounding-box-relative position.
No drawing occurs when n < k_svg_poly_min.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 541 of file reflow_svg_shape.c.

References internal_grad_eval(), internal_scanline_x(), internal_sort_i32(), k_svg_poly_max, k_svg_poly_min, and ra8_gfx_pixel().

Referenced by priv_ra8_svgp_draw_circle(), priv_ra8_svgp_draw_path(), priv_ra8_svgp_draw_polygon(), and priv_ra8_svgp_draw_rect().

◆ priv_ra8_svgp_find_ci()

size_t priv_ra8_svgp_find_ci ( const uint8_t * s,
size_t len,
size_t from,
const char * lit )

Find the first case-insensitive occurrence of lit in s[from..len).

Scans for the first position where priv_ra8_svgp_starts_ci matches; an empty lit returns len. Defined in reflow_svg.c.

Parameters
[in]sByte buffer to search; must not be NULL.
[in]lenTotal valid bytes in s.
[in]fromStarting byte offset; must be <= len.
[in]litNUL-terminated ASCII literal to find; must not be NULL.
Returns
size_t Byte offset of the first match, or len if not found.
Return values
[from..len)Offset of the first case-insensitive occurrence.
lenlit was not found, or lit is empty.
Precondition
s is a valid pointer to at least len bytes.
from is <= len.
Postcondition
s and lit are not modified.
The return value is always in the closed range [from, len].
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Find the first case-insensitive occurrence of lit in s[from..len).

Scans s[from .. len) for the first position where priv_ra8_svgp_starts_ci returns true for lit. If lit is empty (zero-length), returns len immediately as a defined sentinel rather than matching at every position. The inner loop advances the position by one byte per iteration; the loop bound is len - strlen(lit) + 1, so the scan is O(len * len(lit)).

Parameters
[in]sByte buffer to search; must not be NULL.
[in]lenTotal valid bytes in s.
[in]fromStarting byte offset; must be <= len.
[in]litNUL-terminated ASCII literal to find; must not be NULL.
Returns
size_t Byte offset of the first match, or len if not found.
Return values
[from..len)Offset of the first case-insensitive occurrence of lit.
lenlit was not found, or lit is empty.
Precondition
s is a valid pointer to at least len bytes.
from is <= len.
Postcondition
s and lit are not modified.
The return value is always in the closed range [from, len].
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 166 of file reflow_svg.c.

References priv_ra8_svgp_starts_ci(), and strlen().

Referenced by internal_parse_stops(), internal_scan_grads(), and internal_tag_span().

◆ priv_ra8_svgp_flatten_arc()

void priv_ra8_svgp_flatten_arc ( const svg_xform_t * t,
svg_pt_t p0,
const int32_t * args,
svg_pt_t p_end,
int32_t * xs,
int32_t * ys,
int32_t * n )

Flatten an SVG elliptical arc into the polygon vertex array.

Converts the endpoint-parametrised arc to centre form and samples it, appending mapped framebuffer points; appends a line-to on a degenerate arc. Defined in reflow_svg_shape.c.

Parameters
[in]tActive coordinate transform; must not be NULL.
[in]p0Arc start point (current path position, user space).
[in]argsArc argument array indexed by k_svg_arc_* constants; must not be NULL.
[in]p_endArc end point (absolute, user space).
[out]xsVertex X array of at least k_svg_poly_max elements; must not be NULL.
[out]ysVertex Y array of at least k_svg_poly_max elements; must not be NULL.
[in,out]nCurrent vertex count; updated by this function.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
args has at least k_svg_path_args (7) valid int32_t entries.
Postcondition
*n is increased by the number of arc sample points appended.
*n <= k_svg_poly_max on exit.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Converts the endpoint-parametrised arc (P0 to p_end, with radii, rotation, and flags from args) to centre form via internal_arc_center. When the arc is degenerate (ok==false), appends a single line-to p_end. Otherwise samples the arc at internal_arc_segs(a.dt) parameter values using trigonometry (the ellipse equation in the rotated frame) and appends each mapped framebuffer point. Bounded by k_svg_poly_max.

Parameters
[in]tActive coordinate transform; must not be NULL.
[in]p0Arc start point (current path position, user space).
[in]argsArc argument array indexed by svg_arc_* constants; must not be NULL.
[in]p_endArc end point (absolute, user space).
[out]xsVertex X array of at least k_svg_poly_max elements; must not be NULL.
[out]ysVertex Y array of at least k_svg_poly_max elements; must not be NULL.
[in,out]nCurrent vertex count; updated by this function.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
args has at least k_svg_path_args (7) valid int32_t entries.
Postcondition
*n is increased by the number of arc sample points appended.
*n <= k_svg_poly_max on exit.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 917 of file reflow_svg_shape.c.

References svg_arc_t::cos_phi, svg_arc_t::cx, svg_arc_t::cy, svg_arc_t::dt, internal_arc_center(), internal_arc_segs(), k_svg_arc_large, k_svg_arc_rot, k_svg_arc_rx, k_svg_arc_ry, k_svg_arc_sweep, k_svg_poly_max, svg_arc_t::ok, priv_ra8_svgp_map_point(), svg_arc_t::rx, svg_arc_t::ry, svg_arc_t::sin_phi, svg_arc_t::t1, svg_pt_t::x, and svg_pt_t::y.

Referenced by internal_path_curve().

◆ priv_ra8_svgp_has_rot()

bool priv_ra8_svgp_has_rot ( const svg_xform_t * t)

Test whether the user transform contains rotation or shear.

True when t->ub or t->uc is non-zero. Defined in reflow_svg_xform.c.

Parameters
[in]tActive coordinate transform; must not be NULL.
Returns
bool Whether the user transform has a rotation or shear component.
Return values
truet->ub != 0.0F or t->uc != 0.0F.
falseBoth t->ub and t->uc are 0.0F (axis-aligned).
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
t->ub and t->uc hold the shear terms of the current affine.
Postcondition
t is not modified.
The return value is deterministic given the same t.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Checks whether t->ub or t->uc is non-zero. When either is non-zero, the axis-aligned fast-path primitives (ra8_gfx_rect, ra8_gfx_circle) cannot represent the shape correctly and callers must fall back to the polygon path via priv_ra8_svgp_map_point applied to each vertex.

Parameters
[in]tActive coordinate transform; must not be NULL.
Returns
bool Whether the user transform has a rotation or shear component.
Return values
truet->ub != 0.0F or t->uc != 0.0F.
falseBoth t->ub and t->uc are 0.0F (axis-aligned).
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
t->ub and t->uc hold the shear terms of the current affine.
Postcondition
t is not modified.
The return value is deterministic given the same t.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 118 of file reflow_svg_xform.c.

References svg_xform_t::ub, and svg_xform_t::uc.

Referenced by priv_ra8_svgp_draw_circle(), and priv_ra8_svgp_draw_rect().

◆ priv_ra8_svgp_lc()

char priv_ra8_svgp_lc ( char c)

ASCII-fold a character to lower case.

Converts 'A'-'Z' to lower case; all other bytes pass through. Defined in reflow_svg.c.

Parameters
[in]cCharacter to fold.
Returns
char The lowercase equivalent of c, or c unchanged.
Return values
'a'..'z'When c was an uppercase ASCII letter.
cOtherwise.
Precondition
c is any value representable by char.
No module state is required before calling this function.
Postcondition
The result is lower case when c was an uppercase letter.
No external state is modified.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Converts uppercase ASCII letters ('A'-'Z') to their lowercase equivalents by adding the ('a' - 'A') offset. All other characters, including non-ASCII bytes, digits, punctuation, and control characters, are returned unchanged. Used by case-insensitive string comparisons throughout the SVG parser (element names, attribute names, colour names).

Parameters
[in]cCharacter to fold.
Returns
char The lowercase equivalent of c, or c unchanged.
Return values
'a'..'z'When c was an uppercase ASCII letter.
cWhen c was already lowercase or not an ASCII letter.
Precondition
c is any value representable by char.
No module state is required before calling this function.
Postcondition
The return value is an ASCII lowercase letter when c was an uppercase letter.
No external state is modified by this function.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 88 of file reflow_svg.c.

Referenced by internal_ci_eq(), internal_hex(), internal_parse_path(), and priv_ra8_svgp_starts_ci().

◆ priv_ra8_svgp_map_point()

void priv_ra8_svgp_map_point ( const svg_xform_t * t,
int32_t ux,
int32_t uy,
int32_t * fx,
int32_t * fy )

Map a user-space point through the FULL affine, then viewBox->box.

Generalised point map for rotated/sheared/gradient shapes; reduces to the axis-aligned map when the affine is axis-aligned. Defined in reflow_svg_xform.c.

Parameters
[in]tActive transform; must not be NULL.
[in]uxUser-space X coordinate to map.
[in]uyUser-space Y coordinate to map.
[out]fxSet to the framebuffer X coordinate; must not be NULL.
[out]fySet to the framebuffer Y coordinate; must not be NULL.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
fx and fy are valid non-NULL output pointers.
Postcondition
*fx and *fy are set to the framebuffer-space coordinates.
t, ux, and uy are not modified.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Generalized point map for rotated/sheared/gradient shapes. When the affine is axis-aligned (ub==0 && uc==0) the result is byte-identical to (priv_ra8_svgp_mx(ux), priv_ra8_svgp_my(uy)), so routing the polygon/path/line emitters through it does not change the untransformed render.

Parameters
[in]tActive transform; must not be NULL.
[in]uxUser-space X coordinate to map.
[in]uyUser-space Y coordinate to map.
[out]fxSet to the framebuffer X coordinate; must not be NULL.
[out]fySet to the framebuffer Y coordinate; must not be NULL.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
fx and fy are valid non-NULL output pointers.
Postcondition
*fx and *fy are set to the framebuffer-space coordinates.
t, ux, and uy are not modified.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 148 of file reflow_svg_xform.c.

References svg_xform_t::bh, svg_xform_t::bw, svg_xform_t::bx, svg_xform_t::by, svg_xform_t::ua, svg_xform_t::ub, svg_xform_t::uc, svg_xform_t::ud, svg_xform_t::ue, svg_xform_t::uf, svg_xform_t::vh, svg_xform_t::vw, svg_xform_t::vx, and svg_xform_t::vy.

Referenced by internal_flatten_cubic(), internal_flatten_quad(), internal_parse_path(), internal_parse_points(), priv_ra8_svgp_draw_circle(), priv_ra8_svgp_draw_line(), priv_ra8_svgp_draw_rect(), and priv_ra8_svgp_flatten_arc().

◆ priv_ra8_svgp_mx()

int32_t priv_ra8_svgp_mx ( const svg_xform_t * t,
int32_t sx )

Map a user-space x coordinate to a framebuffer x coordinate.

Applies the axis-aligned user transform then the viewBox->box scale. Valid only on the axis-aligned fast path. Defined in reflow_svg_xform.c.

Parameters
[in]tActive coordinate transform; must not be NULL.
[in]sxUser-space X coordinate to map.
Returns
int32_t Framebuffer X coordinate corresponding to sx.
Return values
nThe framebuffer pixel column for user-space column sx.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
t->vw is non-zero (the viewBox has a positive width).
Postcondition
The return value is t->bx + (int32_t)(((ux - t->vx) * t->bw) / t->vw).
t and sx are not modified.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Applies the axis-aligned user transform via internal_ux, then maps the result through the viewBox-to-box scaling: bx + (ux - vx) * bw / vw. Uses 64-bit intermediate arithmetic to avoid overflow on large coordinates. Valid only when t->ub == 0.0F and t->uc == 0.0F; for the general case use priv_ra8_svgp_map_point.

Parameters
[in]tActive coordinate transform; must not be NULL.
[in]sxUser-space X coordinate to map.
Returns
int32_t Framebuffer X coordinate corresponding to sx.
Return values
nThe framebuffer pixel column for user-space column sx.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
t->vw is non-zero (the viewBox has a positive width).
Postcondition
The return value is t->bx + (int32_t)(((ux - t->vx) * t->bw) / t->vw).
t and sx are not modified.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 182 of file reflow_svg_xform.c.

References svg_xform_t::bw, svg_xform_t::bx, internal_ux(), svg_xform_t::vw, and svg_xform_t::vx.

Referenced by priv_ra8_svgp_draw_circle(), and priv_ra8_svgp_draw_rect().

◆ priv_ra8_svgp_my()

int32_t priv_ra8_svgp_my ( const svg_xform_t * t,
int32_t sy )

Map a user-space y coordinate to a framebuffer y coordinate.

Applies the axis-aligned user transform then the viewBox->box scale. Valid only on the axis-aligned fast path. Defined in reflow_svg_xform.c.

Parameters
[in]tActive coordinate transform; must not be NULL.
[in]syUser-space Y coordinate to map.
Returns
int32_t Framebuffer Y coordinate corresponding to sy.
Return values
nThe framebuffer pixel row for user-space row sy.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
t->vh is non-zero (the viewBox has a positive height).
Postcondition
The return value is t->by + (int32_t)(((uy - t->vy) * t->bh) / t->vh).
t and sy are not modified.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Applies the axis-aligned user transform via internal_uy, then maps the result through the viewBox-to-box scaling: by + (uy - vy) * bh / vh. Uses 64-bit intermediate arithmetic to avoid overflow on large coordinates. Valid only when t->ub == 0.0F and t->uc == 0.0F; for the general case use priv_ra8_svgp_map_point.

Parameters
[in]tActive coordinate transform; must not be NULL.
[in]syUser-space Y coordinate to map.
Returns
int32_t Framebuffer Y coordinate corresponding to sy.
Return values
nThe framebuffer pixel row for user-space row sy.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
t->vh is non-zero (the viewBox has a positive height).
Postcondition
The return value is t->by + (int32_t)(((uy - t->vy) * t->bh) / t->vh).
t and sy are not modified.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 214 of file reflow_svg_xform.c.

References svg_xform_t::bh, svg_xform_t::by, internal_uy(), svg_xform_t::vh, and svg_xform_t::vy.

Referenced by priv_ra8_svgp_draw_circle(), and priv_ra8_svgp_draw_rect().

◆ priv_ra8_svgp_num()

int32_t priv_ra8_svgp_num ( const uint8_t * s,
size_t len,
size_t * i )

Parse the integer part of one SVG number at s[*i]; truncate fractions.

Skips leading whitespace/comma separators, reads an optional sign and decimal digits, and discards any fractional part. Defined in reflow_svg.c.

Parameters
[in]sByte buffer holding the SVG text; must not be NULL.
[in]lenTotal valid bytes in s.
[in,out]iCurrent parse cursor; advanced past the consumed number.
Returns
int32_t The signed integer value parsed from the current cursor.
Return values
0No digit characters were found.
nThe value of the decimal integer scanned from s[*i].
Precondition
s is a valid pointer to at least len bytes.
i is not NULL, and *i is <= len.
Postcondition
*i is advanced past whitespace, sign, integer digits, and fraction.
*i <= len.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Parse the integer part of one SVG number at s[*i]; truncate fractions.

First advances *i past any leading whitespace or comma separators. Then reads an optional sign ('+'/'-') followed by consecutive decimal digit characters to form an int32_t. If a decimal point is found immediately after the integer digits, the fractional digits are consumed and discarded so that the next call begins at the correct position. On return *i points one past the last character consumed.

Parameters
[in]sByte buffer holding the SVG text; must not be NULL.
[in]lenTotal valid bytes in s.
[in,out]iCurrent parse cursor; updated to one past the consumed number.
Returns
int32_t The signed integer value parsed from the current cursor position.
Return values
0No digit characters were found after the sign (or no sign either).
nThe value of the decimal integer scanned from s[*i].
Precondition
s is a valid pointer to at least len bytes.
i is not NULL, and *i is <= len.
Postcondition
*i is advanced past any whitespace, sign, integer digits, and fraction.
*i <= len.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 255 of file reflow_svg.c.

References k_svg_dec, and priv_ra8_svgp_ws().

Referenced by internal_parse_path(), internal_parse_points(), internal_read_viewbox(), priv_ra8_svgp_attr_num(), and ra8_svg_size().

◆ priv_ra8_svgp_numf()

float priv_ra8_svgp_numf ( const uint8_t * s,
size_t len,
size_t * i )

Parse one SVG floating-point number at s[*i], skipping separators.

Skips whitespace/commas, reads an optional sign, integer and fractional digits, and advances *i past the number. Defined in reflow_svg_xform.c.

Parameters
[in]sByte buffer holding the SVG text; must not be NULL.
[in]lenTotal valid bytes in s.
[in,out]iCurrent parse cursor; advanced past the consumed number.
Returns
float The signed floating-point value parsed from s[*i].
Return values
0.0FNo digit characters were found.
nThe parsed value, including integer and fractional parts.
Precondition
s is a valid pointer to at least len bytes.
i is not NULL, and *i is <= len.
Postcondition
*i is advanced past separators, sign, integer digits, and fraction.
*i <= len.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Parse one SVG floating-point number at s[*i], skipping separators.

Advances *i past whitespace and comma separators, reads an optional sign ('+'/'-'), then accumulates integer digit characters into v. If a decimal point follows, fractional digits are accumulated with decreasing place values. On return, *i points one past the last character consumed so subsequent calls parse the next number correctly. Used for all floating-point geometry values including path curve control-point coordinates and arc parameters.

Parameters
[in]sByte buffer holding the SVG text; must not be NULL.
[in]lenTotal valid bytes in s.
[in,out]iCurrent parse cursor; updated to one past the consumed number.
Returns
float The signed floating-point value parsed from s[*i].
Return values
0.0FNo digit characters found after the sign (or no sign/digits at all).
nThe parsed value, including integer and fractional parts.
Precondition
s is a valid pointer to at least len bytes.
i is not NULL, and *i is <= len.
Postcondition
*i is advanced past separators, sign, integer digits, and fraction.
*i <= len.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 280 of file reflow_svg_xform.c.

References k_svg_dec, and priv_ra8_svgp_ws().

Referenced by internal_attr_numf(), internal_stop_offset(), and internal_xform_read().

◆ priv_ra8_svgp_paint()

uint32_t priv_ra8_svgp_paint ( const uint8_t * s,
size_t len )

Parse an SVG paint value ('#rgb'/'#rrggbb'/name/'none') to 0x00RRGGBB.

Routes the span to the hex or named-colour parser, returning the no-paint sentinel for empty/"none"/unknown. Defined in reflow_svg.c.

Parameters
[in]sByte span containing the paint value; must not be NULL.
[in]lenNumber of valid bytes in s.
Returns
uint32_t The 24-bit RGB colour, or k_svg_no_paint on failure.
Return values
0x000000..0xFFFFFFSuccessfully parsed solid colour.
(uint32_t)k_svg_no_paintEmpty span, "none", or unrecognised value.
Precondition
s is a valid pointer to at least len bytes.
len is the exact byte length of the attribute value to parse.
Postcondition
s is not modified.
The return value has bits [31:24] clear.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Routes the span to either internal_hex_color (when the first byte is '#', strip it first) or internal_named_color for keyword colours. An empty span immediately returns k_svg_no_paint. The keyword "none" is handled by internal_named_color returning k_svg_no_paint so callers skip the paint.

Parameters
[in]sByte span containing the paint value; must not be NULL.
[in]lenNumber of valid bytes in s.
Returns
uint32_t The 24-bit RGB colour, or k_svg_no_paint on failure.
Return values
0x000000..0xFFFFFFSuccessfully parsed solid colour.
(uint32_t)k_svg_no_paintEmpty span, "none", or unrecognised value.
Precondition
s is a valid pointer to at least len bytes.
len is the exact byte length of the attribute value to parse.
Postcondition
s is not modified.
The return value has bits [31:24] clear.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 614 of file reflow_svg.c.

References internal_hex_color(), internal_named_color(), and k_svg_no_paint.

Referenced by internal_stop_color(), priv_ra8_svgp_attr_paint(), and priv_ra8_svgp_resolve_fill().

◆ priv_ra8_svgp_resolve_fill()

uint32_t priv_ra8_svgp_resolve_fill ( const uint8_t * s,
size_t len,
const svg_xform_t * t,
uint32_t def,
int32_t * gi )

Resolve a shape's 'fill': a solid colour, or a gradient index via gi.

Sets *gi to the matched gradient index for a 'fill="url(#id)"' that resolves in t->grads (returning k_svg_no_paint), else returns the parsed solid colour or def. Defined in reflow_svg.c.

Parameters
[in]sByte buffer containing the SVG tag text; must not be NULL.
[in]lenTotal valid bytes in s.
[in]tActive coordinate transform carrying the gradient set pointer.
[in]defDefault solid colour when the 'fill' attribute is absent.
[out]giSet to the matched gradient index, or -1 when not a gradient.
Returns
uint32_t The resolved solid colour, or k_svg_no_paint for gradient fills.
Return values
def'fill' attribute is absent.
(uint32_t)k_svg_no_paint'fill' is a 'url(#id)' reference (gradient).
0x000000..0xFFFFFFSolid colour from the 'fill' attribute.
Precondition
s is a valid pointer to at least len bytes.
gi is a valid non-NULL output pointer.
Postcondition
*gi is always written before return.
When *gi >= 0, the return value is k_svg_no_paint.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Sets *gi to the matched gradient index (>= 0) for a 'fill="url(#id)"' that resolves in t->grads, returning k_svg_no_paint so the solid path is skipped. A 'url(#id)' with no match also returns k_svg_no_paint with *gi == -1 (graceful skip). An absent 'fill' returns def; otherwise the solid colour parsed from the attribute.

Parameters
[in]sByte buffer containing the SVG tag text; must not be NULL.
[in]lenTotal valid bytes in s.
[in]tActive coordinate transform carrying the gradient set pointer.
[in]defDefault solid colour when the 'fill' attribute is absent.
[out]giSet to the matched gradient index, or -1 when not a gradient.
Returns
uint32_t The resolved solid colour, or k_svg_no_paint for gradient fills.
Return values
def'fill' attribute is absent.
(uint32_t)k_svg_no_paint'fill' is a 'url(#id)' reference (gradient).
0x000000..0xFFFFFFSolid colour from the 'fill' attribute.
Precondition
s is a valid pointer to at least len bytes.
gi is a valid non-NULL output pointer.
Postcondition
*gi is always written before return.
When *gi >= 0, the return value is k_svg_no_paint.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 721 of file reflow_svg.c.

References svg_xform_t::grads, k_svg_no_paint, priv_match_grad(), priv_ra8_svgp_attr(), priv_ra8_svgp_paint(), and priv_ra8_svgp_starts_ci().

Referenced by priv_ra8_svgp_draw_circle(), priv_ra8_svgp_draw_path(), priv_ra8_svgp_draw_polygon(), and priv_ra8_svgp_draw_rect().

◆ priv_ra8_svgp_starts_ci()

bool priv_ra8_svgp_starts_ci ( const uint8_t * s,
size_t len,
size_t at,
const char * lit )

Case-insensitive prefix test of lit at at within s[0..len).

Matches lit against s starting at at after ASCII folding, returning false when the remaining span is shorter than lit. Defined in reflow_svg.c.

Parameters
[in]sByte buffer to search; must not be NULL.
[in]lenTotal number of valid bytes in s.
[in]atByte offset at which to start the comparison.
[in]litNUL-terminated ASCII literal to match; must not be NULL.
Returns
bool Result of the case-insensitive prefix test.
Return values
trues[at .. at+strlen(lit)) matches lit case-insensitively.
falseat + strlen(lit) > len, or any character differs.
Precondition
s is a valid pointer to at least len bytes.
lit is a valid NUL-terminated ASCII string.
Postcondition
s and lit are not modified.
at and len are not modified.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Case-insensitive prefix test of lit at at within s[0..len).

Computes the length of lit via strlen, then verifies that s[at .. at+n) matches lit character-for-character after folding both sides through priv_ra8_svgp_lc. Returns false immediately when the remaining span s[at .. len) is shorter than lit, avoiding any out-of-bounds access. Matching is done byte-by-byte with no locale dependence.

Parameters
[in]sByte buffer to search; must not be NULL.
[in]lenTotal number of valid bytes in s.
[in]atByte offset within s at which to start the comparison.
[in]litNUL-terminated ASCII literal to match; must not be NULL.
Returns
bool Result of the case-insensitive prefix test.
Return values
trues[at .. at+strlen(lit)) matches lit case-insensitively.
falseat + strlen(lit) > len, or any character differs.
Precondition
s is a valid pointer to at least len bytes.
lit is a valid NUL-terminated ASCII string.
Postcondition
s and lit are not modified.
at and len are not modified.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 123 of file reflow_svg.c.

References priv_ra8_svgp_lc(), and strlen().

Referenced by internal_attr_at(), internal_elem_at(), internal_xform_kind(), priv_match_grad(), priv_ra8_svgp_find_ci(), priv_ra8_svgp_resolve_fill(), and ra8_svg_is_svg().

◆ priv_ra8_svgp_sx()

int32_t priv_ra8_svgp_sx ( const svg_xform_t * t,
int32_t sw )

Scale a user-space length by the user x scale and the viewBox x ratio.

Applies t->ua then the viewBox->box x ratio. Valid only on the axis-aligned fast path. Defined in reflow_svg_xform.c.

Parameters
[in]tActive coordinate transform; must not be NULL.
[in]swUser-space width (or length) to scale.
Returns
int32_t Framebuffer pixel width corresponding to sw user units.
Return values
nThe scaled pixel count, truncated to int32_t.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
t->vw is non-zero (the viewBox has a positive width).
Postcondition
The return value is (int32_t)((int64_t)((float)sw * t->ua) * t->bw / t->vw).
t and sw are not modified.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Applies the user x scale (t->ua) to the width sw, then scales the result by the viewBox-to-box x ratio (bw / vw). Uses 64-bit intermediate arithmetic to avoid overflow. Returns the framebuffer pixel count corresponding to sw user-space units. Valid only on the axis-aligned fast path.

Parameters
[in]tActive coordinate transform; must not be NULL.
[in]swUser-space width (or length) to scale.
Returns
int32_t Framebuffer pixel width corresponding to sw user units.
Return values
nThe scaled pixel count, truncated to int32_t.
Precondition
t is a valid non-NULL pointer to an initialised svg_xform_t.
t->vw is non-zero (the viewBox has a positive width).
Postcondition
The return value is (int32_t)((int64_t)((float)sw * t->ua) * t->bw / t->vw).
t and sw are not modified.
Note
Not thread-safe in isolation; callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 245 of file reflow_svg_xform.c.

References svg_xform_t::bw, svg_xform_t::ua, and svg_xform_t::vw.

Referenced by priv_ra8_svgp_draw_circle(), and priv_ra8_svgp_draw_rect().

◆ priv_ra8_svgp_ws()

bool priv_ra8_svgp_ws ( char c)

Test whether a character is XML whitespace.

Classifies c as space (0x20), tab (0x09), line feed (0x0A), carriage return (0x0D), or form feed (0x0C). Defined in reflow_svg.c.

Parameters
[in]cCharacter to test.
Returns
bool Classification result.
Return values
truec is one of the five XML whitespace characters.
falsec is not an XML whitespace character.
Precondition
c is any value representable by char.
No state is required before calling this function.
Postcondition
The return value is one of exactly {true, false}.
No external state is modified.
Note
Not thread-safe in isolation; callers are single-threaded during render.
Since
0.1.0

Classifies c as an XML whitespace character according to the XML 1.0 specification: space (0x20), horizontal tab (0x09), line feed (0x0A), carriage return (0x0D), or form feed (0x0C). Used throughout the parser to skip inter-token gaps and attribute boundaries without invoking libc locale.

Parameters
[in]cCharacter to test.
Returns
bool Classification result.
Return values
truec is one of the five XML whitespace characters.
falsec is not an XML whitespace character.
Precondition
c is any value representable by char (no range restriction).
No state or side-effects are required before calling this function.
Postcondition
The return value is one of exactly {true, false}.
No external state is modified by this function.
Note
Not thread-safe in isolation; all callers in this module are single-threaded during SVG render.
Since
0.1.0

Definition at line 58 of file reflow_svg.c.

Referenced by internal_attr_at(), internal_elem_at(), internal_next_cmd(), internal_parse_points(), internal_parse_xform(), internal_xform_read(), priv_ra8_svgp_attr(), priv_ra8_svgp_num(), priv_ra8_svgp_numf(), and ra8_svg_is_svg().