lhide.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <draw.h>
  4. #include <memdraw.h>
  5. #include <memlayer.h>
  6. #include <pool.h>
  7. /*
  8. * Hide puts that portion of screenr now on the screen into the window's save area.
  9. * Expose puts that portion of screenr now in the save area onto the screen.
  10. *
  11. * Hide and Expose both require that the layer structures in the screen
  12. * match the geometry they are being asked to update, that is, they update the
  13. * save area (hide) or screen (expose) based on what those structures tell them.
  14. * This means they must be called at the correct time during window shuffles.
  15. */
  16. static
  17. void
  18. lhideop(Memimage *src, Rectangle screenr, Rectangle clipr, void *etc, int insave)
  19. {
  20. Rectangle r;
  21. Memlayer *l;
  22. USED(clipr.min.x);
  23. USED(insave);
  24. l = etc;
  25. if(src != l->save){ /* do nothing if src is already in save area */
  26. r = rectsubpt(screenr, l->delta);
  27. memdraw(l->save, r, src, screenr.min, nil, screenr.min, S);
  28. }
  29. }
  30. void
  31. memlhide(Memimage *i, Rectangle screenr)
  32. {
  33. if(i->layer->save == nil)
  34. return;
  35. if(rectclip(&screenr, i->layer->screen->image->r) == 0)
  36. return;
  37. _memlayerop(lhideop, i, screenr, screenr, i->layer);
  38. }
  39. static
  40. void
  41. lexposeop(Memimage *dst, Rectangle screenr, Rectangle clipr, void *etc, int insave)
  42. {
  43. Memlayer *l;
  44. Rectangle r;
  45. USED(clipr.min.x);
  46. if(insave) /* if dst is save area, don't bother */
  47. return;
  48. l = etc;
  49. r = rectsubpt(screenr, l->delta);
  50. if(l->save)
  51. memdraw(dst, screenr, l->save, r.min, nil, r.min, S);
  52. else
  53. l->refreshfn(dst, r, l->refreshptr);
  54. }
  55. void
  56. memlexpose(Memimage *i, Rectangle screenr)
  57. {
  58. if(rectclip(&screenr, i->layer->screen->image->r) == 0)
  59. return;
  60. _memlayerop(lexposeop, i, screenr, screenr, i->layer);
  61. }