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

« back to all changes in this revision

Viewing changes to miext/rootless/accel/rlFill.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
 * This code is largely copied from fbfill.c.
 
3
 *
 
4
 * Copyright © 1998 Keith Packard
 
5
 * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
 
6
 *
 
7
 * Permission to use, copy, modify, distribute, and sell this software and its
 
8
 * documentation for any purpose is hereby granted without fee, provided that
 
9
 * the above copyright notice appear in all copies and that both that
 
10
 * copyright notice and this permission notice appear in supporting
 
11
 * documentation, and that the name of Keith Packard not be used in
 
12
 * advertising or publicity pertaining to distribution of the software without
 
13
 * specific, written prior permission.  Keith Packard makes no
 
14
 * representations about the suitability of this software for any purpose.  It
 
15
 * is provided "as is" without express or implied warranty.
 
16
 *
 
17
 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
18
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
19
 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
20
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
21
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
22
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
23
 * PERFORMANCE OF THIS SOFTWARE.
 
24
 */
 
25
/* $XFree86: xc/programs/Xserver/fb/fbfill.c,v 1.6 2003/01/31 00:01:45 torrey Exp $ */
 
26
 
 
27
#ifdef HAVE_DIX_CONFIG_H
 
28
#include <dix-config.h>
 
29
#endif
 
30
 
 
31
#include "fb.h"
 
32
#include "rlAccel.h"
 
33
 
 
34
 
 
35
void
 
36
rlFill (DrawablePtr pDrawable,
 
37
        GCPtr       pGC,
 
38
        int         x,
 
39
        int         y,
 
40
        int         width,
 
41
        int         height)
 
42
{
 
43
    FbBits          *dst;
 
44
    FbStride        dstStride;
 
45
    int             dstBpp;
 
46
    int             dstXoff, dstYoff;
 
47
    FbGCPrivPtr     pPriv = fbGetGCPrivate(pGC);
 
48
    
 
49
    fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
 
50
 
 
51
    switch (pGC->fillStyle) {
 
52
    case FillSolid:
 
53
        rlSolid (pDrawable->pScreen,
 
54
                 dst + (y + dstYoff) * dstStride, 
 
55
                 dstStride, 
 
56
                 (x + dstXoff) * dstBpp,
 
57
                 dstBpp,
 
58
                 width * dstBpp, height,
 
59
                 pPriv->and, pPriv->xor);
 
60
        break;
 
61
    case FillStippled:
 
62
    case FillOpaqueStippled: {
 
63
        PixmapPtr   pStip = pGC->stipple;
 
64
        int         stipWidth = pStip->drawable.width;
 
65
        int         stipHeight = pStip->drawable.height;
 
66
        
 
67
        if (dstBpp == 1)
 
68
        {
 
69
            int         alu;
 
70
            FbBits      *stip;
 
71
            FbStride    stipStride;
 
72
            int         stipBpp;
 
73
            int         stipXoff, stipYoff; /* XXX assumed to be zero */
 
74
 
 
75
            if (pGC->fillStyle == FillStippled)
 
76
                alu = FbStipple1Rop(pGC->alu,pGC->fgPixel);
 
77
            else
 
78
                alu = FbOpaqueStipple1Rop(pGC->alu,pGC->fgPixel,pGC->bgPixel);
 
79
            fbGetDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
 
80
            fbTile (dst + (y + dstYoff) * dstStride,
 
81
                    dstStride,
 
82
                    x + dstXoff,
 
83
                    width, height,
 
84
                    stip,
 
85
                    stipStride,
 
86
                    stipWidth,
 
87
                    stipHeight,
 
88
                    alu,
 
89
                    pPriv->pm,
 
90
                    dstBpp,
 
91
                    
 
92
                    (pGC->patOrg.x + pDrawable->x + dstXoff),
 
93
                    pGC->patOrg.y + pDrawable->y + dstYoff - y);
 
94
        }
 
95
        else
 
96
        {
 
97
            FbStip      *stip;
 
98
            FbStride    stipStride;
 
99
            int         stipBpp;
 
100
            int         stipXoff, stipYoff; /* XXX assumed to be zero */
 
101
            FbBits      fgand, fgxor, bgand, bgxor;
 
102
 
 
103
            fgand = pPriv->and;
 
104
            fgxor = pPriv->xor;
 
105
            if (pGC->fillStyle == FillStippled)
 
106
            {
 
107
                bgand = fbAnd(GXnoop,(FbBits) 0,FB_ALLONES);
 
108
                bgxor = fbXor(GXnoop,(FbBits) 0,FB_ALLONES);
 
109
            }
 
110
            else
 
111
            {
 
112
                bgand = pPriv->bgand;
 
113
                bgxor = pPriv->bgxor;
 
114
            }
 
115
 
 
116
            fbGetStipDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
 
117
            fbStipple (dst + (y + dstYoff) * dstStride, 
 
118
                       dstStride, 
 
119
                       (x + dstXoff) * dstBpp,
 
120
                       dstBpp,
 
121
                       width * dstBpp, height,
 
122
                       stip,
 
123
                       stipStride,
 
124
                       stipWidth,
 
125
                       stipHeight,
 
126
                       pPriv->evenStipple,
 
127
                       fgand, fgxor,
 
128
                       bgand, bgxor,
 
129
                       pGC->patOrg.x + pDrawable->x + dstXoff,
 
130
                       pGC->patOrg.y + pDrawable->y + dstYoff - y);
 
131
        }
 
132
        break;
 
133
    }
 
134
    case FillTiled: {
 
135
        PixmapPtr   pTile = pGC->tile.pixmap;
 
136
        FbBits      *tile;
 
137
        FbStride    tileStride;
 
138
        int         tileBpp;
 
139
        int         tileWidth;
 
140
        int         tileHeight;
 
141
        int         tileXoff, tileYoff; /* XXX assumed to be zero */
 
142
        
 
143
        fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp, tileXoff, tileYoff);
 
144
        tileWidth = pTile->drawable.width;
 
145
        tileHeight = pTile->drawable.height;
 
146
        fbTile (dst + (y + dstYoff) * dstStride, 
 
147
                dstStride, 
 
148
                (x + dstXoff) * dstBpp, 
 
149
                width * dstBpp, height,
 
150
                tile,
 
151
                tileStride,
 
152
                tileWidth * tileBpp,
 
153
                tileHeight,
 
154
                pGC->alu,
 
155
                pPriv->pm,
 
156
                dstBpp,
 
157
                (pGC->patOrg.x + pDrawable->x + dstXoff) * dstBpp,
 
158
                pGC->patOrg.y + pDrawable->y + dstYoff - y);
 
159
        break;
 
160
    }
 
161
    }
 
162
    fbValidateDrawable (pDrawable);
 
163
}
 
164
 
 
165
void
 
166
rlSolidBoxClipped (DrawablePtr  pDrawable,
 
167
                   RegionPtr    pClip,
 
168
                   int          x1,
 
169
                   int          y1,
 
170
                   int          x2,
 
171
                   int          y2,
 
172
                   FbBits       and,
 
173
                   FbBits       xor)
 
174
{
 
175
    FbBits      *dst;
 
176
    FbStride    dstStride;
 
177
    int         dstBpp;
 
178
    int         dstXoff, dstYoff;
 
179
    BoxPtr      pbox;
 
180
    int         nbox;
 
181
    int         partX1, partX2, partY1, partY2;
 
182
 
 
183
    fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
 
184
    
 
185
    for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip); 
 
186
         nbox--; 
 
187
         pbox++)
 
188
    {
 
189
        partX1 = pbox->x1;
 
190
        if (partX1 < x1)
 
191
            partX1 = x1;
 
192
        
 
193
        partX2 = pbox->x2;
 
194
        if (partX2 > x2)
 
195
            partX2 = x2;
 
196
        
 
197
        if (partX2 <= partX1)
 
198
            continue;
 
199
        
 
200
        partY1 = pbox->y1;
 
201
        if (partY1 < y1)
 
202
            partY1 = y1;
 
203
        
 
204
        partY2 = pbox->y2;
 
205
        if (partY2 > y2)
 
206
            partY2 = y2;
 
207
        
 
208
        if (partY2 <= partY1)
 
209
            continue;
 
210
        
 
211
        rlSolid (pDrawable->pScreen,
 
212
                 dst + (partY1 + dstYoff) * dstStride,
 
213
                 dstStride,
 
214
                 (partX1 + dstXoff) * dstBpp,
 
215
                 dstBpp,
 
216
 
 
217
                 (partX2 - partX1) * dstBpp,
 
218
                 (partY2 - partY1),
 
219
                 and, xor);
 
220
    }
 
221
}