First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / xf4bpp / ppcWindow.c
blob01768d9ff78066cd1407ff28ae6e74dc383544dd
1 /*
3 Copyright (c) 1987 X Consortium
5 Permission is hereby granted, free of charge, to any person obtaining
6 a copy of this software and associated documentation files (the
7 "Software"), to deal in the Software without restriction, including
8 without limitation the rights to use, copy, modify, merge, publish,
9 distribute, sublicense, and/or sell copies of the Software, and to
10 permit persons to whom the Software is furnished to do so, subject to
11 the following conditions:
13 The above copyright notice and this permission notice shall be included
14 in all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 OTHER DEALINGS IN THE SOFTWARE.
24 Except as contained in this notice, the name of the X Consortium shall
25 not be used in advertising or otherwise to promote the sale, use or
26 other dealings in this Software without prior written authorization
27 from the X Consortium.
30 Copyright IBM Corporation 1987,1988,1989
31 All Rights Reserved
33 Permission to use, copy, modify, and distribute this software and its
34 documentation for any purpose and without fee is hereby granted,
35 provided that the above copyright notice appear in all copies and that
36 both that copyright notice and this permission notice appear in
37 supporting documentation, and that the name of IBM not be
38 used in advertising or publicity pertaining to distribution of the
39 software without specific, written prior permission.
41 IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
42 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
43 IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
44 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
45 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
46 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47 SOFTWARE.
50 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
51 All Rights Reserved
53 Permission to use, copy, modify, and distribute this software and its
54 documentation for any purpose and without fee is hereby granted,
55 provided that the above copyright notice appear in all copies and that
56 both that copyright notice and this permission notice appear in
57 supporting documentation, and that the name of Digital not be
58 used in advertising or publicity pertaining to distribution of the
59 software without specific, written prior permission.
61 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
62 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
63 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
64 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
65 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
66 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
67 SOFTWARE.
71 #ifdef HAVE_XORG_CONFIG_H
72 #include <xorg-config.h>
73 #endif
75 #include <stdlib.h>
77 #include "xf4bpp.h"
78 #include "mfbmap.h"
79 #include "mfb.h"
80 #include "scrnintstr.h"
81 #include "ibmTrace.h"
84 xf4bppCopyWindow copies only the parts of the destination that are
85 visible in the source.
88 void
89 xf4bppCopyWindow(pWin, ptOldOrg, prgnSrc)
90 register WindowPtr pWin ;
91 DDXPointRec ptOldOrg ;
92 RegionPtr prgnSrc ;
94 RegionPtr prgnDst ;
95 register BoxPtr pbox ;
96 register int dx, dy ;
97 register int nbox ;
98 register int pm ;
100 BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew ;
101 /* temporaries for shuffling rectangles */
103 TRACE(("xf4bppCopyWindow(pWin= 0x%x, ptOldOrg= 0x%x, prgnSrc= 0x%x)\n", pWin, ptOldOrg, prgnSrc)) ;
106 dx = ptOldOrg.x - pWin->drawable.x ;
107 dy = ptOldOrg.y - pWin->drawable.y ;
108 REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
110 prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
111 REGION_INTERSECT(pWin->drawable.pScreen, prgnDst,
112 &pWin->borderClip, prgnSrc);
114 if ( !( nbox = REGION_NUM_RECTS(prgnDst) ) )
115 return;
117 pbox = REGION_RECTS(prgnDst);
119 pboxNew = 0 ;
120 if ( nbox > 1 ) {
121 if ( dy < 0 ) {
122 if ( dx > 0 ) {
123 /* walk source bottom to top */
124 /* keep ordering in each band, reverse order of bands */
125 if ( !( pboxNew =
126 (BoxPtr) ALLOCATE_LOCAL( sizeof( BoxRec ) * nbox ) ) )
127 return ;
128 pboxBase = pboxNext = pbox+nbox - 1 ;
129 while ( pboxBase >= pbox ) {
130 while ( ( pboxNext >= pbox )
131 && ( pboxBase->y1 == pboxNext->y1 ) )
132 pboxNext-- ;
133 pboxTmp = pboxNext + 1 ;
134 while ( pboxTmp <= pboxBase )
135 *pboxNew++ = *pboxTmp++ ;
136 pboxBase = pboxNext ;
138 pboxNew -= nbox ;
139 pbox = pboxNew ;
141 else { /* dx <= 0 */
142 /* we can just reverse the entire list in place */
143 /* Do three-position swaps */
144 BoxRec tmpBox ;
146 pboxBase = pbox ;
147 pboxNext = pbox + nbox - 1 ;
148 while ( pboxBase < pboxNext ) {
149 /* ****** Warning Structure Assignment !! ****** */
150 tmpBox = *pboxBase ;
151 *pboxBase = *pboxNext ;
152 *pboxNext = tmpBox ;
153 pboxBase++ ;
154 pboxNext-- ;
158 else if ( dx < 0 ) {
159 /* walk source right to left */
160 /* reverse order of rects in each band */
161 if ( !( pboxNew = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox) ) )
162 return ;
163 pboxBase = pboxNext = pbox ;
164 while (pboxBase < pbox+nbox)
166 while ((pboxNext < pbox+nbox) &&
167 (pboxNext->y1 == pboxBase->y1))
168 pboxNext++ ;
169 pboxTmp = pboxNext ;
170 while (pboxTmp != pboxBase)
171 *pboxNew++ = *--pboxTmp ;
172 pboxBase = pboxNext ;
174 pboxNew -= nbox ;
175 pbox = pboxNew ;
177 } /* END if nbox > 1 */
180 * call blit several times, the parms are:
181 * blit( alu,rplanes, wplanes, srcx, srcy, destx, desty, width, height ) ;
184 pm = ( 1 << pWin->drawable.depth ) - 1 ;
185 for ( ; nbox-- ; pbox++ )
186 xf4bppBitBlt( pWin, GXcopy, pm,
187 pbox->x1 + dx, pbox->y1 + dy,
188 pbox->x1, pbox->y1,
189 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1) ;
191 /* free up stuff */
192 if ( pboxNew )
193 DEALLOCATE_LOCAL( pboxNew ) ;
195 REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
198 Bool xf4bppPositionWindow(pWin, x, y)
199 register WindowPtr pWin ;
200 register int x, y ;
202 return TRUE ;
205 Bool
206 xf4bppDestroyWindow(pWin)
207 register WindowPtr pWin ;
209 return pWin ? TRUE : FALSE ;
212 /* As The Name Says -- Used For ega, vga and apa8c */
213 Bool
214 xf4bppCreateWindowForXYhardware(pWin)
215 register WindowPtr pWin ;
217 register mfbPrivWin *pPrivWin;
219 TRACE(("xf4bppCreateWindowForXYhardware (pWin= 0x%x)\n", pWin));
221 pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbGetWindowPrivateIndex()].ptr);
222 pPrivWin->pRotatedBorder = NullPixmap;
223 pPrivWin->pRotatedBackground = NullPixmap;
224 pPrivWin->fastBackground = 0;
225 pPrivWin->fastBorder = 0;
227 return TRUE;