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

« back to all changes in this revision

Viewing changes to mi/mipushpxl.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/mi/mipushpxl.c,v 3.12 2001/12/14 20:00:26 dawes Exp $ */
 
2
/***********************************************************
 
3
 
 
4
Copyright 1987, 1998  The Open Group
 
5
 
 
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.
 
11
 
 
12
The above copyright notice and this permission notice shall be included in
 
13
all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
18
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
21
 
 
22
Except as contained in this notice, the name of The Open Group shall not be
 
23
used in advertising or otherwise to promote the sale, use or other dealings
 
24
in this Software without prior written authorization from The Open Group.
 
25
 
 
26
 
 
27
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
28
 
 
29
                        All Rights Reserved
 
30
 
 
31
Permission to use, copy, modify, and distribute this software and its 
 
32
documentation for any purpose and without fee is hereby granted, 
 
33
provided that the above copyright notice appear in all copies and that
 
34
both that copyright notice and this permission notice appear in 
 
35
supporting documentation, and that the name of Digital not be
 
36
used in advertising or publicity pertaining to distribution of the
 
37
software without specific, written prior permission.  
 
38
 
 
39
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
40
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
41
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
42
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
43
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
44
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
45
SOFTWARE.
 
46
 
 
47
******************************************************************/
 
48
/* $Xorg: mipushpxl.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
 
49
#ifdef HAVE_DIX_CONFIG_H
 
50
#include <dix-config.h>
 
51
#endif
 
52
 
 
53
#include <X11/X.h>
 
54
#include "gcstruct.h"
 
55
#include "scrnintstr.h"
 
56
#include "pixmapstr.h"
 
57
#include "regionstr.h"
 
58
#include "../mfb/maskbits.h"
 
59
#include "mi.h"
 
60
 
 
61
#define NPT 128
 
62
 
 
63
/* miPushPixels -- squeegees the fill style of pGC through pBitMap
 
64
 * into pDrawable.  pBitMap is a stencil (dx by dy of it is used, it may
 
65
 * be bigger) which is placed on the drawable at xOrg, yOrg.  Where a 1 bit
 
66
 * is set in the bitmap, the fill style is put onto the drawable using
 
67
 * the GC's logical function. The drawable is not changed where the bitmap
 
68
 * has a zero bit or outside the area covered by the stencil.
 
69
 
 
70
WARNING:
 
71
    this code works if the 1-bit deep pixmap format returned by GetSpans
 
72
is the same as the format defined by the mfb code (i.e. 32-bit padding
 
73
per scanline, scanline unit = 32 bits; later, this might mean
 
74
bitsizeof(int) padding and sacnline unit == bitsizeof(int).)
 
75
 
 
76
 */
 
77
 
 
78
/*
 
79
 * in order to have both (MSB_FIRST and LSB_FIRST) versions of this
 
80
 * in the server, we need to rename one of them
 
81
 */
 
82
void
 
83
miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
 
84
    GCPtr       pGC;
 
85
    PixmapPtr   pBitMap;
 
86
    DrawablePtr pDrawable;
 
87
    int         dx, dy, xOrg, yOrg;
 
88
{
 
89
    int         h, dxDivPPW, ibEnd;
 
90
    MiBits *pwLineStart;
 
91
    register MiBits     *pw, *pwEnd;
 
92
    register MiBits msk;
 
93
    register int ib, w;
 
94
    register int ipt;           /* index into above arrays */
 
95
    Bool        fInBox;
 
96
    DDXPointRec pt[NPT], ptThisLine;
 
97
    int         width[NPT];
 
98
#ifdef XFree86Server
 
99
    PixelType   startmask;
 
100
    if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
 
101
      if (screenInfo.bitmapBitOrder == LSBFirst)
 
102
        startmask = (MiBits)(-1) ^
 
103
            LONG2CHARSSAMEORDER((MiBits)(-1) << 1);
 
104
      else
 
105
        startmask = (MiBits)(-1) ^
 
106
            LONG2CHARSSAMEORDER((MiBits)(-1) >> 1);
 
107
    else
 
108
      if (screenInfo.bitmapBitOrder == LSBFirst)
 
109
        startmask = (MiBits)(-1) ^
 
110
            LONG2CHARSDIFFORDER((MiBits)(-1) << 1);
 
111
      else
 
112
        startmask = (MiBits)(-1) ^
 
113
            LONG2CHARSDIFFORDER((MiBits)(-1) >> 1);
 
114
#endif
 
115
 
 
116
    pwLineStart = (MiBits *)xalloc(BitmapBytePad(dx));
 
117
    if (!pwLineStart)
 
118
        return;
 
119
    ipt = 0;
 
120
    dxDivPPW = dx/PPW;
 
121
 
 
122
    for(h = 0, ptThisLine.x = 0, ptThisLine.y = 0; 
 
123
        h < dy; 
 
124
        h++, ptThisLine.y++)
 
125
    {
 
126
 
 
127
        (*pBitMap->drawable.pScreen->GetSpans)((DrawablePtr)pBitMap, dx,
 
128
                        &ptThisLine, &dx, 1, (char *)pwLineStart);
 
129
 
 
130
        pw = pwLineStart;
 
131
        /* Process all words which are fully in the pixmap */
 
132
        
 
133
        fInBox = FALSE;
 
134
        pwEnd = pwLineStart + dxDivPPW;
 
135
        while(pw  < pwEnd)
 
136
        {
 
137
            w = *pw;
 
138
#ifdef XFree86Server
 
139
            msk = startmask;
 
140
#else
 
141
            msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1);
 
142
#endif
 
143
            for(ib = 0; ib < PPW; ib++)
 
144
            {
 
145
                if(w & msk)
 
146
                {
 
147
                    if(!fInBox)
 
148
                    {
 
149
                        pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
 
150
                        pt[ipt].y = h + yOrg;
 
151
                        /* start new box */
 
152
                        fInBox = TRUE;
 
153
                    }
 
154
                }
 
155
                else
 
156
                {
 
157
                    if(fInBox)
 
158
                    {
 
159
                        width[ipt] = ((pw - pwLineStart) << PWSH) + 
 
160
                                     ib + xOrg - pt[ipt].x;
 
161
                        if (++ipt >= NPT)
 
162
                        {
 
163
                            (*pGC->ops->FillSpans)(pDrawable, pGC, 
 
164
                                              NPT, pt, width, TRUE);
 
165
                            ipt = 0;
 
166
                        }
 
167
                        /* end box */
 
168
                        fInBox = FALSE;
 
169
                    }
 
170
                }
 
171
#ifdef XFree86Server
 
172
                /* This is not quite right, but it'll do for now */
 
173
                if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
 
174
                  if (screenInfo.bitmapBitOrder == LSBFirst)
 
175
                    msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) << 1);
 
176
                  else
 
177
                    msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) >> 1);
 
178
                else
 
179
                  if (screenInfo.bitmapBitOrder == LSBFirst)
 
180
                    msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) << 1);
 
181
                  else
 
182
                    msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) >> 1);
 
183
#else
 
184
                msk = SCRRIGHT(msk, 1);
 
185
#endif
 
186
            }
 
187
            pw++;
 
188
        }
 
189
        ibEnd = dx & PIM;
 
190
        if(ibEnd)
 
191
        {
 
192
            /* Process final partial word on line */
 
193
            w = *pw;
 
194
#ifdef XFree86Server
 
195
            msk = startmask;
 
196
#else
 
197
            msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1);
 
198
#endif
 
199
            for(ib = 0; ib < ibEnd; ib++)
 
200
            {
 
201
                if(w & msk)
 
202
                {
 
203
                    if(!fInBox)
 
204
                    {
 
205
                        /* start new box */
 
206
                        pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
 
207
                        pt[ipt].y = h + yOrg;
 
208
                        fInBox = TRUE;
 
209
                    }
 
210
                }
 
211
                else
 
212
                {
 
213
                    if(fInBox)
 
214
                    {
 
215
                        /* end box */
 
216
                        width[ipt] = ((pw - pwLineStart) << PWSH) + 
 
217
                                     ib + xOrg - pt[ipt].x;
 
218
                        if (++ipt >= NPT)
 
219
                        {
 
220
                            (*pGC->ops->FillSpans)(pDrawable, 
 
221
                                              pGC, NPT, pt, width, TRUE);
 
222
                            ipt = 0;
 
223
                        }
 
224
                        fInBox = FALSE;
 
225
                    }
 
226
                }
 
227
#ifdef XFree86Server
 
228
                /* This is not quite right, but it'll do for now */
 
229
                if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
 
230
                  if (screenInfo.bitmapBitOrder == LSBFirst)
 
231
                    msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) << 1);
 
232
                  else
 
233
                    msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) >> 1);
 
234
                else
 
235
                  if (screenInfo.bitmapBitOrder == LSBFirst)
 
236
                    msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) << 1);
 
237
                  else
 
238
                    msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) >> 1);
 
239
#else
 
240
                msk = SCRRIGHT(msk, 1);
 
241
#endif
 
242
            }
 
243
        }
 
244
        /* If scanline ended with last bit set, end the box */
 
245
        if(fInBox)
 
246
        {
 
247
            width[ipt] = dx + xOrg - pt[ipt].x;
 
248
            if (++ipt >= NPT)
 
249
            {
 
250
                (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
 
251
                ipt = 0;
 
252
            }
 
253
        }
 
254
    }
 
255
    xfree(pwLineStart);
 
256
    /* Flush any remaining spans */
 
257
    if (ipt)
 
258
    {
 
259
        (*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);
 
260
    }
 
261
}