lhide.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <draw.h>
  12. #include <memdraw.h>
  13. #include <memlayer.h>
  14. /*
  15. * Hide puts that portion of screenr now on the screen into the window's save area.
  16. * Expose puts that portion of screenr now in the save area onto the screen.
  17. *
  18. * Hide and Expose both require that the layer structures in the screen
  19. * match the geometry they are being asked to update, that is, they update the
  20. * save area (hide) or screen (expose) based on what those structures tell them.
  21. * This means they must be called at the correct time during window shuffles.
  22. */
  23. static
  24. void
  25. lhideop(Memimage *src, Rectangle screenr, Rectangle clipr, void *etc, int insave)
  26. {
  27. Rectangle r;
  28. Memlayer *l;
  29. USED(clipr.min.x);
  30. USED(insave);
  31. l = etc;
  32. if(src != l->save){ /* do nothing if src is already in save area */
  33. r = rectsubpt(screenr, l->delta);
  34. memdraw(l->save, r, src, screenr.min, nil, screenr.min, S);
  35. }
  36. }
  37. void
  38. memlhide(Memimage *i, Rectangle screenr)
  39. {
  40. if(i->layer->save == nil)
  41. return;
  42. if(rectclip(&screenr, i->layer->screen->image->r) == 0)
  43. return;
  44. _memlayerop(lhideop, i, screenr, screenr, i->layer);
  45. }
  46. static
  47. void
  48. lexposeop(Memimage *dst, Rectangle screenr, Rectangle clipr, void *etc, int insave)
  49. {
  50. Memlayer *l;
  51. Rectangle r;
  52. USED(clipr.min.x);
  53. if(insave) /* if dst is save area, don't bother */
  54. return;
  55. l = etc;
  56. r = rectsubpt(screenr, l->delta);
  57. if(l->save)
  58. memdraw(dst, screenr, l->save, r.min, nil, r.min, S);
  59. else
  60. l->refreshfn(dst, r, l->refreshptr);
  61. }
  62. void
  63. memlexpose(Memimage *i, Rectangle screenr)
  64. {
  65. if(rectclip(&screenr, i->layer->screen->image->r) == 0)
  66. return;
  67. _memlayerop(lexposeop, i, screenr, screenr, i->layer);
  68. }