|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Cross-TU surface for the split minimal-SVG subset (#112). More...
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. | |
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:
[Ring 4 / Reflow] {World: NS}
Definition in file reflow_svg_internal.h.
| 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.
| enum priv_svg_consts_t : uint32_t |
Parse + colour constants for the SVG subset.
Definition at line 40 of file reflow_svg_internal.h.
| 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.
| [in] | grads | Gradient set to search; may be NULL (returns -1). |
| [in] | val | Byte span holding the raw attribute value; must not be NULL. |
| [in] | vlen | Number of valid bytes in val. |
grads->g, or -1 on no match. | 0..grads->n-1 | The gradient whose id matches the url(#id) reference. |
| -1 | grads is NULL, val is not "url(#...)", or no id match. |
val is a valid pointer to at least vlen bytes. grads is non-NULL, grads->n <= k_svg_grad_max. val and grads are not modified. 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().
| 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.
| [in,out] | t | Transform whose user affine is updated in place; must not be NULL. |
| [in] | tag | Byte span of the element tag to search; must not be NULL. |
| [in] | tlen | Total valid bytes in tag. |
t is a valid non-NULL pointer to an initialised svg_xform_t. tag is a valid pointer to at least tlen bytes. t->ua .. t->uf reflect the newly composed affine. t is unchanged.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.
| [in,out] | t | Transform whose user affine is updated in place; must not be NULL. |
| [in] | tag | Byte span of the element tag to search; must not be NULL. |
| [in] | tlen | Total valid bytes in tag. |
t is a valid non-NULL pointer to an initialised svg_xform_t. tag is a valid pointer to at least tlen bytes.t->ua .. t->uf reflect the newly composed affine. t is unchanged.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().
| 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.
| [in] | s | Byte buffer containing the tag text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | name | NUL-terminated ASCII attribute name; must not be NULL. |
| [out] | voff | Set to the byte offset of the first value character when found. |
| [out] | vlen | Set to the byte length of the value when found. |
| true | Attribute name found; *voff and *vlen are valid. |
| false | Attribute not found, missing '=', or missing opening quote. |
s is a valid pointer to at least len bytes. voff and vlen are valid non-NULL output pointers. *voff < len and *voff + *vlen <= len. *voff and *vlen are indeterminate.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.
| [in] | s | Byte buffer containing the tag text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | name | NUL-terminated ASCII attribute name to find; must not be NULL. |
| [out] | voff | Set to the byte offset of the first value character when found. |
| [out] | vlen | Set to the byte length of the value when found. |
| true | Attribute name found; *voff and *vlen are valid. |
| false | Attribute not found, missing '=', or missing opening quote. |
s is a valid pointer to at least len bytes. voff and vlen are valid non-NULL output pointers.*voff < len and *voff + *vlen <= len. *voff and *vlen are indeterminate and must not be used.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().
| 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.
| [in] | s | Byte buffer containing the SVG tag text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | name | NUL-terminated ASCII attribute name; must not be NULL. |
| [in] | def | Value to return when the attribute is absent. |
def when absent. | def | Attribute name was not found in s. |
| n | The signed integer parsed from the attribute value. |
s is a valid pointer to at least len bytes. name is a valid NUL-terminated ASCII string. s and name are not modified. def when the attribute is absent.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.
| [in] | s | Byte buffer containing the SVG tag text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | name | NUL-terminated ASCII attribute name; must not be NULL. |
| [in] | def | Value to return when the attribute is absent. |
def when the attribute is absent. | def | Attribute name was not found in s. |
| n | The signed integer parsed from the attribute value. |
s is a valid pointer to at least len bytes. name is a valid NUL-terminated ASCII string.s and name are not modified. def when priv_ra8_svgp_attr returns false.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().
| 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.
| [in] | s | Byte buffer containing the SVG tag text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | name | NUL-terminated ASCII attribute name; must not be NULL. |
| [in] | def | Default paint value returned when the attribute is absent. |
def when absent. | def | Attribute name was not found in s. |
| 0x000000..0xFFFFFF | Successfully parsed solid paint colour. |
| (uint32_t)k_svg_no_paint | Attribute present but parses to no-paint. |
s is a valid pointer to at least len bytes. name is a valid NUL-terminated ASCII string. s and name are not modified. def when the attribute is absent.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.
| [in] | s | Byte buffer containing the SVG tag text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | name | NUL-terminated ASCII attribute name; must not be NULL. |
| [in] | def | Default paint value returned when the attribute is absent. |
def when the attribute is absent. | def | Attribute name was not found in s. |
| 0x000000..0xFFFFFF | Successfully parsed solid paint colour. |
| (uint32_t)k_svg_no_paint | Attribute present but parses to no-paint. |
s is a valid pointer to at least len bytes. name is a valid NUL-terminated ASCII string.s and name are not modified. def when the attribute is absent.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().
| 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.
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s (the tag span length). |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t. 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.
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s (the tag span length). |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t.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().
| 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.
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s (the tag span length). |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t. 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).
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s (the tag span length). |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t.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().
| 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.
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t. 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.
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t.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().
| 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.
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t. 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.
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t.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().
| 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.
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t. 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.
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t.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().
| 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.
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s (the tag span length). |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t. 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.
| [in] | s | Byte span of the element tag; must not be NULL. |
| [in] | len | Total valid bytes in s (the tag span length). |
| [in] | t | Active coordinate transform; must not be NULL. |
s is a valid pointer to at least len bytes. t is a valid non-NULL pointer to an initialised svg_xform_t.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().
| 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.
| [in] | xs | Array of n framebuffer X coordinates; must not be NULL. |
| [in] | ys | Array of n framebuffer Y coordinates; must not be NULL. |
| [in] | n | Number of polygon vertices. |
| [in] | color | Fill colour in 0x00RRGGBB format. |
xs and ys are valid pointers to at least n elements. n <= k_svg_poly_max. color. n < k_svg_poly_min.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.
| [in] | xs | Array of n framebuffer X coordinates; must not be NULL. |
| [in] | ys | Array of n framebuffer Y coordinates; must not be NULL. |
| [in] | n | Number of polygon vertices. |
| [in] | color | Fill colour in 0x00RRGGBB format. |
xs and ys are valid pointers to at least n elements. n <= k_svg_poly_max.color. n < k_svg_poly_min.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().
| 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.
| [in] | xs | Array of n framebuffer X coordinates; must not be NULL. |
| [in] | ys | Array of n framebuffer Y coordinates; must not be NULL. |
| [in] | n | Number of polygon vertices. |
| [in] | g | Gradient descriptor to evaluate per pixel; must not be NULL. |
xs and ys are valid pointers to at least n elements. g is a valid non-NULL pointer with g->nstops >= 1. n < k_svg_poly_min.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.
| [in] | xs | Array of n framebuffer X coordinates; must not be NULL. |
| [in] | ys | Array of n framebuffer Y coordinates; must not be NULL. |
| [in] | n | Number of polygon vertices. |
| [in] | g | Gradient descriptor to evaluate per pixel; must not be NULL. |
xs and ys are valid pointers to at least n elements. g is a valid non-NULL pointer with g->nstops >= 1.n < k_svg_poly_min.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().
| 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.
| [in] | s | Byte buffer to search; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | from | Starting byte offset; must be <= len. |
| [in] | lit | NUL-terminated ASCII literal to find; must not be NULL. |
len if not found. | [from..len) | Offset of the first case-insensitive occurrence. |
| len | lit was not found, or lit is empty. |
s is a valid pointer to at least len bytes. from is <= len. s and lit are not modified. from, len].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)).
| [in] | s | Byte buffer to search; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | from | Starting byte offset; must be <= len. |
| [in] | lit | NUL-terminated ASCII literal to find; must not be NULL. |
len if not found. | [from..len) | Offset of the first case-insensitive occurrence of lit. |
| len | lit was not found, or lit is empty. |
s is a valid pointer to at least len bytes. from is <= len.s and lit are not modified. from, len].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().
| 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.
| [in] | t | Active coordinate transform; must not be NULL. |
| [in] | p0 | Arc start point (current path position, user space). |
| [in] | args | Arc argument array indexed by k_svg_arc_* constants; must not be NULL. |
| [in] | p_end | Arc end point (absolute, user space). |
| [out] | xs | Vertex X array of at least k_svg_poly_max elements; must not be NULL. |
| [out] | ys | Vertex Y array of at least k_svg_poly_max elements; must not be NULL. |
| [in,out] | n | Current vertex count; updated by this function. |
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. *n is increased by the number of arc sample points appended. *n <= k_svg_poly_max on exit.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.
| [in] | t | Active coordinate transform; must not be NULL. |
| [in] | p0 | Arc start point (current path position, user space). |
| [in] | args | Arc argument array indexed by svg_arc_* constants; must not be NULL. |
| [in] | p_end | Arc end point (absolute, user space). |
| [out] | xs | Vertex X array of at least k_svg_poly_max elements; must not be NULL. |
| [out] | ys | Vertex Y array of at least k_svg_poly_max elements; must not be NULL. |
| [in,out] | n | Current vertex count; updated by this function. |
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.*n is increased by the number of arc sample points appended. *n <= k_svg_poly_max on exit.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().
| 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.
| [in] | t | Active coordinate transform; must not be NULL. |
| true | t->ub != 0.0F or t->uc != 0.0F. |
| false | Both t->ub and t->uc are 0.0F (axis-aligned). |
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. t is not modified. t.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.
| [in] | t | Active coordinate transform; must not be NULL. |
| true | t->ub != 0.0F or t->uc != 0.0F. |
| false | Both t->ub and t->uc are 0.0F (axis-aligned). |
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.t is not modified. t.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().
| 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.
| [in] | c | Character to fold. |
c, or c unchanged. | 'a'..'z' | When c was an uppercase ASCII letter. |
| c | Otherwise. |
c is any value representable by char. c was an uppercase letter. 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).
| [in] | c | Character to fold. |
c, or c unchanged. | 'a'..'z' | When c was an uppercase ASCII letter. |
| c | When c was already lowercase or not an ASCII letter. |
c is any value representable by char. c was an uppercase letter. 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().
| 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.
| [in] | t | Active transform; must not be NULL. |
| [in] | ux | User-space X coordinate to map. |
| [in] | uy | User-space Y coordinate to map. |
| [out] | fx | Set to the framebuffer X coordinate; must not be NULL. |
| [out] | fy | Set to the framebuffer Y coordinate; must not be NULL. |
t is a valid non-NULL pointer to an initialised svg_xform_t. fx and fy are valid non-NULL output pointers. *fx and *fy are set to the framebuffer-space coordinates. t, ux, and uy are not modified.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.
| [in] | t | Active transform; must not be NULL. |
| [in] | ux | User-space X coordinate to map. |
| [in] | uy | User-space Y coordinate to map. |
| [out] | fx | Set to the framebuffer X coordinate; must not be NULL. |
| [out] | fy | Set to the framebuffer Y coordinate; must not be NULL. |
t is a valid non-NULL pointer to an initialised svg_xform_t. fx and fy are valid non-NULL output pointers.*fx and *fy are set to the framebuffer-space coordinates. t, ux, and uy are not modified.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().
| 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.
| [in] | t | Active coordinate transform; must not be NULL. |
| [in] | sx | User-space X coordinate to map. |
sx. | n | The framebuffer pixel column for user-space column sx. |
t is a valid non-NULL pointer to an initialised svg_xform_t. t->vw is non-zero (the viewBox has a positive width). t->bx + (int32_t)(((ux - t->vx) * t->bw) / t->vw). t and sx are not modified.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.
| [in] | t | Active coordinate transform; must not be NULL. |
| [in] | sx | User-space X coordinate to map. |
sx. | n | The framebuffer pixel column for user-space column sx. |
t is a valid non-NULL pointer to an initialised svg_xform_t. t->vw is non-zero (the viewBox has a positive width).t->bx + (int32_t)(((ux - t->vx) * t->bw) / t->vw). t and sx are not modified.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().
| 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.
| [in] | t | Active coordinate transform; must not be NULL. |
| [in] | sy | User-space Y coordinate to map. |
sy. | n | The framebuffer pixel row for user-space row sy. |
t is a valid non-NULL pointer to an initialised svg_xform_t. t->vh is non-zero (the viewBox has a positive height). t->by + (int32_t)(((uy - t->vy) * t->bh) / t->vh). t and sy are not modified.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.
| [in] | t | Active coordinate transform; must not be NULL. |
| [in] | sy | User-space Y coordinate to map. |
sy. | n | The framebuffer pixel row for user-space row sy. |
t is a valid non-NULL pointer to an initialised svg_xform_t. t->vh is non-zero (the viewBox has a positive height).t->by + (int32_t)(((uy - t->vy) * t->bh) / t->vh). t and sy are not modified.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().
| 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.
| [in] | s | Byte buffer holding the SVG text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in,out] | i | Current parse cursor; advanced past the consumed number. |
| 0 | No digit characters were found. |
| n | The value of the decimal integer scanned from s[*i]. |
s is a valid pointer to at least len bytes. i is not NULL, and *i is <= len. *i is advanced past whitespace, sign, integer digits, and fraction. *i <= len.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.
| [in] | s | Byte buffer holding the SVG text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in,out] | i | Current parse cursor; updated to one past the consumed number. |
| 0 | No digit characters were found after the sign (or no sign either). |
| n | The value of the decimal integer scanned from s[*i]. |
s is a valid pointer to at least len bytes. i is not NULL, and *i is <= len.*i is advanced past any whitespace, sign, integer digits, and fraction. *i <= len.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().
| 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.
| [in] | s | Byte buffer holding the SVG text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in,out] | i | Current parse cursor; advanced past the consumed number. |
s[*i]. | 0.0F | No digit characters were found. |
| n | The parsed value, including integer and fractional parts. |
s is a valid pointer to at least len bytes. i is not NULL, and *i is <= len. *i is advanced past separators, sign, integer digits, and fraction. *i <= len.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.
| [in] | s | Byte buffer holding the SVG text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in,out] | i | Current parse cursor; updated to one past the consumed number. |
s[*i]. | 0.0F | No digit characters found after the sign (or no sign/digits at all). |
| n | The parsed value, including integer and fractional parts. |
s is a valid pointer to at least len bytes. i is not NULL, and *i is <= len.*i is advanced past separators, sign, integer digits, and fraction. *i <= len.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().
| 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.
| [in] | s | Byte span containing the paint value; must not be NULL. |
| [in] | len | Number of valid bytes in s. |
| 0x000000..0xFFFFFF | Successfully parsed solid colour. |
| (uint32_t)k_svg_no_paint | Empty span, "none", or unrecognised value. |
s is a valid pointer to at least len bytes. len is the exact byte length of the attribute value to parse. s is not modified. 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.
| [in] | s | Byte span containing the paint value; must not be NULL. |
| [in] | len | Number of valid bytes in s. |
| 0x000000..0xFFFFFF | Successfully parsed solid colour. |
| (uint32_t)k_svg_no_paint | Empty span, "none", or unrecognised value. |
s is a valid pointer to at least len bytes. len is the exact byte length of the attribute value to parse.s is not modified. 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().
| 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.
| [in] | s | Byte buffer containing the SVG tag text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | t | Active coordinate transform carrying the gradient set pointer. |
| [in] | def | Default solid colour when the 'fill' attribute is absent. |
| [out] | gi | Set to the matched gradient index, or -1 when not a gradient. |
| def | 'fill' attribute is absent. |
| (uint32_t)k_svg_no_paint | 'fill' is a 'url(#id)' reference (gradient). |
| 0x000000..0xFFFFFF | Solid colour from the 'fill' attribute. |
s is a valid pointer to at least len bytes. gi is a valid non-NULL output pointer. *gi is always written before return. *gi >= 0, the return value is k_svg_no_paint.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.
| [in] | s | Byte buffer containing the SVG tag text; must not be NULL. |
| [in] | len | Total valid bytes in s. |
| [in] | t | Active coordinate transform carrying the gradient set pointer. |
| [in] | def | Default solid colour when the 'fill' attribute is absent. |
| [out] | gi | Set to the matched gradient index, or -1 when not a gradient. |
| def | 'fill' attribute is absent. |
| (uint32_t)k_svg_no_paint | 'fill' is a 'url(#id)' reference (gradient). |
| 0x000000..0xFFFFFF | Solid colour from the 'fill' attribute. |
s is a valid pointer to at least len bytes. gi is a valid non-NULL output pointer.*gi is always written before return. *gi >= 0, the return value is k_svg_no_paint.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().
| 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.
| [in] | s | Byte buffer to search; must not be NULL. |
| [in] | len | Total number of valid bytes in s. |
| [in] | at | Byte offset at which to start the comparison. |
| [in] | lit | NUL-terminated ASCII literal to match; must not be NULL. |
| true | s[at .. at+strlen(lit)) matches lit case-insensitively. |
| false | at + strlen(lit) > len, or any character differs. |
s is a valid pointer to at least len bytes. lit is a valid NUL-terminated ASCII string. s and lit are not modified. at and len are not modified.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.
| [in] | s | Byte buffer to search; must not be NULL. |
| [in] | len | Total number of valid bytes in s. |
| [in] | at | Byte offset within s at which to start the comparison. |
| [in] | lit | NUL-terminated ASCII literal to match; must not be NULL. |
| true | s[at .. at+strlen(lit)) matches lit case-insensitively. |
| false | at + strlen(lit) > len, or any character differs. |
s is a valid pointer to at least len bytes. lit is a valid NUL-terminated ASCII string.s and lit are not modified. at and len are not modified.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().
| 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.
| [in] | t | Active coordinate transform; must not be NULL. |
| [in] | sw | User-space width (or length) to scale. |
sw user units. | n | The scaled pixel count, truncated to int32_t. |
t is a valid non-NULL pointer to an initialised svg_xform_t. t->vw is non-zero (the viewBox has a positive width). t and sw are not modified.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.
| [in] | t | Active coordinate transform; must not be NULL. |
| [in] | sw | User-space width (or length) to scale. |
sw user units. | n | The scaled pixel count, truncated to int32_t. |
t is a valid non-NULL pointer to an initialised svg_xform_t. t->vw is non-zero (the viewBox has a positive width).t and sw are not modified.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().
| 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.
| [in] | c | Character to test. |
| true | c is one of the five XML whitespace characters. |
| false | c is not an XML whitespace character. |
c is any value representable by char. 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.
| [in] | c | Character to test. |
| true | c is one of the five XML whitespace characters. |
| false | c is not an XML whitespace character. |
c is any value representable by char (no range restriction). 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().