home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mfb / mfbbstore.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-10  |  4.2 KB  |  138 lines

  1. /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
  2. /***********************************************************
  3.  
  4. Copyright 1987 by the Regents of the University of California
  5. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  6.  
  7.                         All Rights Reserved
  8.  
  9. Permission to use, copy, modify, and distribute this software and its 
  10. documentation for any purpose and without fee is hereby granted, 
  11. provided that the above copyright notice appear in all copies and that
  12. both that copyright notice and this permission notice appear in 
  13. supporting documentation, and that the names of Digital or MIT not be
  14. used in advertising or publicity pertaining to distribution of the
  15. software without specific, written prior permission.  
  16. ******************************************************************/
  17. /* $XConsortium: */
  18.  
  19. #include    "mfb.h"
  20. #include    "X.h"
  21. #include    "mibstore.h"
  22. #include    "regionstr.h"
  23. #include    "scrnintstr.h"
  24. #include    "pixmapstr.h"
  25. #include    "windowstr.h"
  26.  
  27. /*-
  28.  *-----------------------------------------------------------------------
  29.  * mfbSaveAreas --
  30.  *    Function called by miSaveAreas to actually fetch the areas to be
  31.  *    saved into the backing pixmap. This is very simple to do, since
  32.  *    mfbDoBitblt is designed for this very thing. The region to save is
  33.  *    already destination-relative and we're given the offset to the
  34.  *    window origin, so we have only to create an array of points of the
  35.  *    u.l. corners of the boxes in the region translated to the screen
  36.  *    coordinate system and fetch the screen pixmap out of its devPrivate
  37.  *    field....
  38.  *
  39.  * Results:
  40.  *    None.
  41.  *
  42.  * Side Effects:
  43.  *    Data are copied from the screen into the pixmap.
  44.  *
  45.  *-----------------------------------------------------------------------
  46.  */
  47. void
  48. mfbSaveAreas(pPixmap, prgnSave, xorg, yorg)
  49.     PixmapPtr          pPixmap;      /* Backing pixmap */
  50.     RegionPtr          prgnSave;     /* Region to save (pixmap-relative) */
  51.     int                  xorg;            /* X origin of region */
  52.     int                  yorg;            /* Y origin of region */
  53. {
  54.     register DDXPointPtr pPt;
  55.     DDXPointPtr        pPtsInit;
  56.     register BoxPtr    pBox;
  57.     register int    numRects;
  58.     
  59.     numRects = REGION_NUM_RECTS(prgnSave);
  60.     pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects * sizeof(DDXPointRec));
  61.     if (!pPtsInit)
  62.     return;
  63.     
  64.     pBox = REGION_RECTS(prgnSave);
  65.     pPt = pPtsInit;
  66.     while (numRects--)
  67.     {
  68.     pPt->x = pBox->x1 + xorg;
  69.      pPt->y = pBox->y1 + yorg;
  70.      pPt++;
  71.      pBox++;
  72.     }
  73.  
  74.     mfbDoBitblt((DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
  75.         (DrawablePtr)pPixmap,
  76.         GXcopy,
  77.         prgnSave,
  78.         pPtsInit);
  79.  
  80.     DEALLOCATE_LOCAL(pPtsInit);
  81. }
  82.  
  83. /*-
  84.  *-----------------------------------------------------------------------
  85.  * mfbRestoreAreas --
  86.  *    Function called by miRestoreAreas to actually fetch the areas to be
  87.  *    restored from the backing pixmap. This is very simple to do, since
  88.  *    mfbDoBitblt is designed for this very thing. The region to restore is
  89.  *    already destination-relative and we're given the offset to the
  90.  *    window origin, so we have only to create an array of points of the
  91.  *    u.l. corners of the boxes in the region translated to the pixmap
  92.  *    coordinate system and fetch the screen pixmap out of its devPrivate
  93.  *    field....
  94.  *
  95.  * Results:
  96.  *    None.
  97.  *
  98.  * Side Effects:
  99.  *    Data are copied from the pixmap into the screen.
  100.  *
  101.  *-----------------------------------------------------------------------
  102.  */
  103. void
  104. mfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg)
  105.     PixmapPtr          pPixmap;      /* Backing pixmap */
  106.     RegionPtr          prgnRestore;     /* Region to restore (screen-relative)*/
  107.     int                  xorg;            /* X origin of window */
  108.     int                  yorg;            /* Y origin of window */
  109. {
  110.     register DDXPointPtr pPt;
  111.     DDXPointPtr        pPtsInit;
  112.     register BoxPtr    pBox;
  113.     register int    numRects;
  114.     
  115.     numRects = REGION_NUM_RECTS(prgnRestore);
  116.     pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects*sizeof(DDXPointRec));
  117.     if (!pPtsInit)
  118.     return;
  119.     
  120.     pBox = REGION_RECTS(prgnRestore);
  121.     pPt = pPtsInit;
  122.     while (numRects--)
  123.     {
  124.     pPt->x = pBox->x1 - xorg;
  125.      pPt->y = pBox->y1 - yorg;
  126.      pPt++;
  127.      pBox++;
  128.     }
  129.  
  130.     mfbDoBitblt((DrawablePtr)pPixmap,
  131.         (DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
  132.         GXcopy,
  133.         prgnRestore,
  134.         pPtsInit);
  135.  
  136.     DEALLOCATE_LOCAL(pPtsInit);
  137. }
  138.