ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
reflow_api.h
Go to the documentation of this file.
1
23
24#pragma once
25
26#include <stddef.h>
27#include <stdint.h>
28
29#include "ra8_err.h"
30#include "ra8_glyph_atlas.h" /* ra8_glyph_atlas_t + storage descriptor types (#164) */
31#include "reflow_image.h" /* ra8_img_arena_t for the decode scratch */
32#include "reflow_types.h" /* reflow_t + supporting data model */
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38/* ===========================================================================
39 * Public API -- lifecycle
40 * ===========================================================================
41 */
42
79[[nodiscard]] ra8_err_t reflow_init(uint16_t viewport_w,
80 uint16_t viewport_h,
81 const uint8_t* font_data,
82 size_t font_len,
83 uint16_t font_px,
84 uint32_t body_color,
85 uint32_t link_color,
86 reflow_t* out_engine);
87
105[[nodiscard]] ra8_err_t reflow_close(reflow_t* engine);
106
138[[nodiscard]] ra8_err_t reflow_set_image_loader(reflow_t* engine,
140 void* ctx,
141 ra8_img_arena_t* arena);
142
168[[nodiscard]] ra8_err_t
169reflow_set_css_loader(reflow_t* engine, reflow_css_loader_fn loader, void* ctx);
170
201
243[[nodiscard]] ra8_err_t reflow_set_glyph_atlas(reflow_t* engine,
244 ra8_glyph_atlas_t* atlas,
245 const reflow_glyph_atlas_storage_t* storage);
246
277[[nodiscard]] ra8_err_t reflow_hit_test_link(const reflow_t* engine,
278 uint32_t page_idx,
279 int32_t x,
280 int32_t y,
281 uint32_t* out_href_off,
282 uint32_t* out_href_len);
283
331[[nodiscard]] ra8_err_t reflow_hit_test_image(const reflow_t* engine,
332 uint32_t page_idx,
333 int32_t x,
334 int32_t y,
335 uint32_t* out_index);
336
362[[nodiscard]] ra8_err_t
363reflow_find_anchor(const reflow_t* engine, const char* id, uint32_t id_len, uint32_t* out_page);
364
391[[nodiscard]] ra8_err_t reflow_href_split(const char* href,
392 uint32_t len,
393 reflow_href_kind_t* out_kind,
394 uint32_t* out_path_len,
395 uint32_t* out_frag_off,
396 uint32_t* out_frag_len);
397
398/* ===========================================================================
399 * Public API -- layout
400 * ===========================================================================
401 */
402
443[[nodiscard]] ra8_err_t reflow_layout_chapter(reflow_t* engine,
444 const uint8_t* xhtml_buf,
445 size_t xhtml_len,
446 uint32_t* out_total_pages);
447
485[[nodiscard]] ra8_err_t
486reflow_render_page(const reflow_t* engine, uint32_t page_idx, void* framebuffer);
487
522[[nodiscard]] ra8_err_t reflow_render_page_at(const reflow_t* engine,
523 uint32_t page_idx,
524 int32_t origin_x,
525 int32_t origin_y);
526
540[[nodiscard]] ra8_err_t reflow_get_page_count(const reflow_t* engine, uint32_t* out_count);
541
565[[nodiscard]] ra8_err_t reflow_set_font_size(reflow_t* engine, uint16_t new_font_px);
566
604[[nodiscard]] ra8_err_t
605reflow_bind_font(reflow_t* engine, const uint8_t* font_data, size_t font_len);
606
647[[nodiscard]] ra8_err_t
648reflow_register_face(reflow_t* engine, uint8_t css_face_idx, const uint8_t* blob, size_t len);
649
650/* ===========================================================================
651 * Internal -- exposed for the parse / layout / render TUs
652 * ===========================================================================
653 */
654
675[[nodiscard]] ra8_err_t
676reflow_parse_xhtml(reflow_t* engine, const uint8_t* xhtml_buf, size_t xhtml_len);
677
695[[nodiscard]] ra8_err_t reflow_run_layout(reflow_t* engine);
696
697#ifdef __cplusplus
698}
699#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Fixed-RAM-budget glyph cache with LRU eviction (Layer 3, #147).
ra8_err_t reflow_hit_test_link(const reflow_t *engine, uint32_t page_idx, int32_t x, int32_t y, uint32_t *out_href_off, uint32_t *out_href_len)
Hit-test a point on a page against the laid-out <a> link rectangles.
Definition reflow_link.c:36
ra8_err_t reflow_render_page(const reflow_t *engine, uint32_t page_idx, void *framebuffer)
Render one page into the active ra8_gfx framebuffer.
ra8_err_t reflow_run_layout(reflow_t *engine)
Run the line-break + page-break pass over engine->tokens[].
ra8_err_t reflow_layout_chapter(reflow_t *engine, const uint8_t *xhtml_buf, size_t xhtml_len, uint32_t *out_total_pages)
Parse + lay out one chapter of XHTML.
ra8_err_t reflow_parse_xhtml(reflow_t *engine, const uint8_t *xhtml_buf, size_t xhtml_len)
Parse the XHTML buffer into the engine's token stream.
ra8_err_t reflow_set_css_loader(reflow_t *engine, reflow_css_loader_fn loader, void *ctx)
Bind the external-stylesheet loader for <link rel="stylesheet">.
ra8_err_t reflow_find_anchor(const reflow_t *engine, const char *id, uint32_t id_len, uint32_t *out_page)
Find the page of a same-chapter id anchor (for #fragment jumps).
Definition reflow_link.c:88
ra8_err_t reflow_bind_font(reflow_t *engine, const uint8_t *font_data, size_t font_len)
Bind an EPUB-embedded typeface as the engine's active face (#109).
ra8_err_t reflow_set_font_size(reflow_t *engine, uint16_t new_font_px)
Change the body font size and re-flow the cached chapter.
ra8_err_t reflow_href_split(const char *href, uint32_t len, reflow_href_kind_t *out_kind, uint32_t *out_path_len, uint32_t *out_frag_off, uint32_t *out_frag_len)
Split + classify an <a href> into a path part and a #fragment.
ra8_err_t reflow_init(uint16_t viewport_w, uint16_t viewport_h, const uint8_t *font_data, size_t font_len, uint16_t font_px, uint32_t body_color, uint32_t link_color, reflow_t *out_engine)
Initialise a reflow engine for a given viewport / font.
ra8_err_t reflow_set_glyph_atlas(reflow_t *engine, ra8_glyph_atlas_t *atlas, const reflow_glyph_atlas_storage_t *storage)
Bind a Layer-3 glyph cache to the engine's render path (#164).
ra8_err_t reflow_get_page_count(const reflow_t *engine, uint32_t *out_count)
Report the laid-out page count.
ra8_err_t reflow_set_image_loader(reflow_t *engine, reflow_image_loader_fn loader, void *ctx, ra8_img_arena_t *arena)
Bind an <img> byte loader + decode arena to enable image rendering.
ra8_err_t reflow_hit_test_image(const reflow_t *engine, uint32_t page_idx, int32_t x, int32_t y, uint32_t *out_index)
Hit-test a point on a page against the laid-out <img> boxes (#478).
Definition reflow_link.c:63
ra8_err_t reflow_register_face(reflow_t *engine, uint8_t css_face_idx, const uint8_t *blob, size_t len)
Register one embedded @font-face typeface for per-run selection (#109).
ra8_err_t reflow_close(reflow_t *engine)
Release a previously initialized engine.
ra8_err_t reflow_render_page_at(const reflow_t *engine, uint32_t page_idx, int32_t origin_x, int32_t origin_y)
Render one page offset by (origin_x, origin_y) into the bound framebuffer.
Zero-heap raster image decode + scale + blit for reflow (#106).
Reflow-engine data model: enums, structs, typedefs, and the handle.
ra8_err_t(* reflow_css_loader_fn)(void *ctx, const char *href, uint32_t href_len, const uint8_t **out_bytes, size_t *out_len)
External-stylesheet byte loader for <link rel="stylesheet" href>.
ra8_err_t(* reflow_image_loader_fn)(void *ctx, const char *href, uint32_t href_len, const uint8_t **out_bytes, size_t *out_len)
Resolve an <img src> href to its encoded image bytes.
reflow_href_kind_t
Classification of an in-content <a href> target.
Glyph-cache state (caller-owned; treat as private).
Per-cell user descriptor: the rendered glyph dimensions.
Identifies one rendered glyph.
Caller-owned bump arena backing a single image decode.
Per-cell link metadata (one caller-owned array entry per cell).
Caller-owned backing storage for the render-path glyph cache (#164).
Definition reflow_api.h:191
ra8_glyph_dims_t * dims
cell_count dimension descriptors.
Definition reflow_api.h:197
ra8_glyph_key_t * keys
cell_count key-storage entries.
Definition reflow_api.h:196
uint8_t * cell_mem
cell_count * cell_bytes of bitmap storage.
Definition reflow_api.h:192
int32_t * buckets
bucket_count hash-bucket heads.
Definition reflow_api.h:198
uint32_t cell_count
Number of cells (the glyph-cache budget).
Definition reflow_api.h:194
ra8_keycache_cell_t * meta
cell_count link-metadata entries.
Definition reflow_api.h:195
uint32_t cell_bytes
Bytes per cell (>= largest cached glyph).
Definition reflow_api.h:193
uint32_t bucket_count
Number of hash buckets (>= 1).
Definition reflow_api.h:199
Reflow / pagination engine state.