31static const char*
const s_tag =
"longstrip";
46typedef enum : uint8_t {
184 if ((viewport_w == 0U) || (viewport_h == 0U)) {
190 (wt->
canvas_h > (uint32_t)viewport_h) ? (int32_t)(wt->
canvas_h - (uint32_t)viewport_h) : 0;
203 }
else if (y > max) {
216 *out_band = (uint16_t)(y / (uint32_t)wt->
band_h);
229 const uint32_t bh = (uint32_t)wt->
band_h;
230 const uint32_t first = (uint32_t)top / bh;
231 uint32_t bottom = (uint32_t)top + (uint32_t)wt->
viewport_h - 1U;
235 uint32_t last = bottom / bh;
239 *out_first = (uint16_t)first;
240 *out_last = (uint16_t)last;
263 const int64_t sum = (int64_t)a + (int64_t)b;
264 if (sum > (int64_t)INT32_MAX) {
267 if (sum < (int64_t)INT32_MIN) {
442 const uint16_t visible_span = (uint16_t)((last - first) + 1U);
444 if ((depth == 0U) || (wt->
band_count <= visible_span)) {
447 const bool downward = (wt->
velocity >= 0);
448 for (uint16_t i = 1U; i <= depth; i++) {
451 const uint32_t t = (uint32_t)last + (uint32_t)i;
455 target = (uint16_t)t;
460 target = (uint16_t)(first - i);
491 int32_t top = (dst_y > 0) ? dst_y : 0;
492 int32_t bot = dst_y + (int32_t)band_h;
537 const int32_t dst_y = (int32_t)((uint32_t)band * (uint32_t)wt->
band_h) - wt->
scroll_y;
547 return (berr !=
k_ra8_ok) ? berr : perr;
562 for (uint32_t b = (uint32_t)first; b <= (uint32_t)last; b++) {
568 if (stats !=
nullptr) {
JOF band-tile atlas: the display-native normalized image format (#231, shared with the longstrip scro...
ra8_err_t jof_read_tile(jof_pread_fn pread, void *pread_ctx, const jof_info_t *info, uint16_t tile_x, uint16_t tile_y, uint8_t *scratch, uint32_t scratch_cap, uint8_t *out_px, uint32_t out_cap, uint16_t *out_w, uint16_t *out_h)
Read + decode one tile into caller pixels, in bounded RAM.
ra8_err_t jof_parse(jof_pread_fn pread, void *pread_ctx, uint64_t total_size, jof_info_t *out_info)
Parse + validate a JOF atlas's header, footer and index bounds.
ra8_err_t longstrip_prefetch(longstrip_t *wt, uint16_t depth)
Warm the cache with bands just beyond the viewport, in scroll order.
ra8_err_t longstrip_tile_decode(void *ctx, const ra8_tile_key_t *key, uint8_t *cell, uint32_t cell_bytes, uint16_t *out_w, uint16_t *out_h)
JOF-backed ra8_tile_decode_fn: page one band in on a cache miss.
static ra8_err_t internal_check_ptrs(const longstrip_t *wt, const longstrip_cfg_t *cfg)
Reject a NULL engine, config, or any NULL callback / cache it carries.
static void internal_accumulate_coverage(const longstrip_t *wt, int32_t dst_y, uint16_t band_h, longstrip_render_stats_t *stats)
Add the on-screen row span of one blitted band to the coverage.
static int32_t internal_sat_add(int32_t a, int32_t b)
Saturating signed 32-bit add: pins at the int32 limits, never wraps.
static ra8_err_t internal_draw_band(longstrip_t *wt, uint16_t band, int32_t dst_x, longstrip_render_stats_t *stats)
Fetch, composite and release one visible band; update stats.
ra8_err_t longstrip_scroll_by(longstrip_t *wt, int32_t delta)
Scroll by a signed pixel delta (a finger drag), clamping at the ends.
static bool internal_at_bottom(const longstrip_t *wt)
Report whether the viewport is pinned at the bottom of the strip.
ra8_err_t longstrip_visible_bands(const longstrip_t *wt, int32_t scroll_y, uint16_t *out_first, uint16_t *out_last)
Compute the inclusive visible band range for a scroll position.
wt_consts_t
Fixed engine constants (no magic numbers).
@ k_wt_tile_x
Longstrip band column index (single column).
@ k_wt_zoom
Native zoom / mip level.
@ k_wt_fling_num
Velocity retained per tick (numerator).
@ k_wt_fling_den
Velocity retention denominator.
int32_t longstrip_clamp_scroll(const longstrip_t *wt, int32_t y)
Clamp a candidate scroll position to the strip's legal range.
ra8_err_t longstrip_render(longstrip_t *wt, longstrip_render_stats_t *stats)
Composite every visible band at the current scroll position.
ra8_err_t longstrip_set_viewport(longstrip_t *wt, uint16_t viewport_w, uint16_t viewport_h)
Resize the viewport of an open strip and re-derive the scroll clamp.
ra8_err_t longstrip_open(longstrip_t *wt, const longstrip_cfg_t *cfg)
Open a longstrip strip over a parsed + validated JOF atlas.
static void internal_warm_band(longstrip_t *wt, uint16_t band)
Fetch a band into the cache then release it (warm, no held pin).
static bool internal_at_top(const longstrip_t *wt)
Report whether the viewport is pinned at the top of the strip.
ra8_err_t longstrip_fling(longstrip_t *wt, int32_t v0)
Start a momentum fling with initial velocity v0.
bool longstrip_tick(longstrip_t *wt)
Advance the fling one physics step (integer velocity + friction).
static void internal_bind(longstrip_t *wt, const longstrip_cfg_t *cfg, const jof_info_t *info)
Bind the parsed atlas geometry and config into the engine state.
ra8_err_t longstrip_band_at_y(const longstrip_t *wt, uint32_t y, uint16_t *out_band)
Report the band index containing canvas row y.
static int32_t internal_apply_friction(int32_t v)
Decay a velocity one friction step toward zero (magnitude down).
static bool internal_fling_should_stop(const longstrip_t *wt)
True when a fling has hit the boundary it is travelling toward.
Continuous vertical-scroll (longstrip / manhwa) reading mode over an JOF band-tile atlas (#289).
@ k_longstrip_max_prefetch
Max prefetch depth per call.
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Fixed-RAM-budget image-tile cache with LRU eviction (Layer 3b, #147).
ra8_err_t ra8_tile_cache_get(ra8_tile_cache_t *tc, const ra8_tile_key_t *key, ra8_tile_t *out_tile)
Get (and pin) the decoded tile for key.
ra8_err_t ra8_tile_cache_put(ra8_tile_cache_t *tc, const uint8_t *pixels)
Release one pin on a tile previously returned by ra8_tile_cache_get.
Parsed + validated geometry of one JOF atlas.
uint8_t bpp
Bytes per pixel (1, 3 or 4).
uint16_t tile_w
Tile width, pixels.
uint16_t width
Image width, pixels.
uint16_t tile_rows
Ceil(height / tile_h) tile rows.
uint16_t tile_h
Tile height, pixels.
uint16_t height
Image height, pixels.
One-shot configuration handed to longstrip_open.
void * pread_ctx
Context for pread.
ra8_tile_cache_t * cache
Band cache (decode-on-miss = JOF).
uint16_t viewport_h
On-screen viewport height, pixels.
uint32_t image_id
Tile-cache key namespace for strip.
uint16_t viewport_w
On-screen viewport width, pixels.
jof_pread_fn pread
Atlas backing read seam.
uint64_t atlas_size
Atlas byte length (for parse).
longstrip_blit_fn blit
Band composite sink.
void * blit_ctx
Context for blit.
Context binding a JOF atlas to a ra8_tile_cache decode-on-miss.
uint8_t * scratch
Deflate staging (codec 1 only).
void * pread_ctx
Context for pread.
jof_pread_fn pread
Atlas backing read seam.
jof_info_t info
Parsed atlas geometry.
uint32_t scratch_cap
Capacity of scratch.
Per-frame render accounting returned by longstrip_render.
uint16_t skipped
Visible bands that failed to composite.
uint32_t covered_rows
Viewport rows covered by the drawn bands.
uint16_t bands_drawn
Visible bands composited this frame.
Opened longstrip-strip scroll state (caller-owned; treat as private).
int32_t max_scroll
Clamp ceiling (>= 0).
ra8_tile_cache_t * cache
Band cache.
uint32_t canvas_w
Strip width, pixels (== info.width).
jof_info_t info
Parsed atlas geometry.
uint32_t canvas_h
Strip height, pixels (== info.height).
uint32_t image_id
Tile-cache key namespace.
uint16_t band_count
Bands (== info.tile_rows).
uint16_t viewport_h
Viewport height, pixels.
uint16_t viewport_w
Viewport width, pixels.
uint16_t band_h
Band height, pixels (== info.tile_h).
int32_t scroll_y
Viewport top on the canvas, clamped.
longstrip_blit_fn blit
Band composite sink.
int32_t velocity
Fling velocity, px/tick (signed).
void * blit_ctx
Context for blit.
Identifies one decoded image tile.
uint16_t tile_y
Tile row index (in tile units).
uint16_t tile_x
Tile column index (in tile units).
uint16_t zoom
Zoom / mip level (0 = native).
uint32_t image_id
Source image identifier.
A pinned view of a cached tile returned by ra8_tile_cache_get.
const uint8_t * pixels
Decoded tile pixels (cell payload).
uint16_t height
Decoded tile height in pixels.
uint16_t width
Decoded tile width in pixels.