x_closepl.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. #include "sys-defines.h"
  16. #include "extern.h"
  17. bool
  18. _pl_x_end_page (S___(Plotter *_plotter))
  19. {
  20. /* Xdrawable Plotters support double buffering `by hand', so check for it */
  21. if (_plotter->x_double_buffering == X_DBL_BUF_BY_HAND)
  22. /* copy final frame of buffered graphics from pixmap serving as
  23. graphics buffer, to window */
  24. {
  25. /* compute rectangle size; note flipped-y convention */
  26. int window_width = (_plotter->data->imax - _plotter->data->imin) + 1;
  27. int window_height = (_plotter->data->jmin - _plotter->data->jmax) + 1;
  28. if (_plotter->x_drawable1)
  29. XCopyArea (_plotter->x_dpy, _plotter->x_drawable3, _plotter->x_drawable1,
  30. _plotter->drawstate->x_gc_bg,
  31. 0, 0,
  32. (unsigned int)window_width, (unsigned int)window_height,
  33. 0, 0);
  34. if (_plotter->x_drawable2)
  35. XCopyArea (_plotter->x_dpy, _plotter->x_drawable3, _plotter->x_drawable2,
  36. _plotter->drawstate->x_gc_bg,
  37. 0, 0,
  38. (unsigned int)window_width, (unsigned int)window_height,
  39. 0, 0);
  40. /* no more need for pixmap, so free it (if there is one) */
  41. if (_plotter->x_drawable1 || _plotter->x_drawable2)
  42. XFreePixmap (_plotter->x_dpy, _plotter->x_drawable3);
  43. }
  44. /* do teardown of X-specific elements of the first drawing state on the
  45. drawing state stack */
  46. _pl_x_delete_gcs_from_first_drawing_state (S___(_plotter));
  47. return true;
  48. }
  49. void
  50. _pl_x_delete_gcs_from_first_drawing_state (S___(Plotter *_plotter))
  51. {
  52. /* free graphics contexts, if we have them -- and to have them, must have
  53. at least one drawable (see x_savestate.c) */
  54. if (_plotter->x_drawable1 || _plotter->x_drawable2)
  55. {
  56. XFreeGC (_plotter->x_dpy, _plotter->drawstate->x_gc_fg);
  57. XFreeGC (_plotter->x_dpy, _plotter->drawstate->x_gc_fill);
  58. XFreeGC (_plotter->x_dpy, _plotter->drawstate->x_gc_bg);
  59. }
  60. }