]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/mfb/mfbbstore.c
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / programs / Xserver / mfb / mfbbstore.c
1 /* $XConsortium: mfbbstore.c,v 5.7 94/04/17 20:28:18 dpw Exp $ */
2 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
3 /*
4
5 Copyright (c) 1987  X Consortium
6
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
14
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 OTHER DEALINGS IN THE SOFTWARE.
25
26 Except as contained in this notice, the name of the X Consortium shall
27 not be used in advertising or otherwise to promote the sale, use or
28 other dealings in this Software without prior written authorization
29 from the X Consortium.
30
31 */
32
33 #include    "mfb.h"
34 #include    "X.h"
35 #include    "mibstore.h"
36 #include    "regionstr.h"
37 #include    "scrnintstr.h"
38 #include    "pixmapstr.h"
39 #include    "windowstr.h"
40
41 /*-
42  *-----------------------------------------------------------------------
43  * mfbSaveAreas --
44  *      Function called by miSaveAreas to actually fetch the areas to be
45  *      saved into the backing pixmap. This is very simple to do, since
46  *      mfbDoBitblt is designed for this very thing. The region to save is
47  *      already destination-relative and we're given the offset to the
48  *      window origin, so we have only to create an array of points of the
49  *      u.l. corners of the boxes in the region translated to the screen
50  *      coordinate system and fetch the screen pixmap out of its devPrivate
51  *      field....
52  *
53  * Results:
54  *      None.
55  *
56  * Side Effects:
57  *      Data are copied from the screen into the pixmap.
58  *
59  *-----------------------------------------------------------------------
60  */
61 void
62 mfbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
63     PixmapPtr           pPixmap;        /* Backing pixmap */
64     RegionPtr           prgnSave;       /* Region to save (pixmap-relative) */
65     int                 xorg;           /* X origin of region */
66     int                 yorg;           /* Y origin of region */
67     WindowPtr           pWin;
68 {
69     register DDXPointPtr pPt;
70     DDXPointPtr         pPtsInit;
71     register BoxPtr     pBox;
72     register int        numRects;
73     
74     numRects = REGION_NUM_RECTS(prgnSave);
75     pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects * sizeof(DDXPointRec));
76     if (!pPtsInit)
77         return;
78     
79     pBox = REGION_RECTS(prgnSave);
80     pPt = pPtsInit;
81     while (numRects--)
82     {
83         pPt->x = pBox->x1 + xorg;
84         pPt->y = pBox->y1 + yorg;
85         pPt++;
86         pBox++;
87     }
88
89     mfbDoBitblt((DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
90                 (DrawablePtr)pPixmap,
91                 GXcopy,
92                 prgnSave,
93                 pPtsInit);
94
95     DEALLOCATE_LOCAL(pPtsInit);
96 }
97
98 /*-
99  *-----------------------------------------------------------------------
100  * mfbRestoreAreas --
101  *      Function called by miRestoreAreas to actually fetch the areas to be
102  *      restored from the backing pixmap. This is very simple to do, since
103  *      mfbDoBitblt is designed for this very thing. The region to restore is
104  *      already destination-relative and we're given the offset to the
105  *      window origin, so we have only to create an array of points of the
106  *      u.l. corners of the boxes in the region translated to the pixmap
107  *      coordinate system and fetch the screen pixmap out of its devPrivate
108  *      field....
109  *
110  * Results:
111  *      None.
112  *
113  * Side Effects:
114  *      Data are copied from the pixmap into the screen.
115  *
116  *-----------------------------------------------------------------------
117  */
118 void
119 mfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
120     PixmapPtr           pPixmap;        /* Backing pixmap */
121     RegionPtr           prgnRestore;    /* Region to restore (screen-relative)*/
122     int                 xorg;           /* X origin of window */
123     int                 yorg;           /* Y origin of window */
124     WindowPtr           pWin;
125 {
126     register DDXPointPtr pPt;
127     DDXPointPtr         pPtsInit;
128     register BoxPtr     pBox;
129     register int        numRects;
130     
131     numRects = REGION_NUM_RECTS(prgnRestore);
132     pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects*sizeof(DDXPointRec));
133     if (!pPtsInit)
134         return;
135     
136     pBox = REGION_RECTS(prgnRestore);
137     pPt = pPtsInit;
138     while (numRects--)
139     {
140         pPt->x = pBox->x1 - xorg;
141         pPt->y = pBox->y1 - yorg;
142         pPt++;
143         pBox++;
144     }
145
146     mfbDoBitblt((DrawablePtr)pPixmap,
147                 (DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
148                 GXcopy,
149                 prgnRestore,
150                 pPtsInit);
151
152     DEALLOCATE_LOCAL(pPtsInit);
153 }