axle graphics stack

At its core, axle graphics works with rectangular buffers containing raw pixel data, referred to as buffers. All compositing, including manipulations on windows, views, labels, and other UI elements are done through the core animation layer API.

Wrappers around ca_layer exist to easily interact with the window manager API, and help manage your view stack. Windows are standard desktop application windows. Windows can contain multiple View's, which are all bounded to the frame of the window. Several special View types are included, such as Label, Button, and Bmp. All of these objects are built on top of ca_layer.


The core animation layer is the primitive for all graphics operations in axle. ca_layer is a wrapper around a contiguous array of RGB values, representing raw pixel data. Layers can be blitted and composited together using the ca_layer API.

ca_layer can blit sets of pixels together with or without alpha blending. The alpha of a ca_layer can be controlled using layer->alpha, or by a call to set_alpha() with the parent View.

ca_layer tries its best to ensure layers don't overwrite their bounds.

typedef struct ca_layer_t {
    Size size; //width/height in pixels
    uint8_t* raw; //raw RGB values backing this layer
    float alpha; //transparency value bounded to continuous range [0..1]
} ca_layer;

//initialize layer with a given size
struct ca_layer_t* create_layer(Size size);

//free all resources associated with a layer
//no fields of 'layer' should be accessed after this call
void layer_teardown(ca_layer* layer);

//blit RGB contents of 'src' onto 'dest'
//automatically switches to compositing if 'dest' needs ot be alpha blended
//only copies pixels from the rectangle bounded by 'src_frame'
//only copies pixels into the rectangle bounded by 'dest_frame'
void blit_layer(ca_layer* dest, ca_layer* src, Rect dest_frame, Rect src_frame);

//create a copy of layer pointed to by src
//only copies pixels bounded by the rectangle 'frame'
ca_layer* layer_snapshot(ca_layer* src, Rect frame);


Screen is the root container for awm's view hierarchy. Screen is defined as follows:

typedef struct screen_t {
	Window* window; //root window of hierarchy
	uint16_t depth; //bits per pixel
	uint8_t bpp; //bytes per pixel
	Size resolution;
	uint32_t* physbase; //address of beginning of framebuffer
	volatile int finished_drawing; //are we currently rendering a frame?
	ca_layer* vmem; //raw framebuffer pushed to screen
	Size default_font_size; //recommended font size for screen resolution
} Screen;

All fields of Screen should be considered private outside of the window manager implementation, aside from 'resolution', which can be queried to retrieve current graphics mode. To get a reference to the active Screen from kernel mode, use the gfx_screen() call.

On a hierarchy redraw, all subwindows of the root window are rendered to the 'vmem' field, which is then flushed to 'physbase' upon a write_screen().



A Window is the main container for a set of Views.