uwm_lib.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Small userland drawing library for the ring-3 WM: bpp-aware fills, copies,
  2. * 8x8 glyphs, VGA cell grids, RGB565 canvas blits and the Adwaita icon masks.
  3. * No kernel dependencies; the WM maps the shadow buffer and calls these
  4. * functions directly. */
  5. #ifndef UWM_LIB_H
  6. #define UWM_LIB_H
  7. #include "icon_abi.h"
  8. struct ufont_face;
  9. /* Icon ids from the same list the ngui tools use; the order is the bundle
  10. * order. The WM does not link ngui, so it generates its own ids. */
  11. #define UWM_ICON_ENUM_(e, name, file) UWM_ICON_##e,
  12. enum uwm_icon {
  13. ICON_LIST(UWM_ICON_ENUM_)
  14. UWM_ICON_COUNT
  15. };
  16. #undef UWM_ICON_ENUM_
  17. struct usurf {
  18. unsigned char *px;
  19. unsigned int w, h, pitch;
  20. unsigned int bpp; /* 16, 24 or 32 */
  21. struct ufont_face *font; /* NULL = 8x16 bitmap text */
  22. int font_px;
  23. };
  24. struct uwm_canvas {
  25. const unsigned short *px; /* RGB565, tightly packed */
  26. unsigned int w, h;
  27. };
  28. /* Pixels written by the compositor primitives; the WM uses it for stats. */
  29. extern unsigned int usurf_pixels;
  30. void usurf_init(struct usurf *s, void *px, unsigned int w, unsigned int h,
  31. unsigned int pitch, unsigned int bpp);
  32. void usurf_fill(struct usurf *s, int x, int y, unsigned int w,
  33. unsigned int h, unsigned int rgb);
  34. void usurf_copy(struct usurf *s, int dx, int dy, int sx, int sy,
  35. unsigned int w, unsigned int h);
  36. void usurf_glyph(struct usurf *s, int x, int y, unsigned char c,
  37. unsigned int fg, unsigned int bg, int transparent,
  38. unsigned int height,
  39. int cx, int cy, unsigned int cw, unsigned int ch);
  40. void usurf_text(struct usurf *s, int x, int y, const char *str,
  41. unsigned int fg,
  42. int cx, int cy, unsigned int cw, unsigned int ch);
  43. unsigned int usurf_text_width(struct usurf *s, const char *str);
  44. void usurf_font_attach(struct usurf *s, const char *path, int px);
  45. void usurf_cells(struct usurf *s, const unsigned short *cells,
  46. unsigned int cols, unsigned int rows,
  47. int x0, int y0,
  48. int cx, int cy, unsigned int cw, unsigned int ch);
  49. void usurf_canvas(struct usurf *s, const struct uwm_canvas *c,
  50. int x0, int y0,
  51. int cx, int cy, unsigned int cw, unsigned int ch);
  52. /* Blit one 16x16 Adwaita coverage mask, tinted with `rgb`, blended over the
  53. * surface. Returns 0 when the bundle (or that id) is not available. */
  54. int usurf_icon(struct usurf *s, int x, int y, enum uwm_icon icon,
  55. unsigned int rgb);
  56. #endif