|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Tap-to-zoom demo scene: tiled 12 MP page, zoom viewport, loupe (#478). More...
#include <stdint.h>#include "ra8_err.h"#include "ra8_tile_cache.h"#include "ra8_ui.h"#include "zoom.h"#include "zoom_tiles.h"Go to the source code of this file.
Data Structures | |
| struct | ez_scene_t |
| The whole demo: one tiled page, one zoom viewport, one loupe. More... | |
| struct | ez_scene_cfg_t |
| Everything ez_scene_init needs: storage and framebuffer geometry. More... | |
| struct | ez_present_t |
| What the scene asks the panel to flush, and how well. More... | |
| struct | ez_selftest_t |
| Deterministic boot self-check results (the app's golden numbers). More... | |
Enumerations | |
| enum | ez_page_t : uint32_t { k_ez_page_w = 4096U , k_ez_page_h = 3072U , k_ez_tile_edge = 256U , k_ez_image_id = 1U } |
| The procedural source page and its tiling. More... | |
| enum | ez_layout_t : uint16_t { k_ez_status_h = 48U , k_ez_lens_edge = 320U , k_ez_lens_border = 3U , k_ez_edge_band = 176U , k_ez_ind_block = 20U , k_ez_ind_gap = 8U } |
| Panel layout: status bar, content viewport and the loupe box. More... | |
| enum | ez_scale_t : uint8_t { k_ez_page_scale_max = 4U , k_ez_lens_scale_min = 4U , k_ez_lens_scale_max = 8U } |
| The magnification ladders the page view and the loupe walk. More... | |
| enum | ez_zone_t : uint8_t { k_ez_zone_none = 0U , k_ez_zone_pan_left = 1U , k_ez_zone_pan_right = 2U , k_ez_zone_pan_up = 3U , k_ez_zone_pan_down = 4U , k_ez_zone_zoom = 5U , k_ez_zone_lens = 6U , k_ez_zone_toggle = 7U } |
| Tap zones of the demo's discrete touch scheme. More... | |
| enum | ez_cache_t : uint32_t { k_ez_cell_bytes = k_ez_tile_edge * k_ez_tile_edge , k_ez_view_cols = 6U , k_ez_view_rows = 4U , k_ez_cells = (k_ez_view_cols + 1U) * (k_ez_view_rows + 1U) , k_ez_buckets = 64U , k_ez_cell_budget_bytes = 4U * 1024U * 1024U , k_ez_prefetch_max = 6U } |
| Tile-cache budget, DERIVED from the viewport and tile geometry (#338). More... | |
| enum | ez_scratch_t : uint32_t { k_ez_row_bytes = 1024U , k_ez_strip_bytes = 1024U * 16U , k_ez_packed_bytes = (1024U * 16U) / 2U } |
| The zoom engine's entire memory footprint, in bytes. More... | |
Functions | |
| uint8_t | ez_page_sample (uint32_t x, uint32_t y) |
| Sample the procedural full-resolution page at one pixel. | |
| ra8_err_t | ez_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) |
| ra8_tile_decode_fn that materialises one page tile from the sampler. | |
| ra8_ui_rect_t | ez_content_rect (int32_t fb_w, int32_t fb_h) |
| The content rectangle: the panel less the status bar. | |
| ra8_err_t | ez_scene_init (ez_scene_t *s, const ez_scene_cfg_t *cfg) |
| Wire the tile cache, the tiled source and both viewports. | |
| ez_zone_t | ez_zone_hit (const ez_scene_t *s, int32_t x, int32_t y) |
| Classify a tap by the zone it lands in. | |
| bool | ez_scene_tap (ez_scene_t *s, int32_t x, int32_t y, uint32_t now_ms) |
| Apply a tap to the scene. | |
| ra8_err_t | ez_scene_render (ez_scene_t *s) |
| Repaint the content area, the loupe (when open) and the status bar. | |
| ra8_err_t | ez_scene_present (ez_scene_t *s, ez_present_t *out) |
| Take the pending flush plan for whichever view changed. | |
| bool | ez_scene_tick (ez_scene_t *s, uint32_t now_ms) |
| Advance both views' settle timers; report whether a repaint is due. | |
| ra8_err_t | ez_scene_prefetch (ez_scene_t *s, zoom_pan_t dir, uint16_t *out_warmed) |
| Warm the tiles one pan step ahead of the page viewport. | |
| ra8_err_t | ez_scene_selftest (ez_scene_t *s, ez_selftest_t *out) |
| Drive the scene through the scripted boot self-check. | |
| uint32_t | ez_fnv1a (const void *buf, uint32_t len) |
| FNV-1a-32 over a byte range (the framebuffer hash). | |
Tap-to-zoom demo scene: tiled 12 MP page, zoom viewport, loupe (#478).
The presentation model of the ereader_zoom app, kept out of main.c so the host twin (apps/board/stand_alone/ereader/tests/src/test_app_ereader_zoom.c) compiles and drives the same code the board runs. Nothing here touches MMIO: it is zoom over ra8_tile_cache over a procedural page, painting through ra8_gfx.
Definition in file ez_scene.h.
| enum ez_cache_t : uint32_t |
Tile-cache budget, DERIVED from the viewport and tile geometry (#338).
At 1:1 the content viewport straddles at most k_ez_view_cols x k_ez_view_rows tiles; sizing the cache to that frame plus one tile of margin on each axis means a single pan step re-decodes only the newly exposed row or column and never a tile still on screen. The static_asserts in ez_scene.c fail the build if the derivation is ever undercut or grows past its SDRAM budget.
Definition at line 166 of file ez_scene.h.
| enum ez_layout_t : uint16_t |
Panel layout: status bar, content viewport and the loupe box.
The content viewport is the panel less the status bar; the loupe is a square box centred in it. Both are compile-time constants because the tile-cache budget below is derived from them.
Definition at line 94 of file ez_scene.h.
| enum ez_page_t : uint32_t |
The procedural source page and its tiling.
4096x3072 gray8 is 12 MiB – deliberately far past what the part can hold – so "only the visible tiles are resident" is the only way the app can work at all. Every dimension is a power of two so the sampler is shifts and masks rather than divides, which matters under the instruction-accurate emulator.
| Enumerator | |
|---|---|
| k_ez_page_w | Source page width, pixels. |
| k_ez_page_h | Source page height, pixels. |
| k_ez_tile_edge | Tile edge, pixels (gray8 => 64 KiB/tile). |
| k_ez_image_id | Tile-cache key image id for the page. |
Definition at line 73 of file ez_scene.h.
| enum ez_scale_t : uint8_t |
The magnification ladders the page view and the loupe walk.
The page ladder tops out at 4x – past that a 1024-wide viewport shows fewer than 256 source pixels and the reader has lost all context. The loupe starts where the page ladder ends because that is its whole purpose: a small window magnified further than the page around it.
| Enumerator | |
|---|---|
| k_ez_page_scale_max | Page-view ladder ceiling. |
| k_ez_lens_scale_min | Loupe ladder floor. |
| k_ez_lens_scale_max | Loupe ladder ceiling. |
Definition at line 118 of file ez_scene.h.
| enum ez_scratch_t : uint32_t |
The zoom engine's entire memory footprint, in bytes.
Sized for the widest viewport (the content area), and shared by both views because only one renders at a time. The strip height falls out of the division: 16384 / 1024 = 16 rows for the page view, capped at k_zoom_strip_rows_max = 32 for the narrower loupe. This is the whole cost of the viewer – 25 KiB of SRAM – because the composite never holds the visible window.
| Enumerator | |
|---|---|
| k_ez_row_bytes | One source row at the widest viewport. |
| k_ez_strip_bytes | gray8 destination strip (16 rows). |
| k_ez_packed_bytes | The strip packed to 4 bpp. |
Definition at line 195 of file ez_scene.h.
| enum ez_zone_t : uint8_t |
Tap zones of the demo's discrete touch scheme.
The GT911 path reports contacts, not drags, so navigation is tap bands rather than a fling – the same scheme the sibling comic and manga demos use.
Definition at line 138 of file ez_scene.h.
|
nodiscard |
The content rectangle: the panel less the status bar.
| [in] | fb_w | Framebuffer width, pixels. |
| [in] | fb_h | Framebuffer height, pixels. |
| {0, k_ez_status_h, fb_w, fb_h - k_ez_status_h} | Always. |
fb_h exceeds k_ez_status_h. fb_w is positive. Definition at line 232 of file ez_scene.c.
References k_ez_status_h.
Referenced by ez_scene_init(), and main().
|
nodiscard |
FNV-1a-32 over a byte range (the framebuffer hash).
| [in] | buf | Bytes to hash (NULL hashes nothing). |
| [in] | len | Byte count. |
| 2166136261 | buf is NULL or len is 0 (the FNV offset basis). |
| digest | Otherwise, the hash of the range. |
buf addresses at least len readable bytes. Definition at line 712 of file ez_scene.c.
References k_ez_fnv_offset, and k_ez_fnv_prime.
Referenced by ez_render_and_hash().
|
nodiscard |
Sample the procedural full-resolution page at one pixel.
A page of "text": a repeating smooth gradient (which only a dither can render on a 16-level panel without banding) overlaid with 3 px rules broken into word-like runs (which only full-resolution magnification can resolve). Every operation is a shift or a mask, so decoding a 256x256 tile is cheap enough to stay inside the emulator's boot budget.
| [in] | x | Source column, < k_ez_page_w. |
| [in] | y | Source row, < k_ez_page_h. |
| ink | The pixel falls on an inked rule (a dark constant). |
| background | Otherwise, the gradient value at (x, y). |
x and y are inside the page (the caller is the tile decoder). Definition at line 158 of file ez_scene.c.
References k_ez_bg_lo, k_ez_grad_mask, k_ez_grad_shift, k_ez_grad_wrap, k_ez_ink, k_ez_rule_mask, k_ez_rule_thick, k_ez_word_blank, k_ez_word_mask, and k_ez_word_shift.
Referenced by ez_fill_tile().
|
nodiscard |
Wire the tile cache, the tiled source and both viewports.
| [out] | s | Scene to populate. |
| [in] | cfg | Borrowed storage and framebuffer geometry. |
| k_ra8_ok | The scene is ready to render. |
| k_ra8_err_null_ptr | s, cfg, or a required storage pointer is NULL. |
| k_ra8_err_invalid_arg | The framebuffer is too small for the layout. |
| k_ra8_err_* | Propagated from the cache or the zoom engine. |
cfg outlives the scene. Definition at line 430 of file ez_scene.c.
References ez_scene_t::content, ez_bind_page(), ez_cfg_ptrs_ok(), ez_content_rect(), ez_open_views(), ez_scene_cfg_t::fb, ez_scene_t::fb, ez_scene_cfg_t::fb_bytes, ez_scene_t::fb_bytes, ez_scene_cfg_t::fb_h, ez_scene_t::fb_h, ez_scene_cfg_t::fb_w, ez_scene_t::fb_w, k_ez_lens_edge, k_ez_status_h, k_ra8_err_invalid_arg, ez_scene_t::lens_on, RA8_CHECK_NULL_PTR, ra8_log_error, RA8_RETURN_ON_ERROR, and s_tag.
Referenced by ez_setup_scene().
|
nodiscard |
Warm the tiles one pan step ahead of the page viewport.
| [in,out] | s | Initialised scene. |
| [in] | dir | Direction of travel. |
| [out] | out_warmed | Tiles warmed (may be NULL). |
| k_ra8_ok | The read-ahead sweep ran. |
| k_ra8_err_null_ptr | s is NULL. |
| k_ra8_err_* | Propagated from zoom_tiles_prefetch. |
s was initialised by ez_scene_init. Definition at line 705 of file ez_scene.c.
References zoom_tile_src_t::cache, k_ez_prefetch_max, ez_scene_t::page, RA8_CHECK_NULL_PTR, s_tag, ez_scene_t::tiles, and zoom_tiles_prefetch().
Referenced by ez_apply_pan(), and ez_selftest_pan().
|
nodiscard |
Take the pending flush plan for whichever view changed.
A page change dirties the whole content rectangle; a loupe-only change dirties only the lens box, which is the partial-update case this demo exists to show. A view that owes nothing contributes nothing, so an idle reader never refreshes the panel.
| [in,out] | s | Initialised scene. |
| [out] | out | Receives the plan; out->present is false when none is owed. |
| k_ra8_ok | out holds the plan. |
| k_ra8_err_null_ptr | s or out is NULL. |
| k_ra8_err_* | Propagated from zoom_view_present. |
s was initialised by ez_scene_init. Definition at line 677 of file ez_scene.c.
References ez_choose_plan(), k_ra8_ok, ez_scene_t::lens, ez_scene_t::page, RA8_CHECK_NULL_PTR, RA8_RETURN_ON_ERROR, s_tag, and zoom_view_present().
Referenced by ez_redraw(), and ez_render_and_hash().
|
nodiscard |
Repaint the content area, the loupe (when open) and the status bar.
| [in,out] | s | Initialised scene. |
| k_ra8_ok | The framebuffer holds the current scene. |
| k_ra8_err_null_ptr | s is NULL. |
| k_ra8_err_* | Propagated from zoom_view_render or ra8_gfx. |
s was initialised by ez_scene_init. Definition at line 624 of file ez_scene.c.
References ez_scene_t::content, ez_draw_lens_chrome(), ez_draw_status(), ez_lens_rect(), ez_scene_t::lens, ez_scene_t::lens_on, ez_scene_t::page, RA8_CHECK_NULL_PTR, RA8_RETURN_ON_ERROR, zoom_source_t::read, s_tag, ez_scene_t::src, and zoom_view_render().
Referenced by ez_redraw(), and ez_render_and_hash().
|
nodiscard |
Drive the scene through the scripted boot self-check.
Four states – opening 1:1, one right-pan step, 2x about a fixed panel point, and the 4x loupe – each rendered and hashed. This is the app's golden: apps/board/stand_alone/ereader/tests/src/test_app_ereader_zoom.c calls this same function over a host framebuffer and asserts the identical numbers, and hil.conf pins them for the headless emulator gate.
| [in,out] | s | Initialised scene (left in the loupe state on return). |
| [out] | out | Receives the four hashes and the cache counters. |
| k_ra8_ok | The sequence ran and out is populated. |
| k_ra8_err_null_ptr | s or out is NULL. |
| k_ra8_err_* | Propagated from a render or a viewport call. |
s was freshly initialised (the counters start from zero). out reflects the whole sequence.Definition at line 861 of file ez_scene.c.
References ez_scene_t::cache, ez_selftest_t::evictions, ez_selftest_stages(), ez_selftest_t::hits, ez_selftest_t::misses, RA8_CHECK_NULL_PTR, RA8_RETURN_ON_ERROR, ra8_tile_cache_stats(), and s_tag.
Referenced by main().
|
nodiscard |
Apply a tap to the scene.
| [in,out] | s | Initialised scene. |
| [in] | x | Framebuffer column of the tap. |
| [in] | y | Framebuffer row of the tap. |
| [in] | now_ms | Current millisecond timestamp. |
| true | The scene changed; re-render and present. |
| false | The tap hit nothing, or clamped to no movement. |
s was initialised by ez_scene_init (NULL answers false). now_ms comes from a monotonic millisecond source. Definition at line 531 of file ez_scene.c.
References ez_apply_pan(), ez_zone_hit(), k_ez_lens_scale_max, k_ez_lens_scale_min, k_ez_page_scale_max, k_ez_zone_lens, k_ez_zone_toggle, k_ez_zone_zoom, k_ra8_ok, k_zoom_scale_min, ez_scene_t::lens, ez_scene_t::lens_on, ez_scene_t::page, zoom_view_t::scale, zoom_scale_cycle(), zoom_view_invalidate(), and zoom_view_set_scale().
Referenced by ez_poll_touch().
| bool ez_scene_tick | ( | ez_scene_t * | s, |
| uint32_t | now_ms ) |
Advance both views' settle timers; report whether a repaint is due.
| [in,out] | s | Initialised scene. |
| [in] | now_ms | Current millisecond timestamp. |
| true | Re-render and present. |
| false | Nothing to do this tick. |
s was initialised by ez_scene_init (NULL answers false). now_ms comes from a monotonic millisecond source. Definition at line 689 of file ez_scene.c.
References ez_scene_t::lens, ez_scene_t::lens_on, ez_scene_t::page, and zoom_view_tick().
Referenced by main().
|
nodiscard |
ra8_tile_decode_fn that materialises one page tile from the sampler.
The decode-on-miss seam. A real reader inflates a JOF tile here; the demo computes it, which keeps the app free of a multi-megabyte baked fixture while exercising the identical cache, eviction and residency behaviour.
| [in] | ctx | Unused (the page is a pure function). |
| [in] | key | The tile being decoded. |
| [out] | cell | Destination cell, cell_bytes writable bytes. |
| [in] | cell_bytes | Capacity of cell. |
| [out] | out_w | Receives the decoded tile width. |
| [out] | out_h | Receives the decoded tile height. |
| k_ra8_ok | The tile was written. |
| k_ra8_err_null_ptr | key, cell, out_w or out_h is NULL. |
| k_ra8_err_out_of_range | The key names a tile outside the page. |
| k_ra8_err_no_mem | cell_bytes is smaller than one tile. |
cell addresses at least cell_bytes writable bytes. cell); otherwise pure. Definition at line 204 of file ez_scene.c.
References ez_fill_tile(), k_ez_cell_bytes, k_ez_page_h, k_ez_page_w, k_ez_tile_edge, k_ra8_err_no_mem, k_ra8_err_out_of_range, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_error, s_tag, ra8_tile_key_t::tile_x, and ra8_tile_key_t::tile_y.
Referenced by ez_bind_page().
|
nodiscard |
Classify a tap by the zone it lands in.
| [in] | s | Initialised scene. |
| [in] | x | Framebuffer column of the tap. |
| [in] | y | Framebuffer row of the tap. |
| k_ez_zone_none | The point is outside every zone. |
| a zone | Otherwise, the zone that owns the point. |
s was initialised by ez_scene_init (NULL answers none). s; thread-safe. Definition at line 451 of file ez_scene.c.
References ez_scene_t::content, ez_lens_rect(), ra8_ui_rect_t::h, k_ez_edge_band, k_ez_status_h, k_ez_zone_lens, k_ez_zone_none, k_ez_zone_pan_down, k_ez_zone_pan_left, k_ez_zone_pan_right, k_ez_zone_pan_up, k_ez_zone_toggle, k_ez_zone_zoom, ez_scene_t::lens_on, ra8_ui_rect_contains(), ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.
Referenced by ez_scene_tap().