objc

Data Structures | Typedefs | Functions
Pixel Frames

Functions for pixel frames. More...

Collaboration diagram for Pixel Frames:

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...
 

Detailed Description

Functions for pixel frames.

Typedef Documentation

◆ pix_frame_t

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.

Function Documentation

◆ pix_frame_clear_rect()

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.

Parameters
framePointer to the frame to operate on
colorColor to fill the rectangle with
originTop-left corner of the rectangle to clear
sizeDimensions of the rectangle to clear. If zero, clears the entire frame.

Completely overwrites existing pixel data in the specified region.

◆ pix_frame_finalize()

bool pix_frame_finalize ( pix_frame_t frame)

Finalize and free resources associated with a framebuffer.

Parameters
framePointer to the framebuffer to finalize
Returns
true if successfully finalized, false on error.

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_init()

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.

Parameters
formatPixel format for the framebuffer
sizeDimensions of the framebuffer in pixels
alignmentMemory alignment requirement for the buffer (0 for default)
Returns
Initialized framebuffer structure with allocated buffer

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.