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

« back to all changes in this revision

Viewing changes to hw/xfree86/xaa/xaaCpyPlane.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/xaa/xaaCpyPlane.c,v 1.13tsi Exp $ */
 
2
 
 
3
/*
 
4
   A CopyPlane function that handles bitmap->screen copies and
 
5
   sends anything else to the Fallback.
 
6
 
 
7
   Also, a PushPixels for solid fill styles.
 
8
 
 
9
   Written by Mark Vojkovich (markv@valinux.com)
 
10
 
 
11
*/
 
12
 
 
13
#ifdef HAVE_XORG_CONFIG_H
 
14
#include <xorg-config.h>
 
15
#endif
 
16
 
 
17
#include "misc.h"
 
18
#include "xf86.h"
 
19
#include "xf86_ansic.h"
 
20
#include "xf86_OSproc.h"
 
21
#include "servermd.h"
 
22
 
 
23
#include <X11/X.h>
 
24
#include "scrnintstr.h"
 
25
#include "mi.h"
 
26
#include "pixmapstr.h"
 
27
#include "xf86str.h"
 
28
#include "xaa.h"
 
29
#include "xaalocal.h"
 
30
#include "xaawrap.h"
 
31
 
 
32
static void XAACopyPlane1toNColorExpand(DrawablePtr pSrc, DrawablePtr pDst,
 
33
                                        GCPtr pGC, RegionPtr rgnDst,
 
34
                                        DDXPointPtr pptSrc);
 
35
static void XAACopyPlaneNtoNColorExpand(DrawablePtr pSrc, DrawablePtr pDst,
 
36
                                        GCPtr pGC, RegionPtr rgnDst,
 
37
                                        DDXPointPtr pptSrc);
 
38
 
 
39
 
 
40
static unsigned long TmpBitPlane; 
 
41
 
 
42
RegionPtr
 
43
XAACopyPlaneColorExpansion(
 
44
    DrawablePtr pSrc,
 
45
    DrawablePtr pDst,
 
46
    GCPtr pGC,
 
47
    int srcx, int srcy,
 
48
    int width, int height,
 
49
    int dstx, int dsty,
 
50
    unsigned long bitPlane 
 
51
){
 
52
    if((pSrc->type == DRAWABLE_PIXMAP) && !XAA_DEPTH_BUG(pGC)) {
 
53
        if(pSrc->bitsPerPixel == 1) {
 
54
           return(XAABitBlt(pSrc, pDst, pGC, srcx, srcy,
 
55
                        width, height, dstx, dsty, 
 
56
                        XAACopyPlane1toNColorExpand, bitPlane));
 
57
        } else if(bitPlane < (1 << pDst->depth)){
 
58
           TmpBitPlane = bitPlane;
 
59
           return(XAABitBlt(pSrc, pDst, pGC, srcx, srcy,
 
60
                        width, height, dstx, dsty, 
 
61
                        XAACopyPlaneNtoNColorExpand, bitPlane));
 
62
        }
 
63
    }
 
64
 
 
65
    return (XAAFallbackOps.CopyPlane(pSrc, pDst, pGC, srcx, srcy, 
 
66
                        width, height, dstx, dsty, bitPlane));
 
67
}
 
68
 
 
69
 
 
70
static void 
 
71
XAACopyPlane1toNColorExpand(
 
72
    DrawablePtr   pSrc, 
 
73
    DrawablePtr   pDst,
 
74
    GCPtr         pGC,
 
75
    RegionPtr     rgnDst,
 
76
    DDXPointPtr   pptSrc )
 
77
{
 
78
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
 
79
    BoxPtr pbox = REGION_RECTS(rgnDst);
 
80
    int numrects = REGION_NUM_RECTS(rgnDst);
 
81
    unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
 
82
    int srcwidth = ((PixmapPtr)pSrc)->devKind; 
 
83
    
 
84
    while(numrects--) { 
 
85
        (*infoRec->WriteBitmap)(infoRec->pScrn, pbox->x1, pbox->y1, 
 
86
                pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, 
 
87
                src + (srcwidth * pptSrc->y) + ((pptSrc->x >> 5) << 2), 
 
88
                srcwidth, pptSrc->x & 31, 
 
89
                pGC->fgPixel, pGC->bgPixel, pGC->alu, pGC->planemask);
 
90
        pbox++; pptSrc++;
 
91
    }
 
92
}
 
93
 
 
94
 
 
95
static void 
 
96
XAACopyPlaneNtoNColorExpand(
 
97
    DrawablePtr   pSrc, 
 
98
    DrawablePtr   pDst,
 
99
    GCPtr         pGC,
 
100
    RegionPtr     rgnDst,
 
101
    DDXPointPtr   pptSrc 
 
102
){
 
103
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
 
104
    BoxPtr pbox = REGION_RECTS(rgnDst);
 
105
    int numrects = REGION_NUM_RECTS(rgnDst);
 
106
    unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
 
107
    unsigned char *data, *srcPtr, *dataPtr;
 
108
    int srcwidth = ((PixmapPtr)pSrc)->devKind; 
 
109
    int pitch, width, height, h, i, index, offset;
 
110
    int Bpp = pSrc->bitsPerPixel >> 3;
 
111
    unsigned long mask = TmpBitPlane;
 
112
 
 
113
    if(TmpBitPlane < 8) {
 
114
        offset = 0;
 
115
    } else if(TmpBitPlane < 16) {
 
116
        offset = 1;
 
117
        mask >>= 8;
 
118
    } else if(TmpBitPlane < 24) {
 
119
        offset = 2;
 
120
        mask >>= 16;
 
121
    } else {
 
122
        offset = 3;
 
123
        mask >>= 24;
 
124
    }
 
125
 
 
126
    if(IS_OFFSCREEN_PIXMAP(pSrc))
 
127
        SYNC_CHECK(pSrc);
 
128
    
 
129
    while(numrects--) { 
 
130
        width = pbox->x2 - pbox->x1;
 
131
        h = height = pbox->y2 - pbox->y1;
 
132
        pitch = BitmapBytePad(width);
 
133
 
 
134
        if(!(data = xalloc(height * pitch)))
 
135
           goto ALLOC_FAILED;
 
136
 
 
137
        bzero(data, height * pitch);
 
138
 
 
139
        dataPtr = data;
 
140
        srcPtr = ((pptSrc->y) * srcwidth) + src + 
 
141
                        ((pptSrc->x) * Bpp) + offset;
 
142
 
 
143
        while(h--) {
 
144
            for(i = index = 0; i < width; i++, index += Bpp) {
 
145
               if(mask & srcPtr[index])
 
146
                  dataPtr[i >> 3] |= (1 << (i & 7));
 
147
            }
 
148
            dataPtr += pitch;
 
149
            srcPtr += srcwidth;
 
150
        }
 
151
 
 
152
        (*infoRec->WriteBitmap)(infoRec->pScrn, 
 
153
                pbox->x1, pbox->y1, width, height, data, pitch, 0, 
 
154
                pGC->fgPixel, pGC->bgPixel, pGC->alu, pGC->planemask);
 
155
        
 
156
        xfree(data);
 
157
 
 
158
ALLOC_FAILED:
 
159
 
 
160
        pbox++; pptSrc++;
 
161
    }
 
162
}
 
163
 
 
164
void
 
165
XAAPushPixelsSolidColorExpansion(
 
166
    GCPtr       pGC,
 
167
    PixmapPtr   pBitMap,
 
168
    DrawablePtr pDraw,
 
169
    int dx, int dy, 
 
170
    int xOrg, int yOrg )
 
171
{
 
172
   XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
 
173
   int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip);
 
174
   BoxPtr       pbox, pClipBoxes;
 
175
   int          nboxes, srcx, srcy;
 
176
   xRectangle TheRect;
 
177
   unsigned char *src = pBitMap->devPrivate.ptr;
 
178
   int srcwidth = pBitMap->devKind;
 
179
 
 
180
   if(!REGION_NUM_RECTS(pGC->pCompositeClip))
 
181
        return;
 
182
 
 
183
   TheRect.x = xOrg;
 
184
   TheRect.y = yOrg;
 
185
   TheRect.width = dx;
 
186
   TheRect.height = dy; 
 
187
 
 
188
   if(MaxBoxes > (infoRec->PreAllocSize/sizeof(BoxRec))) {
 
189
        pClipBoxes = xalloc(MaxBoxes * sizeof(BoxRec));
 
190
        if(!pClipBoxes) return; 
 
191
   } else pClipBoxes = (BoxPtr)infoRec->PreAllocMem;
 
192
 
 
193
   nboxes = XAAGetRectClipBoxes(pGC, pClipBoxes, 1, &TheRect);
 
194
   pbox = pClipBoxes;
 
195
 
 
196
   while(nboxes--) {
 
197
        srcx = pbox->x1 - xOrg;
 
198
        srcy = pbox->y1 - yOrg;
 
199
        (*infoRec->WriteBitmap)(infoRec->pScrn, pbox->x1, pbox->y1, 
 
200
                pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, 
 
201
                src + (srcwidth * srcy) + ((srcx >> 5) << 2), 
 
202
                srcwidth, srcx & 31, 
 
203
                pGC->fgPixel, -1, pGC->alu, pGC->planemask);
 
204
        pbox++;
 
205
   }
 
206
 
 
207
    if(pClipBoxes != (BoxPtr)infoRec->PreAllocMem)
 
208
        xfree(pClipBoxes);
 
209
}
 
210