1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_image.c,v 1.4 2001/05/18 23:35:32 dawes Exp $ */
#include "savage_driver.h"
#include "xaarop.h"
#include "savage_bci.h"
void SavageSubsequentImageWriteRect (
ScrnInfoPtr pScrn,
int x,
int y,
int w,
int h,
int skipleft);
void SavageSetupForImageWrite (
ScrnInfoPtr pScrn,
int rop,
unsigned planemask,
int transparency_color,
int bpp,
int depth);
void SavageWriteBitmapCPUToScreenColorExpand (
ScrnInfoPtr pScrn,
int x, int y, int w, int h,
unsigned char * src,
int srcwidth,
int skipleft,
int fg, int bg,
int rop,
unsigned int planemask);
#if 0
void SavageWriteBitmapScreenToScreenColorExpand(
ScrnPtr pScrn,
int x,
int y,
int w,
int h,
unsigned char * src,
int srcwidth,
int srcx,
int srcy,
int bg,
int fg,
int rop,
unsigned int planemask
)
{
SavagePtr psav = SAVPTR(pScrn);
BCI_GET_PTR;
unsigned int cmd;
unsigned char * bd_offset;
unsigned int bd;
cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
| BCI_CMD_SEND_COLOR
| BCI_CMD_DEST_GBD | BCI_CMD_SRC_SBD_MONO_NEW;
cmd |= (bg != -1) ? BCI_CMD_SEND_COLOR : BCI_CMD_SRC_TRANSPARENT;
cmd |= s3vAlu[rop];
bd |= BCI_BD_BW_DISABLE;
BCI_BD_SET_BPP(bd, 1);
BCI_BD_SET_STRIDE(bd, srcwidth);
bd_offset = srcwidth * srcy + (srcx >> 3) + src;
psav->WaitQueue(psav,10);
BCI_SEND(cmd);
BCI_SEND((unsigned int)bd_offset);
BCI_SEND(bd);
BCI_SEND(fg);
BCI_SEND((bg != -1) ? bg : 0);
BCI_SEND(BCI_X_Y(srcx, srcy));
BCI_SEND(BCI_X_Y(x, y));
BCI_SEND(BCI_W_H(w, h));
}
#endif
void
SavageWriteBitmapCPUToScreenColorExpand (
ScrnInfoPtr pScrn,
int x, int y, int w, int h,
unsigned char * src,
int srcwidth,
int skipleft,
int fg, int bg,
int rop,
unsigned int planemask
)
{
SavagePtr psav = SAVPTR(pScrn);
BCI_GET_PTR;
int i, j, count, reset;
unsigned int cmd;
CARD32 * srcp;
/* We aren't using planemask at all here... */
if( !srcwidth )
return;
cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
| BCI_CMD_SEND_COLOR | BCI_CMD_CLIP_LR
| BCI_CMD_DEST_GBD | BCI_CMD_SRC_MONO;
cmd |= XAAGetCopyROP(rop) << 16;
if( bg == -1 )
cmd |= BCI_CMD_SRC_TRANSPARENT;
BCI_SEND(cmd);
BCI_SEND(BCI_CLIP_LR(x+skipleft, x+w-1));
BCI_SEND(fg);
if( bg != -1 )
BCI_SEND(bg);
/* Bitmaps come in in units of DWORDS, LSBFirst. This is exactly */
/* reversed of what we expect. */
count = (w + 31) / 32;
/* src += ((srcx & ~31) / 8); */
/* The BCI region is 128k bytes. A screen-sized mono bitmap can */
/* exceed that. */
reset = 65536 / count;
for (j = 0; j < h; j ++) {
BCI_SEND(BCI_X_Y(x, y+j));
BCI_SEND(BCI_W_H(w, 1));
srcp = (CARD32 *) src;
for (i = count; i > 0; srcp ++, i --) {
/* We have to invert the bits in each byte. */
CARD32 u = *srcp;
u = ((u & 0x0f0f0f0f) << 4) | ((u & 0xf0f0f0f0) >> 4);
u = ((u & 0x33333333) << 2) | ((u & 0xcccccccc) >> 2);
u = ((u & 0x55555555) << 1) | ((u & 0xaaaaaaaa) >> 1);
BCI_SEND(u);
}
src += srcwidth;
if( !--reset ) {
BCI_RESET;
reset = 65536 / count;
}
}
}
void
SavageSetupForImageWrite(
ScrnInfoPtr pScrn,
int rop,
unsigned planemask,
int transparency_color,
int bpp,
int depth)
{
SavagePtr psav = SAVPTR(pScrn);
int cmd;
cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
| BCI_CMD_CLIP_LR
| BCI_CMD_DEST_GBD | BCI_CMD_SRC_COLOR;
cmd |= XAAGetCopyROP(rop) << 16;
if( transparency_color != -1 )
cmd |= BCI_CMD_SRC_TRANSPARENT;
psav->SavedBciCmd = cmd;
psav->SavedBgColor = transparency_color;
}
void SavageSubsequentImageWriteRect
(
ScrnInfoPtr pScrn,
int x,
int y,
int w,
int h,
int skipleft)
{
SavagePtr psav = SAVPTR(pScrn);
BCI_GET_PTR;
int count;
count = ((w * pScrn->bitsPerPixel + 31) / 32) * h;
psav->WaitQueue( psav, count );
BCI_SEND(psav->SavedBciCmd);
BCI_SEND(BCI_CLIP_LR(x+skipleft, x+w-1));
if( psav->SavedBgColor != -1 )
BCI_SEND(psav->SavedBgColor);
BCI_SEND(BCI_X_Y(x, y));
BCI_SEND(BCI_W_H(w, h));
}
|