home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / cfb / cfbbstore.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-10  |  4.0 KB  |  140 lines

  1. /*-
  2.  * cfbbstore.c --
  3.  *    Functions required by the backing-store implementation in MI.
  4.  *
  5.  * Copyright (c) 1987 by the Regents of the University of California
  6.  *
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  *
  16.  */
  17. #ifndef lint
  18. static char rcsid[] =
  19. "$XConsortium: cfbbstore.c,v 5.5 90/03/10 15:48:40 keith Exp $ SPRITE (Berkeley)";
  20. #endif
  21.  
  22. #include    "cfb.h"
  23. #include    "X.h"
  24. #include    "mibstore.h"
  25. #include    "regionstr.h"
  26. #include    "scrnintstr.h"
  27. #include    "pixmapstr.h"
  28. #include    "windowstr.h"
  29.  
  30. /*-
  31.  *-----------------------------------------------------------------------
  32.  * cfbSaveAreas --
  33.  *    Function called by miSaveAreas to actually fetch the areas to be
  34.  *    saved into the backing pixmap. This is very simple to do, since
  35.  *    cfbDoBitblt is designed for this very thing. The region to save is
  36.  *    already destination-relative and we're given the offset to the
  37.  *    window origin, so we have only to create an array of points of the
  38.  *    u.l. corners of the boxes in the region translated to the screen
  39.  *    coordinate system and fetch the screen pixmap out of its devPrivate
  40.  *    field....
  41.  *
  42.  * Results:
  43.  *    None.
  44.  *
  45.  * Side Effects:
  46.  *    Data are copied from the screen into the pixmap.
  47.  *
  48.  *-----------------------------------------------------------------------
  49.  */
  50. void
  51. cfbSaveAreas(pPixmap, prgnSave, xorg, yorg)
  52.     PixmapPtr          pPixmap;      /* Backing pixmap */
  53.     RegionPtr          prgnSave;     /* Region to save (pixmap-relative) */
  54.     int                  xorg;            /* X origin of region */
  55.     int                  yorg;            /* Y origin of region */
  56. {
  57.     register DDXPointPtr pPt;
  58.     DDXPointPtr        pPtsInit;
  59.     register BoxPtr    pBox;
  60.     register int    i;
  61.     
  62.     i = REGION_NUM_RECTS(prgnSave);
  63.     pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
  64.     if (!pPtsInit)
  65.     return;
  66.     
  67.     pBox = REGION_RECTS(prgnSave);
  68.     pPt = pPtsInit;
  69.     while (--i >= 0) {
  70.     pPt->x = pBox->x1 + xorg;
  71.     pPt->y = pBox->y1 + yorg;
  72.     pPt++;
  73.     pBox++;
  74.     }
  75.  
  76.  
  77.     cfbDoBitbltCopy((DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
  78.         (DrawablePtr)pPixmap,
  79.         GXcopy,
  80.         prgnSave,
  81.         pPtsInit, ~0L);
  82.  
  83.     DEALLOCATE_LOCAL (pPtsInit);
  84. }
  85.  
  86. /*-
  87.  *-----------------------------------------------------------------------
  88.  * cfbRestoreAreas --
  89.  *    Function called by miRestoreAreas to actually fetch the areas to be
  90.  *    restored from the backing pixmap. This is very simple to do, since
  91.  *    cfbDoBitblt is designed for this very thing. The region to restore is
  92.  *    already destination-relative and we're given the offset to the
  93.  *    window origin, so we have only to create an array of points of the
  94.  *    u.l. corners of the boxes in the region translated to the pixmap
  95.  *    coordinate system and fetch the screen pixmap out of its devPrivate
  96.  *    field....
  97.  *
  98.  * Results:
  99.  *    None.
  100.  *
  101.  * Side Effects:
  102.  *    Data are copied from the pixmap into the screen.
  103.  *
  104.  *-----------------------------------------------------------------------
  105.  */
  106. void
  107. cfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg)
  108.     PixmapPtr          pPixmap;      /* Backing pixmap */
  109.     RegionPtr          prgnRestore;     /* Region to restore (screen-relative)*/
  110.     int                  xorg;            /* X origin of window */
  111.     int                  yorg;            /* Y origin of window */
  112. {
  113.     register DDXPointPtr pPt;
  114.     DDXPointPtr        pPtsInit;
  115.     register BoxPtr    pBox;
  116.     register int    i;
  117.     
  118.     i = REGION_NUM_RECTS(prgnRestore);
  119.     pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec));
  120.     if (!pPtsInit)
  121.     return;
  122.     
  123.     pBox = REGION_RECTS(prgnRestore);
  124.     pPt = pPtsInit;
  125.     while (--i >= 0) {
  126.     pPt->x = pBox->x1 - xorg;
  127.     pPt->y = pBox->y1 - yorg;
  128.     pPt++;
  129.     pBox++;
  130.     }
  131.  
  132.  
  133.     cfbDoBitbltCopy((DrawablePtr)pPixmap,
  134.         (DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
  135.         GXcopy,
  136.         prgnRestore,
  137.         pPtsInit, ~0L);
  138.     DEALLOCATE_LOCAL (pPtsInit);
  139. }
  140.