/* Small userland drawing library for the ring-3 WM: bpp-aware fills, copies, * 8x8 glyphs, VGA cell grids, RGB565 canvas blits and the Adwaita icon masks. * No kernel dependencies; the WM maps the shadow buffer and calls these * functions directly. */ #ifndef UWM_LIB_H #define UWM_LIB_H #include "icon_abi.h" struct ufont_face; /* Icon ids from the same list the ngui tools use; the order is the bundle * order. The WM does not link ngui, so it generates its own ids. */ #define UWM_ICON_ENUM_(e, name, file) UWM_ICON_##e, enum uwm_icon { ICON_LIST(UWM_ICON_ENUM_) UWM_ICON_COUNT }; #undef UWM_ICON_ENUM_ struct usurf { unsigned char *px; unsigned int w, h, pitch; unsigned int bpp; /* 16, 24 or 32 */ struct ufont_face *font; /* NULL = 8x16 bitmap text */ int font_px; }; struct uwm_canvas { const unsigned short *px; /* RGB565, tightly packed */ unsigned int w, h; }; /* Pixels written by the compositor primitives; the WM uses it for stats. */ extern unsigned int usurf_pixels; void usurf_init(struct usurf *s, void *px, unsigned int w, unsigned int h, unsigned int pitch, unsigned int bpp); void usurf_fill(struct usurf *s, int x, int y, unsigned int w, unsigned int h, unsigned int rgb); void usurf_copy(struct usurf *s, int dx, int dy, int sx, int sy, unsigned int w, unsigned int h); void usurf_glyph(struct usurf *s, int x, int y, unsigned char c, unsigned int fg, unsigned int bg, int transparent, unsigned int height, int cx, int cy, unsigned int cw, unsigned int ch); void usurf_text(struct usurf *s, int x, int y, const char *str, unsigned int fg, int cx, int cy, unsigned int cw, unsigned int ch); unsigned int usurf_text_width(struct usurf *s, const char *str); void usurf_font_attach(struct usurf *s, const char *path, int px); void usurf_cells(struct usurf *s, const unsigned short *cells, unsigned int cols, unsigned int rows, int x0, int y0, int cx, int cy, unsigned int cw, unsigned int ch); void usurf_canvas(struct usurf *s, const struct uwm_canvas *c, int x0, int y0, int cx, int cy, unsigned int cw, unsigned int ch); /* Blit one 16x16 Adwaita coverage mask, tinted with `rgb`, blended over the * surface. Returns 0 when the bundle (or that id) is not available. */ int usurf_icon(struct usurf *s, int x, int y, enum uwm_icon icon, unsigned int rgb); #endif