Functions for pixel frames. More...
![]() |
Data Structures | |
struct | pix_frame_t |
Frame structure containing pixel data and drawing operations. More... | |
Typedefs | |
typedef struct pix_frame_t | pix_frame_t |
Frame structure containing pixel data and drawing operations. More... | |
Functions | |
pix_frame_t | pix_frame_init (pix_format_t format, pix_size_t size, size_t alignment) |
Initialize a new framebuffer with the specified format and size. More... | |
bool | pix_frame_finalize (pix_frame_t *frame) |
Finalize and free resources associated with a framebuffer. More... | |
bool | pix_frame_clear_rect (pix_frame_t *frame, pix_color_t color, pix_point_t origin, pix_size_t size) |
Clear a rectangular region to a solid color. More... | |
Functions for pixel frames.
typedef struct pix_frame_t pix_frame_t |
Frame structure containing pixel data and drawing operations.
A frame represents a rectangular region of pixels with associated drawing functions. The frame is not thread-safe for performance reasons - callers must provide their own synchronization if needed.
bool pix_frame_clear_rect | ( | pix_frame_t * | frame, |
pix_color_t | color, | ||
pix_point_t | origin, | ||
pix_size_t | size | ||
) |
Clear a rectangular region to a solid color.
frame | Pointer to the frame to operate on |
color | Color to fill the rectangle with |
origin | Top-left corner of the rectangle to clear |
size | Dimensions of the rectangle to clear. If zero, clears the entire frame. |
Completely overwrites existing pixel data in the specified region.
bool pix_frame_finalize | ( | pix_frame_t * | frame | ) |
Finalize and free resources associated with a framebuffer.
frame | Pointer to the framebuffer to finalize |
This function releases the memory allocated for the framebuffer's pixel buffer and resets the framebuffer structure. The structure cannot be reused after finalization.
pix_frame_t pix_frame_init | ( | pix_format_t | format, |
pix_size_t | size, | ||
size_t | alignment | ||
) |
Initialize a new framebuffer with the specified format and size.
format | Pixel format for the framebuffer |
size | Dimensions of the framebuffer in pixels |
alignment | Memory alignment requirement for the buffer (0 for default) |
Returns a framebuffer structure with an allocated buffer of the specified size and format. The buffer is aligned according to the specified alignment. If alignment is 0, the default alignment for the platform is used, which is usually sizeof(size_t).
If the allocation fails, or there are other errors, the function returns a zero-sized frame. The caller is responsible for checking the return value. Otherwise, the methods for manipulating the frame will be populated according to the specified pixel format.
The "drawable" function will be set to NULL by default, meaning the framebuffer is always considered drawable. Callers can set this function to a custom implementation if needed, such as for windowing systems that may update the framebuffer concurrently.