29typedef enum : uint32_t {
39typedef enum : uint8_t {
50typedef enum : uint32_t {
58typedef enum : uint8_t {
70typedef enum : uint8_t {
84typedef enum : uint8_t {
90typedef enum : uint8_t {
212 return (uint8_t)format;
262 uint8_t* p = dst + (y * stride) + (x * (
size_t)
internal_bpp(format));
308 const uint8_t* p = src + (y * stride) + (x * (
size_t)
internal_bpp(format));
386 for (
size_t i = 0; i < count; i++) {
425 const int32_t x0 = (x >= cl) ? x : cl;
426 const int32_t y0 = (y >= ct) ? y : ct;
429 const int64_t xr = (int64_t)x + (int64_t)w;
430 const int64_t yr = (int64_t)y + (int64_t)h;
431 const int32_t x1 = (xr < (int64_t)cr) ? (int32_t)xr : cr;
432 const int32_t y1 = (yr < (int64_t)cb) ? (int32_t)yr : cb;
433 if ((x1 <= x0) || (y1 <= y0)) {
437 const uint8_t lo = (uint8_t)(v & (uint16_t)
k_mask_byte);
441 const size_t count = (size_t)(x1 - x0);
442 for (int32_t row = y0; row < y1; row++) {
476 for (int32_t row = 0; row < h; row++) {
477 for (int32_t col = 0; col < w; col++) {
508 for (int32_t col = 0; col < w; col++) {
512 for (int32_t row = 0; row < h; row++) {
591 int32_t x0 = (x > 0) ? x : 0;
592 int32_t y0 = (y > 0) ? y : 0;
599 const int64_t xr = (int64_t)x + (int64_t)w;
600 const int64_t yr = (int64_t)y + (int64_t)h;
601 int32_t x1 = (xr < (int64_t)fbw) ? (int32_t)xr : fbw;
602 int32_t y1 = (yr < (int64_t)fbh) ? (int32_t)yr : fbh;
709 for (int32_t y = y0; y < y1; ++y) {
711 const uint8_t* s = src + ((size_t)(y - dst_y) * (size_t)w) + (
size_t)(x0 - dst_x);
712 for (int32_t x = x0; x < x1; ++x) {
749 for (int32_t y = 0; y < h; ++y) {
750 for (int32_t x = 0; x < w; ++x) {
763 if ((src ==
nullptr) || (w <= 0) || (h <= 0)) {
779 if ((x0 < x1) && (y0 < y1)) {
791 int32_t dx = (x1 >= x0) ? (x1 - x0) : (x0 - x1);
792 int32_t dy = (y1 >= y0) ? -(y1 - y0) : -(y0 - y1);
793 const int32_t sx = (x0 < x1) ? 1 : -1;
794 const int32_t sy = (y0 < y1) ? 1 : -1;
795 int32_t err = dx + dy;
800 for (int32_t i = 0; i < max_iters; i++) {
802 if ((x == x1) && (y == y1)) {
805 const int32_t e2 = err * 2;
823 if ((w <= 0) || (h <= 0)) {
884 for (int32_t col = -x; col <= x; col++) {
888 for (int32_t col = -y; col <= y; col++) {
908 for (int32_t i = 0; i < max_iters; i++) {
922 err += (2 * (y - x)) + 1;
935 if (src_buf ==
nullptr) {
944 const uint8_t* src = (
const uint8_t*)src_buf;
945 const size_t src_stride = (size_t)src_w * (
size_t)
internal_bpp(src_format);
946 for (uint32_t row = 0; row < src_h; row++) {
947 for (uint32_t col = 0; col < src_w; col++) {
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_range_check_failed
Value outside range enforced by RA8_CHECK_RANGE / RA8_CHECK_RANGE_TAG.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
Software 2D graphics primitives layered on top of a caller-ownedframebuffer (DRW / D/AVE 2D / GLCDC r...
ra8_gfx_format_t
Pixel format of the framebuffer bound by ra8_gfx_init().
@ k_ra8_gfx_format_rgb565
16-bit RGB565, little-endian in memory.
@ k_ra8_gfx_format_argb8888
32-bit ARGB, A in MSB.
@ k_ra8_gfx_format_rgb888
24-bit packed R,G,B bytes.
@ k_ra8_gfx_min_dim
Minimum width or height in pixels.
@ k_ra8_gfx_max_dim
Maximum supported edge length.
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.
ra8_gfx_rgb565_bpp_t
RGB565 bytes per pixel (used to size span byte counts).
@ k_rgb565_bpp
Rgb565 bpp.
ra8_err_t ra8_gfx_circle(int32_t cx, int32_t cy, int32_t r, uint32_t color, bool filled)
Draw a circle using midpoint algorithm.
static uint8_t internal_color_b(uint32_t color)
Internal helper.
gfx_565_mask_t
RGB565 channel masks.
@ k_565_g_mask
6-bit green.
@ k_565_b_mask
5-bit blue.
static void internal_fill_rect_565(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
Span-fill an axis-aligned RGB565 rectangle, clipped to the framebuffer.
static uint8_t internal_color_a(uint32_t color)
Internal helper.
ra8_err_t ra8_gfx_line(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color)
Draw a line from (x0,y0) to (x1,y1) with Bresenham's algorithm.
ra8_err_t ra8_gfx_reset_clip(void)
Reset the clip rectangle to the whole framebuffer.
static uint32_t internal_get_pixel(const uint8_t *src, size_t stride, ra8_gfx_format_t format, size_t x, size_t y)
Read one pixel from a source buffer and return it as 0xAARRGGBB.
static void internal_fill_565(uint8_t *p, size_t count, uint8_t lo, uint8_t hi)
Fill count consecutive RGB565 pixels at p with packed bytes lo,hi.
static uint32_t internal_gray_to_color(uint32_t g)
Expand an 8-bit gray sample to the 0x00RRGGBB colour word priv_gfx_text_pack_565 expects.
static void internal_blit_gray8_565(const uint8_t *src, int32_t w, int32_t dst_x, int32_t dst_y, int32_t x0, int32_t y0, int32_t x1, int32_t y1)
RGB565 fast path for ra8_gfx_blit_gray8(): clip pre-resolved, tight rows.
ra8_gfx_color_shifts_t
Bit positions for unpacking 0xAARRGGBB colour values.
@ k_shift_blue
Shift blue.
@ k_shift_green
Shift green.
@ k_shift_alpha
Shift alpha.
static uint8_t internal_color_r(uint32_t color)
Extract red byte from a 0xAARRGGBB colour.
static void internal_circle_outline_step(int32_t cx, int32_t cy, int32_t x, int32_t y, uint32_t color)
Plot the eight symmetric points of a midpoint-circle step.
ra8_err_t ra8_gfx_blit(const void *src_buf, uint16_t src_w, uint16_t src_h, ra8_gfx_format_t src_format, int32_t dst_x, int32_t dst_y)
Copy a sub-image from src_buf into the framebuffer at (dst_x,dst_y).
ra8_gfx_glyph_bits_t
Constants for monochrome glyph bit extraction.
@ k_glyph_bits_per_byte
Glyph bits per byte.
@ k_glyph_msb_index
Glyph msb index.
ra8_err_t ra8_gfx_set_clip(int32_t x, int32_t y, int32_t w, int32_t h)
Restrict all subsequent drawing to a rectangle (dirty-region updates).
ra8_err_t ra8_gfx_clear(uint32_t color)
Fill the bound framebuffer's clip region with a single colour.
ra8_gfx_byte_idx_t
Per-byte indices for RGB888 packing.
@ k_idx_argb_r
Index argb r.
@ k_idx_argb_b
Index argb b.
@ k_idx_argb_a
Index argb a.
@ k_idx_argb_g
Index argb g.
ra8_gfx_color_masks_t
Per-channel masks for colour conversion.
ra8_gfx_565_t
RGB565 packing constants.
@ k_565_b_shift_in
drop 3 LSBs of B (8 -> 5 bits).
@ k_565_g_shift_in
drop 2 LSBs of G (8 -> 6 bits).
@ k_565_g_shift_out
565 g shift out.
@ k_565_r_shift_out
565 r shift out.
@ k_565_r_shift_in
drop 3 LSBs of R (8 -> 5 bits).
static bool internal_format_ok(ra8_gfx_format_t f)
Validate a format enum.
static void internal_put_pixel(uint8_t *dst, size_t stride, ra8_gfx_format_t format, size_t x, size_t y, uint32_t color)
Write one pixel into a generic destination buffer.
static void internal_circle_filled_step(int32_t cx, int32_t cy, int32_t x, int32_t y, uint32_t color)
Plot the two horizontal scan-lines for a midpoint-circle step.
void priv_gfx_text_plot(int32_t x, int32_t y, uint32_t color)
Implementation of priv_gfx_text_plot() – promoted for cross-TU use.
ra8_err_t ra8_gfx_pixel(int32_t x, int32_t y, uint32_t color)
Set a single pixel.
static uint8_t internal_bpp(ra8_gfx_format_t format)
Bytes per pixel for a given format.
static uint8_t internal_color_g(uint32_t color)
Internal helper.
static void internal_fill_rect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
Fill a solid rectangle (RGB565 span fast path, else per-pixel).
uint16_t priv_gfx_text_pack_565(uint32_t color)
Implementation of priv_gfx_text_pack_565() – promoted for cross-TU use.
static void internal_blit_gray8_slow(const uint8_t *src, int32_t w, int32_t h, int32_t dx, int32_t dy)
Per-pixel fallback for non-RGB565 formats, matching priv_gfx_text_plot() exactly.
static void internal_rect_outline(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
Draw the four edges of a 1-pixel-wide rectangle outline.
ra8_err_t ra8_gfx_init(void *fb, uint16_t width, uint16_t height, ra8_gfx_format_t format)
Bind ra8_gfx to a caller-owned framebuffer.
ra8_err_t ra8_gfx_blit_gray8(const uint8_t *src, int32_t w, int32_t h, int32_t dst_x, int32_t dst_y)
Blit an 8-bit grayscale image to a framebuffer rectangle.
ra8_err_t ra8_gfx_rect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color, bool filled)
Draw an axis-aligned rectangle.
Internal module state populated by ra8_gfx_init().