ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
zoom_book.c
Go to the documentation of this file.
1
23
24#ifdef __has_include
25#if __has_include("book_paged.h")
52#define ZOOM_HAVE_BOOK
53#endif
54#endif
55
56#ifdef ZOOM_HAVE_BOOK
57
58#include "zoom_book.h"
59
60#include <stdint.h>
61
62#include "book.h"
63#include "book_paged.h"
64#include "ra8_check.h"
65#include "ra8_err.h"
66#include "zoom.h"
67
69static const char* const s_tag = "zoom_book";
70
71ra8_err_t zoom_book_src_init(zoom_book_src_t* bs, const book_src_t* src, uint32_t img_idx)
72{
73 RA8_CHECK_NULL_PTR(bs, s_tag, "binding must not be nullptr");
74 RA8_CHECK_NULL_PTR(src, s_tag, "book source must not be nullptr");
75 book_image_t img = {};
76 RA8_RETURN_ON_ERROR(book_src_image(src, img_idx, &img), s_tag, "image descriptor read");
77 if (img.format != (uint8_t)k_book_image_gray4) {
78 ra8_log_error(s_tag, "vector images are not magnifiable by the raster viewer");
80 }
81 /* Decision: a raster with no extent cannot be magnified (2 conditions). */
82 if ((img.width == 0U) || (img.height == 0U)) {
83 ra8_log_error(s_tag, "image descriptor has a zero extent");
85 }
86 bs->src = src;
87 bs->img = img;
88 return k_ra8_ok;
89}
90
92{
93 RA8_CHECK_NULL_PTR(bs, s_tag, "binding must not be nullptr");
94 RA8_CHECK_NULL_PTR(out, s_tag, "source out must not be nullptr");
95 RA8_CHECK_NULL_PTR(bs->src, s_tag, "binding was never initialised");
96 return zoom_source_init(out,
98 bs,
99 (uint32_t)bs->img.width,
100 (uint32_t)bs->img.height);
101}
102
103ra8_err_t zoom_book_read(void* ctx,
104 uint32_t x,
105 uint32_t y,
106 uint32_t w,
107 uint32_t h,
108 uint8_t* out,
109 uint32_t out_stride)
110{
111 RA8_CHECK_NULL_PTR(ctx, s_tag, "read ctx must not be nullptr");
112 RA8_CHECK_NULL_PTR(out, s_tag, "read destination must not be nullptr");
113 const zoom_book_src_t* bs = (const zoom_book_src_t*)ctx;
114 RA8_CHECK_NULL_PTR(bs->src, s_tag, "binding was never initialised");
115 return book_src_image_rect(bs->src, &bs->img, x, y, w, h, out, out_stride);
116}
117
118#endif /* ZOOM_HAVE_BOOK */
Flat, execute-in-place container for a build-time "compiled" e-book.
@ k_book_image_gray4
4bpp gray, 2px/byte; pixel (x,y) is at flat index y*width + x.
Definition book.h:175
Paged (demand-fetched) accessor mode for book over ra8_vmem (#163).
ra8_err_t book_src_image_rect(const book_src_t *src, const book_image_t *img, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t *out, uint32_t out_stride)
Read a sub-rectangle of a raster image (4bpp or 8bpp) as gray8, row by row.
Definition book_paged.c:325
ra8_err_t book_src_image(const book_src_t *src, uint32_t idx, book_image_t *out_img)
Read one image descriptor out of a book source (resident or paged).
Definition book_paged.c:314
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
Definition ra8_check.h:184
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Definition ra8_check.h:243
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.
Definition ra8_err.h:180
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
#define ra8_log_error(tag, message)
RA8 log error.
Definition ra8_log.h:335
Descriptor for one transcoded image in the image pool.
Definition book.h:354
uint16_t height
Pixel height.
Definition book.h:357
uint8_t format
book_image_format_t.
Definition book.h:358
uint16_t width
Pixel width.
Definition book.h:356
A book data source: resident (zero-copy) or paged (demand-fetched).
Definition book_paged.h:69
One .rabook raster figure, ready to be magnified.
Definition zoom_book.h:63
const book_src_t * src
Borrowed book source (resident or paged).
Definition zoom_book.h:64
book_image_t img
Copy of the image descriptor being zoomed.
Definition zoom_book.h:65
A magnifiable full-resolution image behind the gray8 sub-rect seam.
Definition zoom.h:296
Tap-to-zoom image viewer: viewport state machine + tiled magnifying render (#478).
ra8_err_t zoom_source_init(zoom_source_t *out, zoom_read_fn read, void *ctx, uint32_t width, uint32_t height)
Bind a gray8 sub-rectangle reader and its extent as a magnifiable source.
Definition zoom.c:375
Bind a .rabook image-pool figure as a zoom source (#478).
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.
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.