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

« back to all changes in this revision

Viewing changes to miext/shadow/shplanar.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: xc/programs/Xserver/miext/shadow/shplanar.c,v 1.3 2001/05/29 04:54:13 keithp Exp $
 
3
 *
 
4
 * Copyright © 2000 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
#ifdef HAVE_DIX_CONFIG_H
 
26
#include <dix-config.h>
 
27
#endif
 
28
 
 
29
#include    <X11/X.h>
 
30
#include    "scrnintstr.h"
 
31
#include    "windowstr.h"
 
32
#include    <X11/fonts/font.h>
 
33
#include    "dixfontstr.h"
 
34
#include    <X11/fonts/fontstruct.h>
 
35
#include    "mi.h"
 
36
#include    "regionstr.h"
 
37
#include    "globals.h"
 
38
#include    "gcstruct.h"
 
39
#include    "shadow.h"
 
40
#include    "fb.h"
 
41
 
 
42
/*
 
43
 * 32 4-bit pixels per write
 
44
 */
 
45
 
 
46
#define PL_SHIFT    7       
 
47
#define PL_UNIT     (1 << PL_SHIFT)
 
48
#define PL_MASK     (PL_UNIT - 1)
 
49
 
 
50
/*
 
51
 *  32->8 conversion:
 
52
 *
 
53
 *      7 6 5 4 3 2 1 0
 
54
 *      A B C D E F G H
 
55
 *
 
56
 *      3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
 
57
 *      1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
 
58
 * m    . . . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A
 
59
 * m1   G . . . F . . . E . . . D . . . C . . . B . . . A . . . . . . .     m << (7 - (p))
 
60
 * m2   . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A . .     (m >> (p)) << 2
 
61
 * m3   G               E               C               A                   m1 & 0x80808080
 
62
 * m4     H               F               D               B                 m2 & 0x40404040
 
63
 * m5   G H             E F             C D             A B                 m3 | m4
 
64
 * m6   G H             E F             C D     G H     A B     E F         m5 | (m5 >> 20)
 
65
 * m7   G H             E F             C D     G H     A B C D E F G H     m6 | (m6 >> 10)
 
66
 */
 
67
 
 
68
#if 0
 
69
#define GetBits(p,o,d) {\
 
70
    m = sha[o]; \
 
71
    m1 = m << (7 - (p)); \
 
72
    m2 = (m >> (p)) << 2; \
 
73
    m3 = m1 & 0x80808080; \
 
74
    m4 = m2 & 0x40404040; \
 
75
    m5 = m3 | m4; \
 
76
    m6 = m5 | (m5 >> 20); \
 
77
    d = m6 | (m6 >> 10); \
 
78
}
 
79
#else
 
80
#define GetBits(p,o,d) {\
 
81
    m = sha[o]; \
 
82
    m5 = ((m << (7 - (p))) & 0x80808080) | (((m >> (p)) << 2) & 0x40404040); \
 
83
    m6 = m5 | (m5 >> 20); \
 
84
    d = m6 | (m6 >> 10); \
 
85
}
 
86
#endif
 
87
 
 
88
void
 
89
shadowUpdatePlanar4 (ScreenPtr      pScreen,
 
90
                     shadowBufPtr   pBuf)
 
91
{
 
92
    RegionPtr   damage = &pBuf->damage;
 
93
    PixmapPtr   pShadow = pBuf->pPixmap;
 
94
    int         nbox = REGION_NUM_RECTS (damage);
 
95
    BoxPtr      pbox = REGION_RECTS (damage);
 
96
    CARD32      *shaBase, *shaLine, *sha;
 
97
    FbStride    shaStride;
 
98
    int         scrBase, scrLine, scr;
 
99
    int         shaBpp;
 
100
    int         shaXoff, shaYoff;   /* XXX assumed to be zero */
 
101
    int         x, y, w, h, width;
 
102
    int         i;
 
103
    CARD32      *winBase = NULL, *win;
 
104
    CARD32      winSize;
 
105
    int         plane;
 
106
    CARD32      m,m5,m6;
 
107
    CARD8       s1, s2, s3, s4;
 
108
 
 
109
    fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff);
 
110
    while (nbox--)
 
111
    {
 
112
        x = (pbox->x1) * shaBpp;
 
113
        y = (pbox->y1);
 
114
        w = (pbox->x2 - pbox->x1) * shaBpp;
 
115
        h = pbox->y2 - pbox->y1;
 
116
 
 
117
        w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT;
 
118
        x &= ~PL_MASK;
 
119
        
 
120
        scrLine = (x >> PL_SHIFT);
 
121
        shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
 
122
        
 
123
        while (h--)
 
124
        {
 
125
            for (plane = 0; plane < 4; plane++)
 
126
            {
 
127
                width = w;
 
128
                scr = scrLine;
 
129
                sha = shaLine;
 
130
                winSize = 0;
 
131
                scrBase = 0;
 
132
                while (width) {
 
133
                    /* how much remains in this window */
 
134
                    i = scrBase + winSize - scr;
 
135
                    if (i <= 0 || scr < scrBase)
 
136
                    {
 
137
                        winBase = (CARD32 *) (*pBuf->window) (pScreen,
 
138
                                                              y,
 
139
                                                              (scr << 4) | (plane),
 
140
                                                              SHADOW_WINDOW_WRITE,
 
141
                                                              &winSize,
 
142
                                                              pBuf->closure);
 
143
                        if(!winBase)
 
144
                        return;
 
145
                        winSize >>= 2;
 
146
                        scrBase = scr;
 
147
                        i = winSize;
 
148
                    }
 
149
                    win = winBase + (scr - scrBase);
 
150
                    if (i > width)
 
151
                    i = width;
 
152
                    width -= i;
 
153
                    scr += i;
 
154
                   
 
155
                    while (i--)
 
156
                    {
 
157
                        GetBits(plane,0,s1);
 
158
                        GetBits(plane,1,s2);
 
159
                        GetBits(plane,2,s3);
 
160
                        GetBits(plane,3,s4);
 
161
                        *win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
 
162
                        sha += 4;
 
163
                    }
 
164
                }
 
165
            }
 
166
            shaLine += shaStride;
 
167
            y++;
 
168
        }
 
169
        pbox++;
 
170
    }
 
171
}
 
172
 
 
173
shadowUpdateProc shadowUpdatePlanar4Weak(void) {
 
174
    return shadowUpdatePlanar4;
 
175
}
 
176
 
 
177
shadowUpdateProc shadowUpdatePlanar4x8Weak(void) {
 
178
    return shadowUpdatePlanar4x8;
 
179
}