uwm_lib.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #include "app_icon_abi.h"
  9. struct ufont_face;
  10. /* Icon ids from the same list the ngui tools use; the order is the bundle
  11. * order. The WM does not link ngui, so it generates its own ids. */
  12. #define UWM_ICON_ENUM_(e, name, file) UWM_ICON_##e,
  13. enum uwm_icon {
  14. ICON_LIST(UWM_ICON_ENUM_)
  15. UWM_ICON_COUNT
  16. };
  17. #undef UWM_ICON_ENUM_
  18. struct usurf {
  19. unsigned char *px;
  20. unsigned int w, h, pitch;
  21. unsigned int bpp; /* 16, 24 or 32 */
  22. struct ufont_face *font; /* NULL = 8x16 bitmap text */
  23. int font_px;
  24. };
  25. struct uwm_canvas {
  26. const unsigned short *px; /* RGB565, tightly packed */
  27. unsigned int w, h;
  28. };
  29. /* Pixels written by the compositor primitives; the WM uses it for stats. */
  30. extern unsigned int usurf_pixels;
  31. void usurf_init(struct usurf *s, void *px, unsigned int w, unsigned int h,
  32. unsigned int pitch, unsigned int bpp);
  33. void usurf_fill(struct usurf *s, int x, int y, unsigned int w,
  34. unsigned int h, unsigned int rgb);
  35. void usurf_copy(struct usurf *s, int dx, int dy, int sx, int sy,
  36. unsigned int w, unsigned int h);
  37. void usurf_glyph(struct usurf *s, int x, int y, unsigned char c,
  38. unsigned int fg, unsigned int bg, int transparent,
  39. unsigned int height,
  40. int cx, int cy, unsigned int cw, unsigned int ch);
  41. void usurf_text(struct usurf *s, int x, int y, const char *str,
  42. unsigned int fg,
  43. int cx, int cy, unsigned int cw, unsigned int ch);
  44. unsigned int usurf_text_width(struct usurf *s, const char *str);
  45. void usurf_font_attach(struct usurf *s, const char *path, int px);
  46. void usurf_cells(struct usurf *s, const unsigned short *cells,
  47. unsigned int cols, unsigned int rows,
  48. int x0, int y0,
  49. int cx, int cy, unsigned int cw, unsigned int ch);
  50. void usurf_canvas(struct usurf *s, const struct uwm_canvas *c,
  51. int x0, int y0,
  52. int cx, int cy, unsigned int cw, unsigned int ch);
  53. /* Blit one 16x16 Adwaita coverage mask, tinted with `rgb`, blended over the
  54. * surface. Returns 0 when the bundle (or that id) is not available. */
  55. int usurf_icon(struct usurf *s, int x, int y, enum uwm_icon icon,
  56. unsigned int rgb);
  57. /* Icon blit clipped to (cx,cy,cw,ch), in screen coordinates. */
  58. int usurf_icon_clip(struct usurf *s, int x, int y, enum uwm_icon icon,
  59. unsigned int rgb, int cx, int cy,
  60. unsigned int cw, unsigned int ch);
  61. /* Soft drop shadow around a window rectangle: `spread` pixels outward,
  62. * darkest next to the edge, clipped to (cx,cy,cw,ch). The window interior
  63. * is not modified. */
  64. void usurf_window_shadow(struct usurf *s, int wx, int wy, int ww, int wh,
  65. int spread, int cx, int cy,
  66. unsigned int cw, unsigned int ch);
  67. /* Draw one full-colour app icon from /ramfs/icons/apps96.icn, scaled to
  68. * size x size and centred at (x, y). Returns 0 when the bundle (or that
  69. * id) is not available, so the caller can fall back to a letter tile. */
  70. int usurf_app_icon(struct usurf *s, int x, int y, int size,
  71. enum app_icon icon);
  72. /* A rounded rectangle blended over the surface at `alpha` (0..255). The
  73. * dock uses it for its translucent panel and the hover label. */
  74. void usurf_fill_round_alpha(struct usurf *s, int x, int y, int w, int h,
  75. int radius, unsigned int rgb,
  76. unsigned int alpha);
  77. #endif