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

« back to all changes in this revision

Viewing changes to fb/fbsolid.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
/*
 
2
 * $XFree86$
 
3
 *
 
4
 * Copyright © 1998 Keith Packard
 
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, and that the name of Keith Packard not be used in
 
11
 * advertising or publicity pertaining to distribution of the software without
 
12
 * specific, written prior permission.  Keith Packard makes no
 
13
 * representations about the suitability of this software for any purpose.  It
 
14
 * is provided "as is" without express or implied warranty.
 
15
 *
 
16
 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
17
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
18
 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
19
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
20
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
21
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
22
 * PERFORMANCE OF THIS SOFTWARE.
 
23
 */
 
24
 
 
25
#define FbSelectPart(xor,o,t)    xor
 
26
 
 
27
#ifdef HAVE_DIX_CONFIG_H
 
28
#include <dix-config.h>
 
29
#endif
 
30
 
 
31
#include "fb.h"
 
32
 
 
33
void
 
34
fbSolid (FbBits     *dst,
 
35
         FbStride   dstStride,
 
36
         int        dstX,
 
37
         int        bpp,
 
38
 
 
39
         int        width,
 
40
         int        height,
 
41
 
 
42
         FbBits     and,
 
43
         FbBits     xor)
 
44
{
 
45
    FbBits  startmask, endmask;
 
46
    int     n, nmiddle;
 
47
    int     startbyte, endbyte;
 
48
 
 
49
#ifdef FB_24BIT
 
50
    if (bpp == 24 && (!FbCheck24Pix(and) || !FbCheck24Pix(xor)))
 
51
    {
 
52
        fbSolid24 (dst, dstStride, dstX, width, height, and, xor);
 
53
        return;
 
54
    }
 
55
#endif
 
56
    dst += dstX >> FB_SHIFT;
 
57
    dstX &= FB_MASK;
 
58
    FbMaskBitsBytes(dstX, width, and == 0, startmask, startbyte, 
 
59
                    nmiddle, endmask, endbyte);
 
60
    if (startmask)
 
61
        dstStride--;
 
62
    dstStride -= nmiddle;
 
63
    while (height--)
 
64
    {
 
65
        if (startmask)
 
66
        {
 
67
            FbDoLeftMaskByteRRop(dst,startbyte,startmask,and,xor);
 
68
            dst++;
 
69
        }
 
70
        n = nmiddle;
 
71
        if (!and)
 
72
            while (n--)
 
73
                *dst++ = xor;
 
74
        else
 
75
            while (n--)
 
76
            {
 
77
                *dst = FbDoRRop (*dst, and, xor);
 
78
                dst++;
 
79
            }
 
80
        if (endmask)
 
81
            FbDoRightMaskByteRRop(dst,endbyte,endmask,and,xor);
 
82
        dst += dstStride;
 
83
    }
 
84
}
 
85
 
 
86
#ifdef FB_24BIT
 
87
void
 
88
fbSolid24 (FbBits   *dst,
 
89
           FbStride dstStride,
 
90
           int      dstX,
 
91
 
 
92
           int      width,
 
93
           int      height,
 
94
 
 
95
           FbBits   and,
 
96
           FbBits   xor)
 
97
{
 
98
    FbBits  startmask, endmask;
 
99
    FbBits  xor0 = 0, xor1 = 0, xor2 = 0;
 
100
    FbBits  and0 = 0, and1 = 0, and2 = 0;
 
101
    FbBits  xorS = 0, andS = 0, xorE = 0, andE = 0;
 
102
    int     n, nmiddle;
 
103
    int     rotS, rot;
 
104
 
 
105
    dst += dstX >> FB_SHIFT;
 
106
    dstX &= FB_MASK;
 
107
    /*
 
108
     * Rotate pixel values this far across the word to align on
 
109
     * screen pixel boundaries
 
110
     */
 
111
    rot = FbFirst24Rot (dstX);
 
112
    FbMaskBits (dstX, width, startmask, nmiddle, endmask);
 
113
    if (startmask)
 
114
        dstStride--;
 
115
    dstStride -= nmiddle;
 
116
    
 
117
    /*
 
118
     * Precompute rotated versions of the rasterop values
 
119
     */
 
120
    rotS = rot;
 
121
    xor = FbRot24(xor,rotS);
 
122
    and = FbRot24(and,rotS);
 
123
    if (startmask)
 
124
    {
 
125
        xorS = xor;
 
126
        andS = and;
 
127
        xor = FbNext24Pix(xor);
 
128
        and = FbNext24Pix(and);
 
129
    }
 
130
    
 
131
    if (nmiddle)
 
132
    {
 
133
        xor0 = xor;
 
134
        and0 = and;
 
135
        xor1 = FbNext24Pix(xor0);
 
136
        and1 = FbNext24Pix(and0);
 
137
        xor2 = FbNext24Pix(xor1);
 
138
        and2 = FbNext24Pix(and1);
 
139
    }
 
140
    
 
141
    if (endmask)
 
142
    {
 
143
        switch (nmiddle % 3) {
 
144
        case 0:
 
145
            xorE = xor;
 
146
            andE = and;
 
147
            break;
 
148
        case 1:
 
149
            xorE = xor1;
 
150
            andE = and1;
 
151
            break;
 
152
        case 2:
 
153
            xorE = xor2;
 
154
            andE = and2;
 
155
            break;
 
156
        }
 
157
    }
 
158
    
 
159
    while (height--)
 
160
    {
 
161
        if (startmask)
 
162
        {
 
163
            *dst = FbDoMaskRRop(*dst, andS, xorS, startmask);
 
164
            dst++;
 
165
        }
 
166
        n = nmiddle;
 
167
        if (!and0)
 
168
        {
 
169
            while (n >= 3)
 
170
            {
 
171
                *dst++ = xor0;
 
172
                *dst++ = xor1;
 
173
                *dst++ = xor2;
 
174
                n -= 3;
 
175
            }
 
176
            if (n)
 
177
            {
 
178
                *dst++ = xor0;
 
179
                n--;
 
180
                if (n)
 
181
                {
 
182
                    *dst++ = xor1;
 
183
                }
 
184
            }
 
185
        }
 
186
        else
 
187
        {
 
188
            while (n >= 3)
 
189
            {
 
190
                *dst = FbDoRRop (*dst, and0, xor0);
 
191
                dst++;
 
192
                *dst = FbDoRRop (*dst, and1, xor1);
 
193
                dst++;
 
194
                *dst = FbDoRRop (*dst, and2, xor2);
 
195
                dst++;
 
196
                n -= 3;
 
197
            }
 
198
            if (n)
 
199
            {
 
200
                *dst = FbDoRRop (*dst, and0, xor0);
 
201
                dst++;
 
202
                n--;
 
203
                if (n)
 
204
                {
 
205
                    *dst = FbDoRRop (*dst, and1, xor1);
 
206
                    dst++;
 
207
                }
 
208
            }
 
209
        }
 
210
        if (endmask)
 
211
            *dst = FbDoMaskRRop (*dst, andE, xorE, endmask);
 
212
        dst += dstStride;
 
213
    }
 
214
}
 
215
#endif