41 "blue-noise mask must be mask_dim * mask_dim bytes");
43 "toroidal index bitmask must be mask_dim - 1");
103 uint8_t level = base;
106 level = (uint8_t)(level + 1U);
135 const uint32_t g = (uint32_t)level;
168 for (int32_t row = 0; row < h; ++row) {
169 for (int32_t col = 0; col < w; ++col) {
170 const uint32_t i = ((uint32_t)row * (uint32_t)w) + (uint32_t)col;
171 const uint8_t level =
174 if ((i & 1U) == 0U) {
177 out[byte_idx] = (uint8_t)(out[byte_idx] | level);
197 static const char*
const k_tag =
"ra8_gfx_dither";
202 if ((w <= 0) || (h <= 0)) {
207 const uint32_t n_pixels = (uint32_t)w * (uint32_t)h;
209 if (out_cap < n_bytes) {
225 if ((src ==
nullptr) || (w <= 0) || (h <= 0)) {
229 for (int32_t row = 0; row < h; ++row) {
230 for (int32_t col = 0; col < w; ++col) {
231 const uint8_t level =
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_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ 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.
ra8_err_t ra8_gfx_blit_gray8_dither(const uint8_t *src, int32_t w, int32_t h, int32_t dst_x, int32_t dst_y)
Blit a gray8 image into the bound framebuffer, blue-noise dithered.
static void internal_pack_tile(const uint8_t *src, int32_t w, int32_t h, int32_t ox, int32_t oy, uint8_t *out)
Dither a gray8 tile to packed 4-bpp nibbles, mask-phased at (ox, oy).
static uint32_t internal_mask_index(int32_t x, int32_t y)
Toroidal blue-noise mask index for absolute panel coordinate (x, y).
static uint8_t internal_quantise(uint8_t gray8, uint8_t thr)
Quantise a gray8 sample to a 4-bit level given its blue-noise threshold.
static uint32_t internal_level_to_color(uint8_t level)
Expand a 4-bit panel level to a 0x00RRGGBB gray colour.
uint8_t ra8_gfx_dither_gray4_level(uint8_t gray8, int32_t x, int32_t y)
Quantise one gray8 sample to a 4-bit panel level via the blue-noise mask.
ra8_err_t ra8_gfx_dither_gray8_to_gray4(const uint8_t *src, int32_t w, int32_t h, int32_t origin_x, int32_t origin_y, uint8_t *out, uint32_t out_cap, uint32_t *out_size)
Dither a gray8 tile to packed 4-bpp nibbles (panel-native), seamlessly.
Void-and-cluster blue-noise dithering: continuous-tone gray8 -> 16-level panel (#477).
@ k_ra8_gfx_dither_mask_len
Mask entry count (mask_dim * mask_dim).
@ k_ra8_gfx_dither_byte_levels
Threshold texture depth (mask range +1).
@ k_ra8_gfx_dither_nib_shift
High-nibble shift (packing + gray8 expand).
@ k_ra8_gfx_dither_ppb
Pixels packed per output byte.
@ k_ra8_gfx_dither_step
Palette step 255/15; also the 4->8 replicate.
@ k_ra8_gfx_dither_mask_index_mask
Toroidal index bitmask (mask_dim - 1).
@ k_ra8_gfx_dither_mask_dim
Blue-noise mask edge (power of two).
@ k_ra8_gfx_dither_rgb_r_shift
Red shift of the 0x00RRGGBB gray expand.
@ k_ra8_gfx_dither_rgb_g_shift
Green shift of the 0x00RRGGBB gray expand.
Void-and-cluster blue-noise threshold mask for the e-ink dither (#477).
static const uint8_t s_ra8_gfx_dither_mask[]
64x64 row-major blue-noise threshold texture (4096 bytes).
Module-private declarations shared across the ra8_gfx software rasteriser TUs.
ra8_gfx_state_t g_gfx_text_state
Single module-wide framebuffer binding shared by every ra8_gfx TU.
void priv_gfx_text_plot(int32_t x, int32_t y, uint32_t color)
Plot a single pixel with bounds checking against the active clip.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_error(tag, message)
RA8 log error.