|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Block-level <img> layout for the reflow engine (#106). More...
#include <stddef.h>#include <stdint.h>#include "ra8_attributes.h"#include "ra8_err.h"#include "reflow.h"#include "reflow_image.h"#include "reflow_internal.h"#include "reflow_layout_internal.h"#include "stb_truetype.h"Go to the source code of this file.
Functions | |
| static bool | internal_apply_image_placeholder (reflow_t *engine, priv_cursor_t *cur) |
| Apply an <img> token without a bound loader: placeholder advance. | |
| static bool | internal_page_has_content (const reflow_t *engine, const priv_cursor_t *cur) |
| True iff the page under construction already holds glyphs or images. | |
| static void | internal_image_fit (int32_t iw, int32_t ih, int32_t col_w, int32_t avail_h, int32_t *out_w, int32_t *out_h) |
| Scale an intrinsic image size to fit the text column (no upscaling). | |
| static bool | internal_image_resolve_size (reflow_t *engine, const reflow_token_t *tok, int32_t *out_w, int32_t *out_h) |
| Resolve an image token to a column-fitted box size via the loader. | |
| static void | internal_image_record (reflow_t *engine, priv_cursor_t *cur, const reflow_token_t *tok, int32_t bw, int32_t bh) |
| Record a laid-out image box and advance the cursor below it. | |
| static bool | internal_place_image (reflow_t *engine, priv_cursor_t *cur, const reflow_token_t *tok) |
| Lay out a real <img> as a block: size it, page-break, record it. | |
| bool | priv_reflow_layout_apply_image (reflow_t *engine, priv_cursor_t *cur, const reflow_token_t *tok) |
| Apply an <img> token: real image when a loader is bound, else a placeholder. | |
Block-level <img> layout for the reflow engine (#106).
Splits the image-layout sub-responsibility out of reflow_layout.c so each translation unit stays under the project file-size cap. An <img> is laid out as a block: when a loader + arena are bound and the token carries a source slice, the encoded bytes are fetched, the intrinsic size is probed (zero-alloc), the box is scaled to fit the text column without upscaling, the cursor page-breaks as needed, and the box is recorded for the render pass. If no loader is bound – or any sizing step fails – the historic fixed-size placeholder advance is used so image-free content remains byte-identical.
The driver reaches this module via priv_reflow_layout_apply_image; the core inline-flow helpers it reuses (line wrap, page flush) are shared through reflow_layout_internal.h.
[Ring 4 / Reflow] {World: NS}
Definition in file reflow_layout_image.c.
|
static |
Apply an <img> token without a bound loader: placeholder advance.
See implementation. Historical v1 behaviour, kept so image-free content (and content laid out before a loader is bound) is byte-identical.
| [in] | engine | See implementation. |
| [in] | cur | See implementation. |
| k_ra8_ok | Operation succeeded. |
Definition at line 55 of file reflow_layout_image.c.
References k_priv_image_placeholder_px, k_reflow_margin_px, priv_cursor_t::line_has_content, priv_reflow_internal_right_overflow_break(), priv_reflow_layout_newline(), reflow_t::viewport_w, and priv_cursor_t::x.
Referenced by priv_reflow_layout_apply_image().
|
static |
Scale an intrinsic image size to fit the text column (no upscaling).
See implementation. Caps width at the column, height at one page; preserves aspect ratio with int64 products to avoid overflow.
| [in] | iw | See implementation. |
| [in] | ih | See implementation. |
| [in] | col_w | See implementation. |
| [in] | avail_h | See implementation. |
| [out] | out_w | See implementation. |
| [out] | out_h | See implementation. |
Definition at line 114 of file reflow_layout_image.c.
Referenced by internal_image_resolve_size().
|
static |
Record a laid-out image box and advance the cursor below it.
See implementation. Stores the box at the left margin / current baseline tagged with the active page, then drops the cursor past it.
| [in] | engine | See implementation. |
| [in] | cur | See implementation. |
| [in] | tok | See implementation. |
| [in] | bw | See implementation. |
| [in] | bh | See implementation. |
Definition at line 195 of file reflow_layout_image.c.
References reflow_image_box_t::h, reflow_t::image_box_count, reflow_t::image_boxes, priv_cursor_t::indent_px, k_reflow_margin_px, k_reflow_paragraph_gap_px, priv_cursor_t::line_has_content, priv_cursor_t::line_top, reflow_t::page_count, reflow_image_box_t::page_index, reflow_image_box_t::reserved, reflow_image_box_t::src_len, reflow_image_box_t::src_off, reflow_token_t::text_len, reflow_token_t::text_off, reflow_image_box_t::w, priv_cursor_t::x, reflow_image_box_t::x, priv_cursor_t::y, and reflow_image_box_t::y.
Referenced by internal_place_image().
|
static |
Resolve an image token to a column-fitted box size via the loader.
See implementation. Calls the bound loader for the encoded bytes, probes the intrinsic size (zero-alloc), and fits it to the column.
| [in] | engine | See implementation. |
| [in] | tok | See implementation. |
| [out] | out_w | See implementation. |
| [out] | out_h | See implementation. |
| true | Box size resolved. |
| false | Loader failed, probe failed, or viewport too small. |
Definition at line 151 of file reflow_layout_image.c.
References reflow_t::img_loader, reflow_t::img_loader_ctx, internal_image_fit(), k_ra8_ok, k_reflow_margin_px, ra8_img_probe_size(), reflow_token_t::text_len, reflow_token_t::text_off, reflow_t::text_pool, reflow_t::viewport_h, and reflow_t::viewport_w.
Referenced by internal_place_image().
|
static |
True iff the page under construction already holds glyphs or images.
See implementation.
| [in] | engine | See implementation. |
| [in] | cur | See implementation. |
| true | Page has content. |
Definition at line 88 of file reflow_layout_image.c.
References reflow_t::glyph_count, reflow_t::image_box_count, priv_cursor_t::page_first_glyph, and priv_cursor_t::page_first_image.
Referenced by internal_place_image().
|
static |
Lay out a real <img> as a block: size it, page-break, record it.
See implementation. Returns false (caller falls back to the placeholder) on a full image pool, unresolved src, or a flush overflow.
| [in] | engine | See implementation. |
| [in] | cur | See implementation. |
| [in] | tok | See implementation. |
| true | Image placed and recorded. |
| false | Could not place; caller uses the placeholder. |
Definition at line 237 of file reflow_layout_image.c.
References reflow_t::image_box_count, internal_image_record(), internal_image_resolve_size(), internal_page_has_content(), k_reflow_margin_px, k_reflow_max_images, priv_cursor_t::line_has_content, priv_cursor_t::line_height_px, priv_reflow_layout_finish_page(), priv_reflow_layout_newline(), reflow_t::viewport_h, and priv_cursor_t::y.
Referenced by priv_reflow_layout_apply_image().
| bool priv_reflow_layout_apply_image | ( | reflow_t * | engine, |
| priv_cursor_t * | cur, | ||
| const reflow_token_t * | tok ) |
Apply an <img> token: real image when a loader is bound, else a placeholder.
Defined in reflow_layout_image.c. When the engine has a bound image loader + arena and the token carries a source slice, the image is sized to the text column, page-broken as a block, and recorded as an image box; any failure (full pool, unresolved src, flush overflow) falls back to the historic fixed-size placeholder advance so image-free content stays byte-identical.
| [in] | engine | See implementation. |
| [in] | cur | See implementation. |
| [in] | tok | See implementation. |
| true | Token applied (image placed or placeholder reserved). |
| false | Pool overflow propagated from a sub-step. |
Definition at line 270 of file reflow_layout_image.c.
References reflow_t::img_arena, reflow_t::img_loader, internal_apply_image_placeholder(), internal_place_image(), and reflow_token_t::text_len.
Referenced by priv_reflow_layout_apply_token().