21typedef enum :
size_t {
46 struct stat metadata = {};
47 if ((fstat(fd, &metadata) != 0) || (metadata.st_size < 0) ||
48 (((uint64_t)metadata.st_size %
sizeof(uint16_t)) != 0U)) {
51 const uint64_t pixels = (uint64_t)metadata.st_size /
sizeof(uint16_t);
52 const uint64_t output_size = pixels *
sizeof(uint32_t);
53 if ((uint64_t)position >= output_size) {
56 const size_t available = (size_t)(output_size - (uint64_t)position);
57 return (count < available) ? count : available;
75 for (
size_t index = 0U; index < pixel_count; index++) {
76 const uint32_t pixel = rgb565[index];
80 const uint32_t red8 = (red5 << 3U) | (red5 >> 2U);
81 const uint32_t green8 = (green6 << 2U) | (green6 >> 4U);
82 const uint32_t blue8 = (blue5 << 3U) | (blue5 >> 2U);
83 rgb888[index] = (red8 << 16U) | (green8 << 8U) | blue8;
89 if ((fd < 0) || (position < 0) || (buffer ==
nullptr) || (count == 0U)) {
93 uint8_t* destination = (uint8_t*)buffer;
95 while (copied < available) {
96 const uint64_t stream_offset = (uint64_t)position + copied;
97 const uint64_t first_pixel = stream_offset /
sizeof(uint32_t);
98 const size_t byte_skip = (size_t)(stream_offset %
sizeof(uint32_t));
99 const size_t wanted = available - copied;
100 size_t pixel_count = (byte_skip + wanted +
sizeof(uint32_t) - 1U) /
sizeof(uint32_t);
108 pixel_count *
sizeof(uint16_t),
109 (off_t)(first_pixel *
sizeof(uint16_t)))
114 const size_t generated = (pixel_count *
sizeof(uint32_t)) - byte_skip;
115 const size_t take = ((available - copied) < generated) ? (available - copied) : generated;
116 (void)
memcpy(&destination[copied], &((
const uint8_t*)rgb888)[byte_skip], take);
Minimal self-contained macOS window for the board emulator.
size_t board_view_read_rgb888_fd(int fd, off_t position, void *buffer, size_t count)
Expand an arbitrary byte range from a sealed RGB565 descriptor.
view_pixel_geometry_t
Bounded conversion chunk and RGB565 channel geometry.
@ k_rgb565_five_bit_max
Five-bit channel mask.
@ k_rgb565_red_shift
Red-field least-significant bit.
@ k_rgb565_six_bit_max
Six-bit channel mask.
@ k_rgb565_green_shift
Green-field least-significant bit.
@ k_view_pixel_chunk
Fixed source/conversion chunk capacity.
static size_t internal_available_bytes(int fd, off_t position, size_t count)
Clamp one provider request to the bytes the surface can still supply.
static void internal_expand_chunk(const uint16_t *rgb565, uint32_t *rgb888, size_t pixel_count)
Expand one bounded RGB565 chunk into packed 32-bit RGB888 words.
Bounded raw-descriptor I/O seam for the RA8 emulator.
@ k_emu_io_ok
The complete operation succeeded.
emu_io_result_t priv_emu_io_pread_exact(int fd, void *buf, size_t count, off_t offset)
Read exactly count bytes at offset without changing the cursor.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.