First import
[xorg_rtime.git] / xorg-server-1.4 / mfb / mfbbstore.c
blob784df4e843fe9fa687b5397bc32e5212a43e16ec
1 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2 /*
4 Copyright 1987, 1998 The Open Group
6 Permission to use, copy, modify, distribute, and sell this software and its
7 documentation for any purpose is hereby granted without fee, provided that
8 the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
10 documentation.
12 The above copyright notice and this permission notice shall be included
13 in all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 OTHER DEALINGS IN THE SOFTWARE.
23 Except as contained in this notice, the name of The Open Group shall
24 not be used in advertising or otherwise to promote the sale, use or
25 other dealings in this Software without prior written authorization
26 from The Open Group.
30 #ifdef HAVE_DIX_CONFIG_H
31 #include <dix-config.h>
32 #endif
34 #include "mfb.h"
35 #include <X11/X.h>
36 #include "mibstore.h"
37 #include "regionstr.h"
38 #include "scrnintstr.h"
39 #include "pixmapstr.h"
40 #include "windowstr.h"
42 /*-
43 *-----------------------------------------------------------------------
44 * mfbSaveAreas --
45 * Function called by miSaveAreas to actually fetch the areas to be
46 * saved into the backing pixmap. This is very simple to do, since
47 * mfbDoBitblt is designed for this very thing. The region to save is
48 * already destination-relative and we're given the offset to the
49 * window origin, so we have only to create an array of points of the
50 * u.l. corners of the boxes in the region translated to the screen
51 * coordinate system and fetch the screen pixmap out of its devPrivate
52 * field....
54 * Results:
55 * None.
57 * Side Effects:
58 * Data are copied from the screen into the pixmap.
60 *-----------------------------------------------------------------------
62 void
63 mfbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
64 PixmapPtr pPixmap; /* Backing pixmap */
65 RegionPtr prgnSave; /* Region to save (pixmap-relative) */
66 int xorg; /* X origin of region */
67 int yorg; /* Y origin of region */
68 WindowPtr pWin;
70 register DDXPointPtr pPt;
71 DDXPointPtr pPtsInit;
72 register BoxPtr pBox;
73 register int numRects;
75 numRects = REGION_NUM_RECTS(prgnSave);
76 pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects * sizeof(DDXPointRec));
77 if (!pPtsInit)
78 return;
80 pBox = REGION_RECTS(prgnSave);
81 pPt = pPtsInit;
82 while (numRects--)
84 pPt->x = pBox->x1 + xorg;
85 pPt->y = pBox->y1 + yorg;
86 pPt++;
87 pBox++;
90 mfbDoBitblt((DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
91 (DrawablePtr)pPixmap,
92 GXcopy,
93 prgnSave,
94 pPtsInit);
96 DEALLOCATE_LOCAL(pPtsInit);
99 /*-
100 *-----------------------------------------------------------------------
101 * mfbRestoreAreas --
102 * Function called by miRestoreAreas to actually fetch the areas to be
103 * restored from the backing pixmap. This is very simple to do, since
104 * mfbDoBitblt is designed for this very thing. The region to restore is
105 * already destination-relative and we're given the offset to the
106 * window origin, so we have only to create an array of points of the
107 * u.l. corners of the boxes in the region translated to the pixmap
108 * coordinate system and fetch the screen pixmap out of its devPrivate
109 * field....
111 * Results:
112 * None.
114 * Side Effects:
115 * Data are copied from the pixmap into the screen.
117 *-----------------------------------------------------------------------
119 void
120 mfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
121 PixmapPtr pPixmap; /* Backing pixmap */
122 RegionPtr prgnRestore; /* Region to restore (screen-relative)*/
123 int xorg; /* X origin of window */
124 int yorg; /* Y origin of window */
125 WindowPtr pWin;
127 register DDXPointPtr pPt;
128 DDXPointPtr pPtsInit;
129 register BoxPtr pBox;
130 register int numRects;
132 numRects = REGION_NUM_RECTS(prgnRestore);
133 pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects*sizeof(DDXPointRec));
134 if (!pPtsInit)
135 return;
137 pBox = REGION_RECTS(prgnRestore);
138 pPt = pPtsInit;
139 while (numRects--)
141 pPt->x = pBox->x1 - xorg;
142 pPt->y = pBox->y1 - yorg;
143 pPt++;
144 pBox++;
147 mfbDoBitblt((DrawablePtr)pPixmap,
148 (DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
149 GXcopy,
150 prgnRestore,
151 pPtsInit);
153 DEALLOCATE_LOCAL(pPtsInit);