blit.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Blit backend: the drawing operations the window manager uses, behind a
  2. * vtable so a GPU/driver implementation can replace the software one without
  3. * touching the WM. Ops paint into the current render target (vga_target());
  4. * copy() and present() work on the screen.
  5. *
  6. * The software table is the only backend today; it is also the fallback for
  7. * every machine without (or before) a usable accelerator. */
  8. #ifndef BLIT_H
  9. #define BLIT_H
  10. struct surface;
  11. struct gfx_canvas;
  12. struct blit_ops {
  13. const char *name;
  14. /* Solid fill with a packed 0xRRGGBB colour. */
  15. void (*fill)(unsigned int x, unsigned int y, unsigned int w,
  16. unsigned int h, unsigned int rgb);
  17. /* Overlap-safe rectangle copy inside the target. */
  18. void (*copy)(unsigned int dx, unsigned int dy, unsigned int sx,
  19. unsigned int sy, unsigned int w, unsigned int h);
  20. /* Blend an ARGB8888 source surface onto the target: uniform alpha for
  21. * 255, per-pixel source alpha otherwise. Used by the layer
  22. * compositor. */
  23. void (*blend)(unsigned int x, unsigned int y, unsigned int w,
  24. unsigned int h, const struct surface *src,
  25. unsigned int sx, unsigned int sy, unsigned int alpha);
  26. /* Canvas (RGB565) blit clipped to (cx, cy, cw, ch), scaled to the
  27. * target's pixel format. */
  28. void (*canvas)(const struct gfx_canvas *c, unsigned int x,
  29. unsigned int y, unsigned int cx, unsigned int cy,
  30. unsigned int cw, unsigned int ch);
  31. /* Make drawn content visible: copy the pending damage rects (up to
  32. * max_bytes, 0 = everything), or flip when the backend has two
  33. * buffers. */
  34. void (*present)(unsigned int max_bytes);
  35. /* Wait for the next frame and swap (no-op for the single-buffered
  36. * software path). */
  37. void (*flip)(void);
  38. };
  39. extern const struct blit_ops *blit; /* the active backend */
  40. extern const struct blit_ops blit_software;
  41. #endif