|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Software pixel-pusher implementation of ra8_gfx primitives. More...
#include <stddef.h>#include <stdint.h>#include <string.h>#include "ra8_err.h"#include "ra8_gfx.h"#include "ra8_gfx_internal.h"Go to the source code of this file.
Enumerations | |
| enum | gfx_565_mask_t : uint32_t { k_565_r_mask = 0x1FU , k_565_g_mask = 0x3FU , k_565_b_mask = 0x1FU } |
| RGB565 channel masks. More... | |
| enum | ra8_gfx_color_shifts_t : uint8_t { k_shift_blue = 0 , k_shift_green = 8 , k_shift_red = 16 , k_shift_alpha = 24 } |
| Bit positions for unpacking 0xAARRGGBB colour values. More... | |
| enum | ra8_gfx_color_masks_t : uint32_t { k_mask_byte = 0xFFU } |
| Per-channel masks for colour conversion. More... | |
| enum | ra8_gfx_565_t : uint8_t { k_565_r_shift_in = 3 , k_565_g_shift_in = 2 , k_565_b_shift_in = 3 , k_565_r_shift_out = 11 , k_565_g_shift_out = 5 } |
| RGB565 packing constants. More... | |
| enum | ra8_gfx_byte_idx_t : uint8_t { k_idx_r = 0 , k_idx_g = 1 , k_idx_b = 2 , k_idx_argb_b = 0 , k_idx_argb_g = 1 , k_idx_argb_r = 2 , k_idx_argb_a = 3 } |
| Per-byte indices for RGB888 packing. More... | |
| 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_rgb565_bpp_t : uint8_t { k_rgb565_bpp = 2 } |
| RGB565 bytes per pixel (used to size span byte counts). More... | |
Functions | |
| static uint8_t | internal_color_r (uint32_t color) |
| Extract red byte from a 0xAARRGGBB colour. | |
| static uint8_t | internal_color_g (uint32_t color) |
| Internal helper. | |
| static uint8_t | internal_color_b (uint32_t color) |
| Internal helper. | |
| static uint8_t | internal_color_a (uint32_t color) |
| Internal helper. | |
| uint16_t | priv_gfx_text_pack_565 (uint32_t color) |
| Implementation of priv_gfx_text_pack_565() – promoted for cross-TU use. | |
| static uint8_t | internal_bpp (ra8_gfx_format_t format) |
| Bytes per pixel for a given format. | |
| 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 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. | |
| 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. | |
| 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 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 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). | |
| 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_clear (uint32_t color) |
| Fill the bound framebuffer's clip region with a single colour. | |
| 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_reset_clip (void) |
| Reset the clip rectangle to the whole framebuffer. | |
| ra8_err_t | ra8_gfx_pixel (int32_t x, int32_t y, uint32_t color) |
| Set a single pixel. | |
| 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. | |
| 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. | |
| 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_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_rect (int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color, bool filled) |
| Draw an axis-aligned rectangle. | |
| 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. | |
| 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. | |
| 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. | |
| 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). | |
Variables | |
| ra8_gfx_state_t | g_gfx_text_state = {.format = k_ra8_gfx_format_rgb565} |
| Single module-wide framebuffer binding shared by every ra8_gfx TU. | |
Software pixel-pusher implementation of ra8_gfx primitives.
Portable C software rasteriser. The framebuffer pointer + format are stored in module-static state by ra8_gfx_init(); each draw entry point dispatches to a per-format pixel writer.
The main shapes (line, rect, circle) clip per pixel, which is fine for the sizes we render (a 7-inch panel is 1024 x 600). When DRW becomes available the rect/blit fast paths will be replaced; the public API does not change.
Definition in file ra8_gfx_text.c.
| enum gfx_565_mask_t : uint32_t |
RGB565 channel masks.
| Enumerator | |
|---|---|
| k_565_r_mask | 5-bit red. |
| k_565_g_mask | 6-bit green. |
| k_565_b_mask | 5-bit blue. |
Definition at line 29 of file ra8_gfx_text.c.
| enum ra8_gfx_565_t : uint8_t |
RGB565 packing constants.
Definition at line 58 of file ra8_gfx_text.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. |
| k_idx_b | Index b. |
| k_idx_argb_b | Index argb b. |
| k_idx_argb_g | Index argb g. |
| k_idx_argb_r | Index argb r. |
| k_idx_argb_a | Index argb a. |
Definition at line 70 of file ra8_gfx_text.c.
| enum ra8_gfx_color_masks_t : uint32_t |
Per-channel masks for colour conversion.
| Enumerator | |
|---|---|
| k_mask_byte | Mask byte. |
Definition at line 50 of file ra8_gfx_text.c.
| enum ra8_gfx_color_shifts_t : uint8_t |
Bit positions for unpacking 0xAARRGGBB colour values.
| Enumerator | |
|---|---|
| k_shift_blue | Shift blue. |
| k_shift_green | Shift green. |
| k_shift_red | Shift red. |
| k_shift_alpha | Shift alpha. |
Definition at line 39 of file ra8_gfx_text.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 84 of file ra8_gfx_text.c.
| enum ra8_gfx_rgb565_bpp_t : uint8_t |
RGB565 bytes per pixel (used to size span byte counts).
| Enumerator | |
|---|---|
| k_rgb565_bpp | Rgb565 bpp. |
Definition at line 90 of file ra8_gfx_text.c.
|
static |
RGB565 fast path for ra8_gfx_blit_gray8(): clip pre-resolved, tight rows.
Writes the clipped block [x0,x1) x [y0,y1) from a packed gray8 source image directly into the RGB565 framebuffer. For each visible pixel the gray sample is located via the src pointer, w (source row stride), dst_x, and dst_y offset arithmetic, then expanded to 0x00RRGGBB by internal_gray_to_color() before being packed to two RGB565 bytes by priv_gfx_text_pack_565(). The two bytes are written in the same low-byte-first order that internal_put_pixel() uses for k_ra8_gfx_format_rgb565, making the result byte-identical to the per-pixel path while avoiding the per-pixel clip overhead.
| [in] | src | Base pointer of the source gray8 image (one byte per pixel). |
| [in] | w | Source image width in pixels (row stride in bytes). |
| [in] | dst_x | Destination x offset of the source image top-left in the framebuffer. |
| [in] | dst_y | Destination y offset of the source image top-left in the framebuffer. |
| [in] | x0 | First visible column (inclusive), already clipped by the caller. |
| [in] | y0 | First visible row (inclusive), already clipped by the caller. |
| [in] | x1 | One past the last visible column (exclusive), already clipped. |
| [in] | y1 | One past the last visible row (exclusive), already clipped. |
Definition at line 699 of file ra8_gfx_text.c.
References g_gfx_text_state, internal_gray_to_color(), k_glyph_bits_per_byte, k_idx_g, k_idx_r, k_mask_byte, k_rgb565_bpp, and priv_gfx_text_pack_565().
Referenced by ra8_gfx_blit_gray8().
|
static |
Per-pixel fallback for non-RGB565 formats, matching priv_gfx_text_plot() exactly.
Iterates over every pixel in the w x h source gray8 image, expands each sample to 0x00RRGGBB via internal_gray_to_color(), and calls priv_gfx_text_plot() to write the result at framebuffer coordinates (dx+col, dy+row). Because priv_gfx_text_plot() performs per-pixel clipping against the active clip rectangle, no additional bounds checking is needed here. This path is taken for all formats other than k_ra8_gfx_format_rgb565; the RGB565 fast path is internal_blit_gray8_565().
| [in] | src | Base pointer of the source gray8 image (one byte per pixel, row-major). |
| [in] | w | Source image width in pixels (also the byte stride per row). |
| [in] | h | Source image height in pixels. |
| [in] | dx | Destination x offset of the image top-left in the framebuffer. |
| [in] | dy | Destination y offset of the image top-left in the framebuffer. |
Definition at line 747 of file ra8_gfx_text.c.
References internal_gray_to_color(), and priv_gfx_text_plot().
Referenced by ra8_gfx_blit_gray8().
|
inlinestatic |
Bytes per pixel for a given format.
See implementation.
| [in] | format | See implementation. |
| k_ra8_ok | Operation succeeded. |
Definition at line 210 of file ra8_gfx_text.c.
Referenced by internal_get_pixel(), internal_put_pixel(), ra8_gfx_blit(), and ra8_gfx_init().
|
static |
Plot the two horizontal scan-lines for a midpoint-circle step.
See implementation.
| [in] | cx | See implementation. |
| [in] | cy | See implementation. |
| [in] | x | See implementation. |
| [in] | y | See implementation. |
| [in] | color | See implementation. |
Definition at line 882 of file ra8_gfx_text.c.
References priv_gfx_text_plot().
Referenced by ra8_gfx_circle().
|
static |
Plot the eight symmetric points of a midpoint-circle step.
See implementation.
| [in] | cx | See implementation. |
| [in] | cy | See implementation. |
| [in] | x | See implementation. |
| [in] | y | See implementation. |
| [in] | color | See implementation. |
Definition at line 852 of file ra8_gfx_text.c.
References priv_gfx_text_plot().
Referenced by ra8_gfx_circle().
|
inlinestatic |
Internal helper.
See implementation.
| [in] | color | See implementation. |
| k_ra8_ok | Operation succeeded. |
Definition at line 181 of file ra8_gfx_text.c.
References k_mask_byte, and k_shift_alpha.
Referenced by internal_put_pixel().
|
inlinestatic |
Internal helper.
See implementation.
| [in] | color | See implementation. |
| k_ra8_ok | Operation succeeded. |
Definition at line 163 of file ra8_gfx_text.c.
References k_mask_byte, and k_shift_blue.
Referenced by internal_put_pixel(), and priv_gfx_text_pack_565().
|
inlinestatic |
Internal helper.
See implementation.
| [in] | color | See implementation. |
| k_ra8_ok | Operation succeeded. |
Definition at line 145 of file ra8_gfx_text.c.
References k_mask_byte, and k_shift_green.
Referenced by internal_put_pixel(), and priv_gfx_text_pack_565().
|
inlinestatic |
Extract red byte from a 0xAARRGGBB colour.
See implementation.
| [in] | color | See implementation. |
| k_ra8_ok | Operation succeeded. |
Definition at line 127 of file ra8_gfx_text.c.
References k_mask_byte, and k_shift_red.
Referenced by internal_put_pixel(), and priv_gfx_text_pack_565().
|
inlinestatic |
Fill count consecutive RGB565 pixels at p with packed bytes lo,hi.
One tight inner loop that stores the two pre-packed bytes per pixel, so a span fill pays the colour packing (priv_gfx_text_pack_565 + the per-channel extraction) once for the whole run instead of once per pixel. The byte order (low byte first) is exactly what internal_put_pixel writes for k_ra8_gfx_format_rgb565, so the result is byte-identical to plotting each pixel individually.
| [out] | p | Destination of the first pixel (2 bytes per pixel). |
| [in] | count | Number of pixels to write. |
| [in] | lo | Low byte of the packed RGB565 word. |
| [in] | hi | High byte of the packed RGB565 word. |
Definition at line 376 of file ra8_gfx_text.c.
References k_rgb565_bpp, and memset().
Referenced by internal_fill_rect_565().
|
static |
Fill a solid rectangle (RGB565 span fast path, else per-pixel).
RGB565 – the panel format – takes the clipped span fill; other formats fall back to the per-pixel priv_gfx_text_plot loop. Both write the same in-bounds pixels.
| [in] | x | Top-left corner x. |
| [in] | y | Top-left corner y. |
| [in] | w | Width in pixels (> 0, checked by ra8_gfx_rect). |
| [in] | h | Height in pixels (> 0, checked by ra8_gfx_rect). |
| [in] | color | 32-bit fill colour. |
Definition at line 470 of file ra8_gfx_text.c.
References g_gfx_text_state, internal_fill_rect_565(), k_ra8_gfx_format_rgb565, and priv_gfx_text_plot().
Referenced by ra8_gfx_rect().
|
static |
Span-fill an axis-aligned RGB565 rectangle, clipped to the framebuffer.
Clips [x,x+w) x [y,y+h) to the framebuffer once, then fills each visible row with internal_fill_565. This writes exactly the pixels priv_gfx_text_plot would (the same in-bounds set) with the same packed bytes, so it is byte-identical to the per-pixel fill while replacing roughly six function calls per pixel (plot -> put_pixel -> pack_565 -> color_r/g/b -> bpp) with one packed store.
| [in] | x | Top-left corner x (may be partly or fully off-screen). |
| [in] | y | Top-left corner y (may be partly or fully off-screen). |
| [in] | w | Width in pixels (assumed > 0 by the caller). |
| [in] | h | Height in pixels (assumed > 0 by the caller). |
| [in] | color | 32-bit colour, packed to RGB565 once. |
Definition at line 415 of file ra8_gfx_text.c.
References g_gfx_text_state, internal_fill_565(), k_glyph_bits_per_byte, k_mask_byte, and priv_gfx_text_pack_565().
Referenced by internal_fill_rect(), and ra8_gfx_clear().
|
inlinestatic |
Validate a format enum.
See implementation.
| [in] | f | See implementation. |
| k_ra8_ok | Operation succeeded. |
Definition at line 230 of file ra8_gfx_text.c.
References k_ra8_gfx_format_argb8888, k_ra8_gfx_format_rgb565, and k_ra8_gfx_format_rgb888.
Referenced by ra8_gfx_blit(), and ra8_gfx_init().
|
static |
Read one pixel from a source buffer and return it as 0xAARRGGBB.
See implementation.
| [in] | src | See implementation. |
| [in] | stride | See implementation. |
| [in] | format | See implementation. |
| [in] | x | See implementation. |
| [in] | y | See implementation. |
| k_ra8_ok | Operation succeeded. |
Definition at line 306 of file ra8_gfx_text.c.
References internal_bpp(), k_565_b_mask, k_565_b_shift_in, k_565_g_mask, k_565_g_shift_in, k_565_g_shift_out, k_565_r_mask, k_565_r_shift_in, k_565_r_shift_out, k_glyph_bits_per_byte, k_idx_argb_a, k_idx_argb_b, k_idx_argb_g, k_idx_argb_r, k_idx_b, k_idx_g, k_idx_r, k_ra8_gfx_format_argb8888, k_ra8_gfx_format_rgb565, k_ra8_gfx_format_rgb888, k_shift_alpha, k_shift_blue, k_shift_green, and k_shift_red.
Referenced by ra8_gfx_blit().
|
inlinestatic |
Expand an 8-bit gray sample to the 0x00RRGGBB colour word priv_gfx_text_pack_565 expects.
Replicates the single gray value g into the R, G, and B channels of a packed 0x00RRGGBB word by shifting g to the positions defined by k_shift_red, k_shift_green, and k_shift_blue, then ORing the three contributions together. The alpha channel is left as zero (fully opaque is implied by convention throughout the software rasteriser). The result can be fed directly to priv_gfx_text_pack_565 to produce the equivalent RGB565 pixel.
| [in] | g | 8-bit gray intensity in the range [0, 255]. |
| 0x00000000 | When g is 0 (black). |
| 0x00FFFFFF | When g is 255 (white). |
Definition at line 664 of file ra8_gfx_text.c.
References k_shift_blue, k_shift_green, and k_shift_red.
Referenced by internal_blit_gray8_565(), and internal_blit_gray8_slow().
|
static |
Write one pixel into a generic destination buffer.
| [out] | dst | Destination buffer base. |
| [in] | stride | Bytes per row in destination. |
| [in] | format | Destination pixel format. |
| [in] | x,y | Pixel coordinates within the destination. |
| [in] | color | 32-bit colour. |
See implementation.
| [in] | y | See implementation. |
Definition at line 255 of file ra8_gfx_text.c.
References internal_bpp(), internal_color_a(), internal_color_b(), internal_color_g(), internal_color_r(), k_glyph_bits_per_byte, k_idx_argb_a, k_idx_argb_b, k_idx_argb_g, k_idx_argb_r, k_idx_b, k_idx_g, k_idx_r, k_mask_byte, k_ra8_gfx_format_argb8888, k_ra8_gfx_format_rgb565, k_ra8_gfx_format_rgb888, and priv_gfx_text_pack_565().
Referenced by priv_gfx_text_plot(), and ra8_gfx_clear().
|
static |
Draw the four edges of a 1-pixel-wide rectangle outline.
Plots the top row (y), bottom row (y+h-1), left column (x), and right column (x+w-1) by iterating over all column and row positions in two separate loops. interior pixels are never touched. Each pixel is routed through priv_gfx_text_plot, which applies the active clip rectangle before writing to the framebuffer, so partial off-screen outlines are rendered correctly without additional guards here.
| [in] | x | Top-left corner x. |
| [in] | y | Top-left corner y. |
| [in] | w | Width in pixels (> 0, checked by ra8_gfx_rect). |
| [in] | h | Height in pixels (> 0, checked by ra8_gfx_rect). |
| [in] | color | 32-bit edge colour. |
Definition at line 506 of file ra8_gfx_text.c.
References priv_gfx_text_plot().
Referenced by ra8_gfx_rect().
| uint16_t priv_gfx_text_pack_565 | ( | uint32_t | color | ) |
Implementation of priv_gfx_text_pack_565() – promoted for cross-TU use.
Pack a 32-bit colour into a single RGB565 word.
Definition at line 187 of file ra8_gfx_text.c.
References internal_color_b(), internal_color_g(), internal_color_r(), k_565_b_shift_in, k_565_g_shift_in, k_565_g_shift_out, k_565_r_shift_in, and k_565_r_shift_out.
Referenced by internal_blit_glyph_565(), internal_blit_gray8_565(), internal_fill_rect_565(), and internal_put_pixel().
| 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.
Plot a single pixel with bounds checking against the active clip.
Definition at line 335 of file ra8_gfx_text.c.
References g_gfx_text_state, and internal_put_pixel().
Referenced by internal_blit_gray8_slow(), internal_circle_filled_step(), internal_circle_outline_step(), internal_fill_rect(), internal_gray4_block(), internal_rect_outline(), internal_render_glyph(), ra8_gfx_blit(), ra8_gfx_blit_gray8_dither(), ra8_gfx_line(), and ra8_gfx_pixel().
|
nodiscard |
Copy a sub-image from src_buf into the framebuffer at (dst_x,dst_y).
| [in] | src_buf | Source image bytes. |
| [in] | src_w,src_h | Source size. |
| [in] | src_format | Pixel format of the source image. |
| [in] | dst_x,dst_y | Destination top-left in the framebuffer. |
| k_ra8_ok | Blitted (clipped if needed). |
| k_ra8_err_null_ptr | src_buf was NULL. |
| k_ra8_err_not_initialized | ra8_gfx_init() was not called. |
| k_ra8_err_invalid_arg | src_w or src_h was zero or src_format invalid. |
Definition at line 928 of file ra8_gfx_text.c.
References g_gfx_text_state, internal_bpp(), internal_format_ok(), internal_get_pixel(), k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_err_null_ptr, k_ra8_ok, and priv_gfx_text_plot().
Referenced by ls_blit().
|
nodiscard |
Blit an 8-bit grayscale image to a framebuffer rectangle.
Writes the w x h block of 8-bit gray samples at src into the bound framebuffer with its top-left at (dst_x, dst_y), expanding each sample g to the colour (g<<16)|(g<<8)|g and down-converting to the panel format. The clip rectangle and framebuffer bounds are resolved ONCE for the whole block (not per pixel), so a full image is a tight row loop – the same pixels a per-pixel ra8_gfx_pixel() loop would write, far fewer instructions. Rows are sampled left-to-right, top-to-bottom; src is row-major with stride w.
| [in] | src | Row-major 8-bit gray buffer of at least w * h bytes. |
| [in] | w | Source width in pixels (> 0). |
| [in] | h | Source height in pixels (> 0). |
| [in] | dst_x | Destination column of the block's left edge. |
| [in] | dst_y | Destination row of the block's top edge. |
| k_ra8_ok | Visible pixels written (or fully clipped out). |
| k_ra8_err_not_initialized | ra8_gfx_init() was not called. |
| k_ra8_err_invalid_arg | src is NULL, or w / h <= 0. |
src holds at least w * h bytes. Definition at line 758 of file ra8_gfx_text.c.
References g_gfx_text_state, internal_blit_gray8_565(), internal_blit_gray8_slow(), k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_gfx_format_rgb565, and k_ra8_ok.
Referenced by erb_render_image(), sh_image_blit_cover(), and sh_image_blit_gray8().
|
nodiscard |
Draw a circle using midpoint algorithm.
| [in] | cx,cy | Centre. |
| [in] | r | Radius in pixels (>= 0). |
| [in] | color | 32-bit colour. |
| [in] | filled | true for solid disc, false for 1-pixel outline. |
| k_ra8_ok | Drawn. |
| k_ra8_err_not_initialized | ra8_gfx_init() was not called. |
| k_ra8_err_invalid_arg | r < 0. |
Definition at line 894 of file ra8_gfx_text.c.
References g_gfx_text_state, internal_circle_filled_step(), internal_circle_outline_step(), k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_gfx_max_dim, and k_ra8_ok.
Referenced by er_round_rect(), and priv_ra8_svgp_draw_circle().
|
nodiscard |
Fill the bound framebuffer's clip region with a single colour.
| [in] | color | 32-bit colour in 0x00RRGGBB or 0xAARRGGBB form. |
| k_ra8_ok | Cleared. |
| k_ra8_err_not_initialized | ra8_gfx_init() was not called. |
Definition at line 549 of file ra8_gfx_text.c.
References g_gfx_text_state, internal_fill_rect_565(), internal_put_pixel(), k_ra8_err_not_initialized, k_ra8_gfx_format_rgb565, and k_ra8_ok.
Referenced by ch_render(), cm_render(), ef_decode_and_hash(), er_render_keyboard(), er_render_library(), er_render_reading(), erb_render_all(), erb_render_image(), internal_decode(), internal_rc_render_all(), ls_redraw(), main(), mg_reader_render(), render_page(), sfr_bringup_panel(), sfr_panic_halt(), sh_comic_probe_blob(), sh_comic_render(), sh_cover_render(), sh_epub_thumb(), sh_loading_overlay(), sh_reader_render(), sh_shelf_render(), sh_toc_render(), wa_app_render(), wd_app_render(), and wk_check_full().
|
nodiscard |
Bind ra8_gfx to a caller-owned framebuffer.
| [in] | fb | Pointer to framebuffer memory. |
| [in] | width | Framebuffer width in pixels. |
| [in] | height | Framebuffer height in pixels. |
| [in] | format | Pixel format (see ra8_gfx_format_t). |
| k_ra8_ok | Bound successfully. |
| k_ra8_err_null_ptr | fb was NULL. |
| k_ra8_err_invalid_arg | Dimensions out of range or unsupported format. |
Definition at line 522 of file ra8_gfx_text.c.
References g_gfx_text_state, internal_bpp(), internal_format_ok(), k_ra8_err_invalid_arg, k_ra8_err_null_ptr, k_ra8_gfx_max_dim, k_ra8_gfx_min_dim, and k_ra8_ok.
Referenced by app_bringup_gfx(), cm_bringup_panel(), ez_bringup_panel(), main(), mg_bringup_panel(), priv_viewer_render_comic(), priv_viewer_tile_comic(), render_page(), sfr_bringup_panel(), sh_comic_probe_blob(), sh_comic_selfcheck(), sh_epub_thumb(), sh_panel_or_halt(), wc_panel_up(), wd_panel_up(), and wk_panel_up().
|
nodiscard |
Draw a line from (x0,y0) to (x1,y1) with Bresenham's algorithm.
| [in] | x0,y0,x1,y1 | Endpoints (clipped to framebuffer). |
| [in] | color | 32-bit colour. |
| k_ra8_ok | Line drawn (after clipping). |
| k_ra8_err_not_initialized | ra8_gfx_init() was not called. |
Definition at line 785 of file ra8_gfx_text.c.
References g_gfx_text_state, k_ra8_err_not_initialized, k_ra8_gfx_max_dim, k_ra8_ok, and priv_gfx_text_plot().
Referenced by ch_border(), ch_fill(), er_icon_delete(), er_icon_return(), er_tri_up(), priv_ra8_svgp_draw_line(), priv_ra8_svgp_draw_polyline(), and priv_ra8_svgp_fill_poly().
|
nodiscard |
Set a single pixel.
| [in] | x | Column, 0 = left. |
| [in] | y | Row, 0 = top. |
| [in] | color | 32-bit colour. |
| k_ra8_ok | Pixel written. |
| k_ra8_err_not_initialized | ra8_gfx_init() was not called. |
| k_ra8_err_range_check_failed | (x,y) outside framebuffer. |
Definition at line 628 of file ra8_gfx_text.c.
References g_gfx_text_state, k_ra8_err_not_initialized, k_ra8_err_range_check_failed, k_ra8_ok, and priv_gfx_text_plot().
Referenced by internal_blit_alpha_mask(), internal_blit_scaled(), internal_draw_underline(), and priv_ra8_svgp_fill_poly_grad().
|
nodiscard |
Draw an axis-aligned rectangle.
| [in] | x,y | Top-left corner. |
| [in] | w,h | Width and height in pixels. |
| [in] | color | 32-bit colour. |
| [in] | filled | true for solid fill, false for 1-pixel outline. |
| k_ra8_ok | Drawn. |
| k_ra8_err_not_initialized | ra8_gfx_init() was not called. |
Definition at line 818 of file ra8_gfx_text.c.
References g_gfx_text_state, internal_fill_rect(), internal_rect_outline(), k_ra8_err_not_initialized, and k_ra8_ok.
Referenced by cm_draw_progress_bar(), cm_draw_status_bar(), er_icon_shift(), er_kbd_keys_render(), er_lib_body_render(), er_lib_sb_render(), er_nag_render(), er_read_footer_render(), er_read_sb_render(), er_render_boxnodes(), er_round_rect(), ez_draw_lens_chrome(), ez_draw_status(), ls_draw_rail(), ls_draw_status(), mg_render_minimap(), mg_render_status(), priv_ra8_svgp_draw_rect(), sh_border(), sh_cover_button(), sh_draw_card(), sh_titlebar(), sh_toc_render(), wa_fill_render(), wc_footer_render(), wc_status_render(), wc_tile_render(), wd_content_render(), wd_fill(), wd_status_render(), wd_tabbar_render(), and wk_paint_fill().
|
nodiscard |
Reset the clip rectangle to the whole framebuffer.
| k_ra8_ok | Clip reset to the full framebuffer. |
| k_ra8_err_not_initialized | ra8_gfx_init() was not called. |
Definition at line 616 of file ra8_gfx_text.c.
References g_gfx_text_state, k_ra8_err_not_initialized, and k_ra8_ok.
Referenced by er_render_nag_region(), ls_redraw(), and sh_image_loupe().
|
nodiscard |
Restrict all subsequent drawing to a rectangle (dirty-region updates).
Every draw call (clear, rect, line, pixel, text, blit) writes only pixels inside the intersection of this rectangle and the framebuffer; pixels outside are left untouched. This is the primitive for incremental / dirty-region repaints – set the clip to the damaged area, redraw, then ra8_gfx_reset_clip() – so a small change (e.g. an overlay banner) does not repaint the whole panel. The clip persists until changed or reset; ra8_gfx_init() and ra8_gfx_reset_clip() set it to the full framebuffer.
| [in] | x | Clip left in pixels (clamped to the framebuffer). |
| [in] | y | Clip top in pixels (clamped to the framebuffer). |
| [in] | w | Clip width in pixels (a non-positive width yields an empty clip). |
| [in] | h | Clip height in pixels (a non-positive height yields an empty clip). |
| k_ra8_ok | Clip set (possibly empty). |
| k_ra8_err_not_initialized | ra8_gfx_init() was not called. |
Definition at line 580 of file ra8_gfx_text.c.
References g_gfx_text_state, k_ra8_err_not_initialized, and k_ra8_ok.
Referenced by er_render_nag_region(), and sh_image_loupe().
| ra8_gfx_state_t g_gfx_text_state = {.format = k_ra8_gfx_format_rgb565} |
Single module-wide framebuffer binding shared by every ra8_gfx TU.
Module-wide framebuffer binding (single shared object; see ra8_gfx_internal.h).
Defined once in ra8_gfx_text.c (populated by ra8_gfx_init()); the text/glyph TU reads it through this extern declaration. There is exactly one object so all draw entry points observe the same framebuffer, format, and clip rectangle.
The one definition of the shared rasteriser state. Other ra8_gfx TUs read it through the extern declaration in ra8_gfx_internal.h.
Definition at line 106 of file ra8_gfx_text.c.
Referenced by internal_blit_glyph_565(), internal_blit_gray8_565(), internal_fill_rect(), internal_fill_rect_565(), internal_render_glyph(), priv_gfx_text_plot(), ra8_gfx_blit(), ra8_gfx_blit_gray4_zoom(), ra8_gfx_blit_gray8(), ra8_gfx_blit_gray8_dither(), ra8_gfx_circle(), ra8_gfx_clear(), ra8_gfx_init(), ra8_gfx_line(), ra8_gfx_pixel(), ra8_gfx_rect(), ra8_gfx_reset_clip(), ra8_gfx_set_clip(), and ra8_gfx_text_out().