ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
zoom_book.h File Reference

Bind a .rabook image-pool figure as a zoom source (#478). More...

#include <stdint.h>
#include "book.h"
#include "book_paged.h"
#include "ra8_err.h"
#include "zoom.h"
Include dependency graph for zoom_book.h:

Go to the source code of this file.

Data Structures

struct  zoom_book_src_t
 One .rabook raster figure, ready to be magnified. More...

Functions

ra8_err_t zoom_book_src_init (zoom_book_src_t *bs, const book_src_t *src, uint32_t img_idx)
 Look up one image in a book source and prepare it for magnification.
ra8_err_t zoom_book_src_bind (zoom_book_src_t *bs, zoom_source_t *out)
 Present a bound figure to the zoom engine as a zoom_source_t.
ra8_err_t zoom_book_read (void *ctx, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t *out, uint32_t out_stride)
 zoom_read_fn over a .rabook image pool.

Detailed Description

Bind a .rabook image-pool figure as a zoom source (#478).

The EPUB half of the tap-to-zoom viewer. A reflow page lays a figure out at whatever size the column allows; tapping it should open the retained image, not the laid-out thumbnail, and let the reader magnify into it – which is the whole reason .rabook import stopped downscaling (#210-213, #476).

This adapter is deliberately thin, because the work is already done: book_src_image_rect owns the image-pool addressing contract, serves both retained depths (4 bpp packed and 8 bpp continuous tone) as gray8, and faults a paged book frame-by-frame so a figure larger than RAM still reads. All this file does is present that call as a zoom_read_fn and remember the two things the engine needs – the descriptor and its extent.

The TU compiles to nothing when book_paged.h is not on the include path, so an app that only magnifies tiled comics does not drag book in.

Note
Not thread-safe; inherits the (non-)reentrancy of the bound book source.
See also
zoom.h The viewport engine this feeds.
zoom_tiles.h The tiled-atlas source, for comics and manga.
Since
0.1.0

Definition in file zoom_book.h.

Function Documentation

◆ zoom_book_read()

ra8_err_t zoom_book_read ( void * ctx,
uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h,
uint8_t * out,
uint32_t out_stride )
nodiscard

zoom_read_fn over a .rabook image pool.

Bound by zoom_book_src_bind; not normally called directly. It forwards to book_src_image_rect, which is where the gray4 nibble parity, the gray8 passthrough and the bounded paged reads all live.

Parameters
[in]ctxThe zoom_book_src_t binding.
[in]xRectangle left edge, source pixels.
[in]yRectangle top edge, source pixels.
[in]wRectangle width, source pixels (> 0).
[in]hRectangle height, source pixels (> 0).
[out]outgray8 destination of at least out_stride * h bytes.
[in]out_strideBytes between successive output rows (>= w).
Returns
ra8_err_t Error code.
Return values
k_ra8_okThe rectangle was written as gray8.
k_ra8_err_null_ptrctx or out is NULL.
k_ra8_err_*Propagated verbatim from book_src_image_rect.
Precondition
ctx is a bound zoom_book_src_t.
The rectangle lies inside the bound image.
Postcondition
On k_ra8_ok every output pixel is the gray8 value of its source pixel.
On failure out content is unspecified.
Note
Not thread-safe.
See also
book_src_image_rect
Since
0.1.0

◆ zoom_book_src_bind()

ra8_err_t zoom_book_src_bind ( zoom_book_src_t * bs,
zoom_source_t * out )
nodiscard

Present a bound figure to the zoom engine as a zoom_source_t.

Parameters
[in]bsBinding populated by zoom_book_src_init.
[out]outSource descriptor to fill.
Returns
ra8_err_t Error code.
Return values
k_ra8_okout is ready to hand to zoom_view_open.
k_ra8_err_null_ptrbs, out, or bs->src is NULL.
k_ra8_err_invalid_argThe bound extent is unusable (zero or too large).
Precondition
bs was populated by zoom_book_src_init.
bs outlives every view bound to out.
Postcondition
On k_ra8_ok out->ctx == bs and the extent equals the image's.
bs is not modified.
Note
Not thread-safe.
See also
zoom_view_open
Since
0.1.0

◆ zoom_book_src_init()

ra8_err_t zoom_book_src_init ( zoom_book_src_t * bs,
const book_src_t * src,
uint32_t img_idx )
nodiscard

Look up one image in a book source and prepare it for magnification.

Reads the descriptor once, and fails closed on anything the viewer cannot magnify: a vector (SVG) entry, or a zero extent. A raster is accepted at either retained depth – book_src_image_rect normalises both to gray8, which is the only depth the engine reads.

Parameters
[out]bsBinding to populate.
[in]srcBook source, already bound resident or paged.
[in]img_idxImage index, < src->hdr.image_count.
Returns
ra8_err_t Error code.
Return values
k_ra8_okbs describes a magnifiable raster.
k_ra8_err_null_ptrbs or src is NULL.
k_ra8_err_not_supportedThe entry is SVG, not a raster.
k_ra8_err_invalid_argThe entry has a zero width or height.
k_ra8_err_*Propagated from book_src_image.
Precondition
src was populated by book_src_resident() / book_src_paged().
bs addresses writable storage for one zoom_book_src_t.
Postcondition
On k_ra8_ok bs->src == src and bs->img is the descriptor copy.
On any error bs is not left partially bound.
Note
Not thread-safe.
See also
zoom_book_src_bind
Since
0.1.0