]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/cfb/cfbbstore.c
Support RDP5 logon packets.
[rdpsrv] / Xserver / programs / Xserver / cfb / cfbbstore.c
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.8 93/12/13 17:21:51 dpw 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, pWin)
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     WindowPtr           pWin;
57 {
58     register DDXPointPtr pPt;
59     DDXPointPtr         pPtsInit;
60     register BoxPtr     pBox;
61     register int        i;
62     ScreenPtr           pScreen = pPixmap->drawable.pScreen;
63     PixmapPtr           pScrPix;
64     
65     i = REGION_NUM_RECTS(prgnSave);
66     pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
67     if (!pPtsInit)
68         return;
69     
70     pBox = REGION_RECTS(prgnSave);
71     pPt = pPtsInit;
72     while (--i >= 0) {
73         pPt->x = pBox->x1 + xorg;
74         pPt->y = pBox->y1 + yorg;
75         pPt++;
76         pBox++;
77     }
78
79 #ifdef CFB_NEED_SCREEN_PRIVATE
80     pScrPix = (PixmapPtr) pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
81 #else
82     pScrPix = (PixmapPtr) pScreen->devPrivate;
83 #endif
84
85     cfbDoBitbltCopy((DrawablePtr) pScrPix, (DrawablePtr)pPixmap,
86                     GXcopy, prgnSave, pPtsInit, ~0L);
87
88     DEALLOCATE_LOCAL (pPtsInit);
89 }
90
91 /*-
92  *-----------------------------------------------------------------------
93  * cfbRestoreAreas --
94  *      Function called by miRestoreAreas to actually fetch the areas to be
95  *      restored from the backing pixmap. This is very simple to do, since
96  *      cfbDoBitblt is designed for this very thing. The region to restore is
97  *      already destination-relative and we're given the offset to the
98  *      window origin, so we have only to create an array of points of the
99  *      u.l. corners of the boxes in the region translated to the pixmap
100  *      coordinate system and fetch the screen pixmap out of its devPrivate
101  *      field....
102  *
103  * Results:
104  *      None.
105  *
106  * Side Effects:
107  *      Data are copied from the pixmap into the screen.
108  *
109  *-----------------------------------------------------------------------
110  */
111 void
112 cfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
113     PixmapPtr           pPixmap;        /* Backing pixmap */
114     RegionPtr           prgnRestore;    /* Region to restore (screen-relative)*/
115     int                 xorg;           /* X origin of window */
116     int                 yorg;           /* Y origin of window */
117     WindowPtr           pWin;
118 {
119     register DDXPointPtr pPt;
120     DDXPointPtr         pPtsInit;
121     register BoxPtr     pBox;
122     register int        i;
123     ScreenPtr           pScreen = pPixmap->drawable.pScreen;
124     PixmapPtr           pScrPix;
125     
126     i = REGION_NUM_RECTS(prgnRestore);
127     pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec));
128     if (!pPtsInit)
129         return;
130     
131     pBox = REGION_RECTS(prgnRestore);
132     pPt = pPtsInit;
133     while (--i >= 0) {
134         pPt->x = pBox->x1 - xorg;
135         pPt->y = pBox->y1 - yorg;
136         pPt++;
137         pBox++;
138     }
139
140 #ifdef CFB_NEED_SCREEN_PRIVATE
141     pScrPix = (PixmapPtr) pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
142 #else
143     pScrPix = (PixmapPtr) pScreen->devPrivate;
144 #endif
145
146     cfbDoBitbltCopy((DrawablePtr)pPixmap, (DrawablePtr) pScrPix,
147                     GXcopy, prgnRestore, pPtsInit, ~0L);
148
149     DEALLOCATE_LOCAL (pPtsInit);
150 }