~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/xfree86/xf4bpp/ppcWindow.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcWindow.c,v 1.3 1999/06/06 08:49:06 dawes Exp $ */
 
2
/*
 
3
 
 
4
Copyright (c) 1987  X Consortium
 
5
 
 
6
Permission is hereby granted, free of charge, to any person obtaining
 
7
a copy of this software and associated documentation files (the
 
8
"Software"), to deal in the Software without restriction, including
 
9
without limitation the rights to use, copy, modify, merge, publish,
 
10
distribute, sublicense, and/or sell copies of the Software, and to
 
11
permit persons to whom the Software is furnished to do so, subject to
 
12
the following conditions:
 
13
 
 
14
The above copyright notice and this permission notice shall be included
 
15
in all copies or substantial portions of the Software.
 
16
 
 
17
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
18
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
19
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
20
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
21
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
22
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
23
OTHER DEALINGS IN THE SOFTWARE.
 
24
 
 
25
Except as contained in this notice, the name of the X Consortium shall
 
26
not be used in advertising or otherwise to promote the sale, use or
 
27
other dealings in this Software without prior written authorization
 
28
from the X Consortium.
 
29
 
 
30
 
 
31
Copyright IBM Corporation 1987,1988,1989
 
32
All Rights Reserved
 
33
 
 
34
Permission to use, copy, modify, and distribute this software and its
 
35
documentation for any purpose and without fee is hereby granted,
 
36
provided that the above copyright notice appear in all copies and that 
 
37
both that copyright notice and this permission notice appear in
 
38
supporting documentation, and that the name of IBM not be
 
39
used in advertising or publicity pertaining to distribution of the
 
40
software without specific, written prior permission.
 
41
 
 
42
IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
43
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
44
IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
45
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
46
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
47
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
48
SOFTWARE.
 
49
 
 
50
 
 
51
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
 
52
All Rights Reserved
 
53
 
 
54
Permission to use, copy, modify, and distribute this software and its 
 
55
documentation for any purpose and without fee is hereby granted, 
 
56
provided that the above copyright notice appear in all copies and that
 
57
both that copyright notice and this permission notice appear in 
 
58
supporting documentation, and that the name of Digital not be
 
59
used in advertising or publicity pertaining to distribution of the
 
60
software without specific, written prior permission.  
 
61
 
 
62
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
63
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
64
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
65
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
66
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
67
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
68
SOFTWARE.
 
69
 
 
70
*/
 
71
/* $XConsortium: ppcWindow.c /main/5 1996/02/21 17:58:43 kaleb $ */
 
72
 
 
73
#ifdef HAVE_XORG_CONFIG_H
 
74
#include <xorg-config.h>
 
75
#endif
 
76
 
 
77
#include "xf4bpp.h"
 
78
#include "mfbmap.h"
 
79
#include "mfb.h"
 
80
#include "scrnintstr.h"
 
81
#include "ibmTrace.h"
 
82
 
 
83
/*
 
84
   xf4bppCopyWindow copies only the parts of the destination that are
 
85
visible in the source.
 
86
*/
 
87
 
 
88
void 
 
89
xf4bppCopyWindow(pWin, ptOldOrg, prgnSrc)
 
90
    register WindowPtr pWin ;
 
91
    DDXPointRec ptOldOrg ;
 
92
    RegionPtr prgnSrc ;
 
93
{
 
94
    RegionPtr prgnDst ;
 
95
    register BoxPtr pbox ;
 
96
    register int dx, dy ;
 
97
    register int nbox ;
 
98
    register int pm ;
 
99
 
 
100
    BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew ;
 
101
                                /* temporaries for shuffling rectangles */
 
102
 
 
103
    TRACE(("xf4bppCopyWindow(pWin= 0x%x, ptOldOrg= 0x%x, prgnSrc= 0x%x)\n", pWin, ptOldOrg, prgnSrc)) ;
 
104
 
 
105
 
 
106
    dx = ptOldOrg.x - pWin->drawable.x ;
 
107
    dy = ptOldOrg.y - pWin->drawable.y ;
 
108
    REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
 
109
 
 
110
    prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
 
111
    REGION_INTERSECT(pWin->drawable.pScreen, prgnDst,
 
112
                     &pWin->borderClip, prgnSrc);
 
113
 
 
114
    if ( !( nbox = REGION_NUM_RECTS(prgnDst) ) )
 
115
        return;
 
116
 
 
117
    pbox = REGION_RECTS(prgnDst);
 
118
 
 
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 ;
 
137
                }
 
138
                pboxNew -= nbox ;
 
139
                pbox = pboxNew ;
 
140
            }
 
141
            else { /* dx <= 0 */
 
142
                /* we can just reverse the entire list in place */
 
143
                /* Do three-position swaps */
 
144
                BoxRec tmpBox ;
 
145
 
 
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-- ;
 
155
                }
 
156
            }
 
157
        }
 
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)
 
165
            {
 
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 ;
 
173
            }
 
174
            pboxNew -= nbox ;
 
175
            pbox = pboxNew ;
 
176
        }
 
177
    } /* END if nbox > 1 */
 
178
 
 
179
    /*
 
180
     * call blit several times, the parms are:
 
181
     *   blit( alu,rplanes, wplanes, srcx, srcy, destx, desty, width, height ) ;
 
182
     */
 
183
 
 
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) ;
 
190
 
 
191
    /* free up stuff */
 
192
    if ( pboxNew )
 
193
        DEALLOCATE_LOCAL( pboxNew ) ;
 
194
 
 
195
    REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
 
196
}
 
197
 
 
198
Bool xf4bppPositionWindow(pWin, x, y)
 
199
register WindowPtr pWin ;
 
200
register int x, y ;
 
201
{
 
202
    return TRUE ;
 
203
}
 
204
 
 
205
Bool 
 
206
xf4bppDestroyWindow(pWin)
 
207
register WindowPtr pWin ;
 
208
{
 
209
return pWin ? TRUE : FALSE ;
 
210
}
 
211
 
 
212
/* As The Name Says -- Used For ega, vga and apa8c */
 
213
Bool
 
214
xf4bppCreateWindowForXYhardware(pWin)
 
215
register WindowPtr pWin ;
 
216
{
 
217
    register mfbPrivWin *pPrivWin;
 
218
 
 
219
    TRACE(("xf4bppCreateWindowForXYhardware (pWin= 0x%x)\n", pWin));
 
220
 
 
221
    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbGetWindowPrivateIndex()].ptr);
 
222
    pPrivWin->pRotatedBorder = NullPixmap;
 
223
    pPrivWin->pRotatedBackground = NullPixmap;
 
224
    pPrivWin->fastBackground = 0;
 
225
    pPrivWin->fastBorder = 0;
 
226
 
 
227
    return TRUE;
 
228
}