|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Glyph-cell blitting and text rendering for the ra8_gfx software rasteriser. More...
#include <stddef.h>#include <stdint.h>#include "ra8_err.h"#include "ra8_gfx.h"#include "ra8_gfx_internal.h"Go to the source code of this file.
Enumerations | |
| enum | ra8_gfx_glyph_bits_t : uint8_t { k_glyph_bits_per_byte = 8 , k_glyph_msb_index = 7 } |
| Constants for monochrome glyph bit extraction. More... | |
| enum | ra8_gfx_color_masks_t : uint32_t { k_mask_byte = 0xFFU } |
| Per-channel masks for colour conversion. More... | |
| enum | ra8_gfx_byte_idx_t : uint8_t { k_idx_r = 0 , k_idx_g = 1 } |
| Per-byte indices for RGB888 packing. More... | |
Functions | |
| static void | internal_blit_glyph_565 (int32_t x, int32_t y, int32_t gw, int32_t gh, uint32_t row_bytes, const uint8_t *gd, uint32_t fg, uint32_t bg) |
| Blit one 1-bpp glyph cell into an RGB565 framebuffer, clipped on screen. | |
| static void | internal_render_glyph (int32_t x, int32_t y, const ra8_gfx_font_t *font, uint8_t cp, uint32_t fg, uint32_t bg) |
| Render a single glyph at (x,y). | |
| ra8_err_t | ra8_gfx_text_out (int32_t x, int32_t y, const char *str, const ra8_gfx_font_t *font, uint32_t fg_color, uint32_t bg_color) |
| Render a NUL-terminated ASCII string. | |
| ra8_err_t | ra8_gfx_text_size (const char *str, const ra8_gfx_font_t *font, uint32_t *out_w, uint32_t *out_h) |
| Compute rendered pixel dimensions of a string. | |
Glyph-cell blitting and text rendering for the ra8_gfx software rasteriser.
Holds the text sub-responsibility of the software pixel-pusher: the 1-bpp glyph-cell blitters and the public text entry points (ra8_gfx_text_out, ra8_gfx_text_size). These share the single framebuffer binding (g_gfx_text_state) and the low-level packers/plotters with the core rasteriser TU (ra8_gfx_text.c) via ra8_gfx_internal.h.
Definition in file ra8_gfx_text_glyph.c.
| enum ra8_gfx_byte_idx_t : uint8_t |
Per-byte indices for RGB888 packing.
| Enumerator | |
|---|---|
| k_idx_r | Index r. |
| k_idx_g | Index g. |
Definition at line 45 of file ra8_gfx_text_glyph.c.
| enum ra8_gfx_color_masks_t : uint32_t |
Per-channel masks for colour conversion.
| Enumerator | |
|---|---|
| k_mask_byte | Mask byte. |
Definition at line 37 of file ra8_gfx_text_glyph.c.
| enum ra8_gfx_glyph_bits_t : uint8_t |
Constants for monochrome glyph bit extraction.
| Enumerator | |
|---|---|
| k_glyph_bits_per_byte | Glyph bits per byte. |
| k_glyph_msb_index | Glyph msb index. |
Definition at line 28 of file ra8_gfx_text_glyph.c.
|
static |
Blit one 1-bpp glyph cell into an RGB565 framebuffer, clipped on screen.
The foreground and background colours are packed to RGB565 once, then each visible cell pixel stores the two pre-packed bytes directly – so the per-glyph colour packing (priv_gfx_text_pack_565 + per-channel extraction) and the per-pixel clip happen once each instead of once per pixel. The cell is clipped to the framebuffer up front (the same in-bounds set priv_gfx_text_plot would have written), and every on/off bit maps to the same colour, so the result is byte-identical to the per-pixel priv_gfx_text_plot path. The full cell is painted (foreground for set bits, background for clear bits), matching the per-pixel path's opaque cell.
| [in] | x | Glyph top-left x in framebuffer pixels. |
| [in] | y | Glyph top-left y in framebuffer pixels. |
| [in] | gw | Glyph cell width in pixels. |
| [in] | gh | Glyph cell height in pixels. |
| [in] | row_bytes | Bytes per glyph row in gd. |
| [in] | gd | Packed 1-bpp glyph bitmap (MSB-first within each byte). |
| [in] | fg | Foreground 32-bit colour (applied to set bits). |
| [in] | bg | Background 32-bit colour (applied to clear bits). |
gd addresses at least gh*row_bytes bytes. Definition at line 79 of file ra8_gfx_text_glyph.c.
References g_gfx_text_state, k_glyph_bits_per_byte, k_glyph_msb_index, k_idx_g, k_idx_r, k_mask_byte, and priv_gfx_text_pack_565().
Referenced by internal_render_glyph().
|
static |
Render a single glyph at (x,y).
See implementation.
| [in] | x | See implementation. |
| [in] | y | See implementation. |
| [in] | font | See implementation. |
| [in] | cp | See implementation. |
| [in] | fg | See implementation. |
| [in] | bg | See implementation. |
Definition at line 145 of file ra8_gfx_text_glyph.c.
References ra8_gfx_font_t::bytes_per_glyph, ra8_gfx_font_t::first_codepoint, g_gfx_text_state, ra8_gfx_font_t::glyph_data, ra8_gfx_font_t::glyph_height, ra8_gfx_font_t::glyph_width, internal_blit_glyph_565(), k_glyph_bits_per_byte, k_glyph_msb_index, k_ra8_gfx_format_rgb565, ra8_gfx_font_t::last_codepoint, and priv_gfx_text_plot().
Referenced by ra8_gfx_text_out().
|
nodiscard |
Render a NUL-terminated ASCII string.
| [in] | x,y | Top-left of the first glyph. |
| [in] | str | NUL-terminated ASCII string (NULL not allowed). |
| [in] | font | Font descriptor (NULL not allowed). |
| [in] | fg_color | Foreground colour. |
| [in] | bg_color | Background colour. |
| k_ra8_ok | Rendered. |
| k_ra8_err_null_ptr | str or font was NULL. |
| k_ra8_err_not_initialized | ra8_gfx_init() was not called. |
Definition at line 182 of file ra8_gfx_text_glyph.c.
References g_gfx_text_state, ra8_gfx_font_t::glyph_width, internal_render_glyph(), k_ra8_err_not_initialized, k_ra8_err_null_ptr, k_ra8_gfx_max_dim, and k_ra8_ok.
Referenced by ch_render(), cm_draw_status_bar(), er_draw_key_label(), er_nag_render(), er_text_left(), ls_text(), mg_render_status(), render_page(), sh_comic_render(), sh_cover_button(), sh_cover_render(), sh_draw_card(), sh_loading_overlay(), sh_reader_render(), sh_titlebar(), sh_toc_render(), wc_footer_render(), wc_status_render(), wc_tile_render(), wd_content_render(), wd_status_render(), wd_tabbar_render(), wd_text(), and wk_paint_text().
|
nodiscard |
Compute rendered pixel dimensions of a string.
| [in] | str | ASCII string. |
| [in] | font | Font descriptor. |
| [out] | out_w | Receives total pixel width. |
| [out] | out_h | Receives total pixel height (font glyph height). |
| k_ra8_ok | Measured. |
| k_ra8_err_null_ptr | Any argument was NULL. |
Definition at line 211 of file ra8_gfx_text_glyph.c.
References ra8_gfx_font_t::glyph_height, ra8_gfx_font_t::glyph_width, k_ra8_err_null_ptr, k_ra8_gfx_max_dim, and k_ra8_ok.
Referenced by er_text_right(), ls_text(), wd_size(), and wk_paint_size().