2 * GDI bit-blit operations
4 * Copyright 1993, 1994 Alexandre Julliard
10 #include <X11/Intrinsic.h>
18 /* #define DEBUG_BITBLT */
23 #define DST 0 /* Destination drawable */
24 #define SRC 1 /* Source drawable */
25 #define TMP 2 /* Temporary drawable */
26 #define PAT 3 /* Pattern (brush) in destination DC */
28 #define OP(src,dst,rop) (OP_ARGS(src,dst) << 4 | (rop))
29 #define OP_ARGS(src,dst) (((src) << 2) | (dst))
31 #define OP_SRC(opcode) ((opcode) >> 6)
32 #define OP_DST(opcode) (((opcode) >> 4) & 3)
33 #define OP_SRCDST(opcode) ((opcode) >> 4)
34 #define OP_ROP(opcode) ((opcode) & 0x0f)
36 #define MAX_OP_LEN 6 /* Longest opcode + 1 for the terminating 0 */
38 static const unsigned char BITBLT_Opcodes
[256][MAX_OP_LEN
] =
40 { OP(PAT
,DST
,GXclear
) }, /* 0x00 0 */
41 { OP(PAT
,SRC
,GXor
), OP(SRC
,DST
,GXnor
) }, /* 0x01 ~(D|(P|S)) */
42 { OP(PAT
,SRC
,GXnor
), OP(SRC
,DST
,GXand
) }, /* 0x02 D&~(P|S) */
43 { OP(PAT
,SRC
,GXnor
) }, /* 0x03 ~(P|S) */
44 { OP(PAT
,DST
,GXnor
), OP(SRC
,DST
,GXand
) }, /* 0x04 S&~(D|P) */
45 { OP(PAT
,DST
,GXnor
) }, /* 0x05 ~(D|P) */
46 { OP(SRC
,DST
,GXequiv
), OP(PAT
,DST
,GXnor
), }, /* 0x06 ~(P|~(D^S)) */
47 { OP(SRC
,DST
,GXand
), OP(PAT
,DST
,GXnor
) }, /* 0x07 ~(P|(D&S)) */
48 { OP(PAT
,DST
,GXandInverted
), OP(SRC
,DST
,GXand
) },/* 0x08 S&D&~P */
49 { OP(SRC
,DST
,GXxor
), OP(PAT
,DST
,GXnor
) }, /* 0x09 ~(P|(D^S)) */
50 { OP(PAT
,DST
,GXandInverted
) }, /* 0x0a D&~P */
51 { OP(SRC
,DST
,GXandReverse
), OP(PAT
,DST
,GXnor
) }, /* 0x0b ~(P|(S&~D)) */
52 { OP(PAT
,SRC
,GXandInverted
) }, /* 0x0c S&~P */
53 { OP(SRC
,DST
,GXandInverted
), OP(PAT
,DST
,GXnor
) },/* 0x0d ~(P|(D&~S)) */
54 { OP(SRC
,DST
,GXnor
), OP(PAT
,DST
,GXnor
) }, /* 0x0e ~(P|~(D|S)) */
55 { OP(PAT
,DST
,GXcopyInverted
) }, /* 0x0f ~P */
56 { OP(SRC
,DST
,GXnor
), OP(PAT
,DST
,GXand
) }, /* 0x10 P&~(S|D) */
57 { OP(SRC
,DST
,GXnor
) }, /* 0x11 ~(D|S) */
58 { OP(PAT
,DST
,GXequiv
), OP(SRC
,DST
,GXnor
) }, /* 0x12 ~(S|~(D^P)) */
59 { OP(PAT
,DST
,GXand
), OP(SRC
,DST
,GXnor
) }, /* 0x13 ~(S|(D&P)) */
60 { OP(PAT
,SRC
,GXequiv
), OP(SRC
,DST
,GXnor
) }, /* 0x14 ~(D|~(P^S)) */
61 { OP(PAT
,SRC
,GXand
), OP(SRC
,DST
,GXnor
) }, /* 0x15 ~(D|(P&S)) */
62 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,TMP
,GXnand
),
63 OP(TMP
,DST
,GXand
), OP(SRC
,DST
,GXxor
),
64 OP(PAT
,DST
,GXxor
) }, /* 0x16 P^S^(D&~(P&S) */
65 { OP(SRC
,TMP
,GXcopy
), OP(SRC
,DST
,GXxor
),
66 OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXand
),
67 OP(TMP
,DST
,GXequiv
) }, /* 0x17 ~S^((S^P)&(S^D))*/
68 { OP(PAT
,SRC
,GXxor
), OP(PAT
,DST
,GXxor
),
69 OP(SRC
,DST
,GXand
) }, /* 0x18 (S^P)&(D^P) */
70 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,TMP
,GXnand
),
71 OP(TMP
,DST
,GXand
), OP(SRC
,DST
,GXequiv
) }, /* 0x19 ~S^(D&~(P&S)) */
72 { OP(PAT
,SRC
,GXand
), OP(SRC
,DST
,GXor
),
73 OP(PAT
,DST
,GXxor
) }, /* 0x1a P^(D|(S&P)) */
74 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,TMP
,GXxor
),
75 OP(TMP
,DST
,GXand
), OP(SRC
,DST
,GXequiv
) }, /* 0x1b ~S^(D&(P^S)) */
76 { OP(PAT
,DST
,GXand
), OP(SRC
,DST
,GXor
),
77 OP(PAT
,DST
,GXxor
) }, /* 0x1c P^(S|(D&P)) */
78 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXxor
),
79 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXequiv
) }, /* 0x1d ~D^(S&(D^P)) */
80 { OP(SRC
,DST
,GXor
), OP(PAT
,DST
,GXxor
) }, /* 0x1e P^(D|S) */
81 { OP(SRC
,DST
,GXor
), OP(PAT
,DST
,GXnand
) }, /* 0x1f ~(P&(D|S)) */
82 { OP(PAT
,SRC
,GXandReverse
), OP(SRC
,DST
,GXand
) }, /* 0x20 D&(P&~S) */
83 { OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXnor
) }, /* 0x21 ~(S|(D^P)) */
84 { OP(SRC
,DST
,GXandInverted
) }, /* 0x22 ~S&D */
85 { OP(PAT
,DST
,GXandReverse
), OP(SRC
,DST
,GXnor
) }, /* 0x23 ~(S|(P&~D)) */
86 { OP(SRC
,DST
,GXxor
), OP(PAT
,SRC
,GXxor
),
87 OP(SRC
,DST
,GXand
) }, /* 0x24 (S^P)&(S^D) */
88 { OP(PAT
,SRC
,GXnand
), OP(SRC
,DST
,GXand
),
89 OP(PAT
,DST
,GXequiv
) }, /* 0x25 ~P^(D&~(S&P)) */
90 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,TMP
,GXand
),
91 OP(TMP
,DST
,GXor
), OP(SRC
,DST
,GXxor
) }, /* 0x26 S^(D|(S&P)) */
92 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,TMP
,GXequiv
),
93 OP(TMP
,DST
,GXor
), OP(SRC
,DST
,GXxor
) }, /* 0x27 S^(D|~(P^S)) */
94 { OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXand
) }, /* 0x28 D&(P^S) */
95 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,TMP
,GXand
),
96 OP(TMP
,DST
,GXor
), OP(SRC
,DST
,GXxor
),
97 OP(PAT
,DST
,GXequiv
) }, /* 0x29 ~P^S^(D|(P&S)) */
98 { OP(PAT
,SRC
,GXnand
), OP(SRC
,DST
,GXand
) }, /* 0x2a D&~(P&S) */
99 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXxor
),
100 OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXand
),
101 OP(TMP
,DST
,GXequiv
) }, /* 0x2b ~S^((P^S)&(P^D))*/
102 { OP(SRC
,DST
,GXor
), OP(PAT
,DST
,GXand
),
103 OP(SRC
,DST
,GXxor
) }, /* 0x2c S^(P&(S|D)) */
104 { OP(SRC
,DST
,GXorReverse
), OP(PAT
,DST
,GXxor
) }, /* 0x2d P^(S|~D) */
105 { OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXor
),
106 OP(PAT
,DST
,GXxor
) }, /* 0x2e P^(S|(D^P)) */
107 { OP(SRC
,DST
,GXorReverse
), OP(PAT
,DST
,GXnand
) }, /* 0x2f ~(P&(S|~D)) */
108 { OP(PAT
,SRC
,GXandReverse
) }, /* 0x30 P&~S */
109 { OP(PAT
,DST
,GXandInverted
), OP(SRC
,DST
,GXnor
) },/* 0x31 ~(S|(D&~P)) */
110 { OP(SRC
,DST
,GXor
), OP(PAT
,DST
,GXor
),
111 OP(SRC
,DST
,GXxor
) }, /* 0x32 S^(D|P|S) */
112 { OP(SRC
,DST
,GXcopyInverted
) }, /* 0x33 ~S */
113 { OP(SRC
,DST
,GXand
), OP(PAT
,DST
,GXor
),
114 OP(SRC
,DST
,GXxor
) }, /* 0x34 S^(P|(D&S)) */
115 { OP(SRC
,DST
,GXequiv
), OP(PAT
,DST
,GXor
),
116 OP(SRC
,DST
,GXxor
) }, /* 0x35 S^(P|~(D^S)) */
117 { OP(PAT
,DST
,GXor
), OP(SRC
,DST
,GXxor
) }, /* 0x36 S^(D|P) */
118 { OP(PAT
,DST
,GXor
), OP(SRC
,DST
,GXnand
) }, /* 0x37 ~(S&(D|P)) */
119 { OP(PAT
,DST
,GXor
), OP(SRC
,DST
,GXand
),
120 OP(PAT
,DST
,GXxor
) }, /* 0x38 P^(S&(D|P)) */
121 { OP(PAT
,DST
,GXorReverse
), OP(SRC
,DST
,GXxor
) }, /* 0x39 S^(P|~D) */
122 { OP(SRC
,DST
,GXxor
), OP(PAT
,DST
,GXor
),
123 OP(SRC
,DST
,GXxor
) }, /* 0x3a S^(P|(D^S)) */
124 { OP(PAT
,DST
,GXorReverse
), OP(SRC
,DST
,GXnand
) }, /* 0x3b ~(S&(P|~D)) */
125 { OP(PAT
,SRC
,GXxor
) }, /* 0x3c P^S */
126 { OP(SRC
,DST
,GXnor
), OP(PAT
,DST
,GXor
),
127 OP(SRC
,DST
,GXxor
) }, /* 0x3d S^(P|~(D|S)) */
128 { OP(SRC
,DST
,GXandInverted
), OP(PAT
,DST
,GXor
),
129 OP(SRC
,DST
,GXxor
) }, /* 0x3e S^(P|(D&~S)) */
130 { OP(PAT
,SRC
,GXnand
) }, /* 0x3f ~(P&S) */
131 { OP(SRC
,DST
,GXandReverse
), OP(PAT
,DST
,GXand
) }, /* 0x40 P&S&~D */
132 { OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXnor
) }, /* 0x41 ~(D|(P^S)) */
133 { OP(DST
,SRC
,GXxor
), OP(PAT
,DST
,GXxor
),
134 OP(SRC
,DST
,GXand
) }, /* 0x42 (S^D)&(P^D) */
135 { OP(SRC
,DST
,GXnand
), OP(PAT
,DST
,GXand
),
136 OP(SRC
,DST
,GXequiv
) }, /* 0x43 ~S^(P&~(D&S)) */
137 { OP(SRC
,DST
,GXandReverse
) }, /* 0x44 S&~D */
138 { OP(PAT
,SRC
,GXandReverse
), OP(SRC
,DST
,GXnor
) }, /* 0x45 ~(D|(P&~S)) */
139 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXand
),
140 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXxor
) }, /* 0x46 D^(S|(P&D)) */
141 { OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXand
),
142 OP(PAT
,DST
,GXequiv
) }, /* 0x47 ~P^(S&(D^P)) */
143 { OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXand
) }, /* 0x48 S&(P^D) */
144 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXand
),
145 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXxor
),
146 OP(PAT
,DST
,GXequiv
) }, /* 0x49 ~P^D^(S|(P&D)) */
147 { OP(DST
,SRC
,GXor
), OP(PAT
,SRC
,GXand
),
148 OP(SRC
,DST
,GXxor
) }, /* 0x4a D^(P&(S|D)) */
149 { OP(SRC
,DST
,GXorInverted
), OP(PAT
,DST
,GXxor
) }, /* 0x4b P^(D|~S) */
150 { OP(PAT
,DST
,GXnand
), OP(SRC
,DST
,GXand
) }, /* 0x4c S&~(D&P) */
151 { OP(SRC
,TMP
,GXcopy
), OP(SRC
,DST
,GXxor
),
152 OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXor
),
153 OP(TMP
,DST
,GXequiv
) }, /* 0x4d ~S^((S^P)|(S^D))*/
154 { OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXor
),
155 OP(PAT
,DST
,GXxor
) }, /* 0x4e P^(D|(S^P)) */
156 { OP(SRC
,DST
,GXorInverted
), OP(PAT
,DST
,GXnand
) },/* 0x4f ~(P&(D|~S)) */
157 { OP(PAT
,DST
,GXandReverse
) }, /* 0x50 P&~D */
158 { OP(PAT
,SRC
,GXandInverted
), OP(SRC
,DST
,GXnor
) },/* 0x51 ~(D|(S&~P)) */
159 { OP(DST
,SRC
,GXand
), OP(PAT
,SRC
,GXor
),
160 OP(SRC
,DST
,GXxor
) }, /* 0x52 D^(P|(S&D)) */
161 { OP(SRC
,DST
,GXxor
), OP(PAT
,DST
,GXand
),
162 OP(SRC
,DST
,GXequiv
) }, /* 0x53 ~S^(P&(D^S)) */
163 { OP(PAT
,SRC
,GXnor
), OP(SRC
,DST
,GXnor
) }, /* 0x54 ~(D|~(P|S)) */
164 { OP(PAT
,DST
,GXinvert
) }, /* 0x55 ~D */
165 { OP(PAT
,SRC
,GXor
), OP(SRC
,DST
,GXxor
) }, /* 0x56 D^(P|S) */
166 { OP(PAT
,SRC
,GXor
), OP(SRC
,DST
,GXnand
) }, /* 0x57 ~(D&(P|S)) */
167 { OP(PAT
,SRC
,GXor
), OP(SRC
,DST
,GXand
),
168 OP(PAT
,DST
,GXxor
) }, /* 0x58 P^(D&(P|S)) */
169 { OP(PAT
,SRC
,GXorReverse
), OP(SRC
,DST
,GXxor
) }, /* 0x59 D^(P|~S) */
170 { OP(PAT
,DST
,GXxor
) }, /* 0x5a D^P */
171 { OP(DST
,SRC
,GXnor
), OP(PAT
,SRC
,GXor
),
172 OP(SRC
,DST
,GXxor
) }, /* 0x5b D^(P|~(S|D)) */
173 { OP(DST
,SRC
,GXxor
), OP(PAT
,SRC
,GXor
),
174 OP(SRC
,DST
,GXxor
) }, /* 0x5c D^(P|(S^D)) */
175 { OP(PAT
,SRC
,GXorReverse
), OP(SRC
,DST
,GXnand
) }, /* 0x5d ~(D&(P|~S)) */
176 { OP(DST
,SRC
,GXandInverted
), OP(PAT
,SRC
,GXor
),
177 OP(SRC
,DST
,GXxor
) }, /* 0x5e D^(P|(S&~D)) */
178 { OP(PAT
,DST
,GXnand
) }, /* 0x5f ~(D&P) */
179 { OP(SRC
,DST
,GXxor
), OP(PAT
,DST
,GXand
) }, /* 0x60 P&(D^S) */
180 { OP(DST
,TMP
,GXcopy
), OP(SRC
,DST
,GXand
),
181 OP(PAT
,DST
,GXor
), OP(SRC
,DST
,GXxor
),
182 OP(TMP
,DST
,GXequiv
) }, /* 0x61 ~D^S^(P|(D&S)) */
183 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXor
),
184 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXxor
) }, /* 0x62 D^(S&(P|D)) */
185 { OP(PAT
,DST
,GXorInverted
), OP(SRC
,DST
,GXxor
) }, /* 0x63 S^(D|~P) */
186 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXor
),
187 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXxor
) }, /* 0x64 S^(D&(P|S)) */
188 { OP(PAT
,SRC
,GXorInverted
), OP(SRC
,DST
,GXxor
) }, /* 0x65 D^(S|~P) */
189 { OP(SRC
,DST
,GXxor
) }, /* 0x66 S^D */
190 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXnor
),
191 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXxor
) }, /* 0x67 S^(D|~(S|P) */
192 { OP(DST
,TMP
,GXcopy
), OP(SRC
,DST
,GXnor
),
193 OP(PAT
,DST
,GXor
), OP(SRC
,DST
,GXxor
),
194 OP(TMP
,DST
,GXequiv
) }, /* 0x68 ~D^S^(P|~(D|S))*/
195 { OP(SRC
,DST
,GXxor
), OP(PAT
,DST
,GXequiv
) }, /* 0x69 ~P^(D^S) */
196 { OP(PAT
,SRC
,GXand
), OP(SRC
,DST
,GXxor
) }, /* 0x6a D^(P&S) */
197 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXor
),
198 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXxor
),
199 OP(PAT
,DST
,GXequiv
) }, /* 0x6b ~P^S^(D&(P|S)) */
200 { OP(PAT
,DST
,GXand
), OP(SRC
,DST
,GXxor
) }, /* 0x6c S^(D&P) */
201 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXor
),
202 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXxor
),
203 OP(PAT
,DST
,GXequiv
) }, /* 0x6d ~P^D^(S&(P|D)) */
204 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXorReverse
),
205 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXxor
) }, /* 0x6e S^(D&(P|~S)) */
206 { OP(SRC
,DST
,GXequiv
), OP(PAT
,DST
,GXnand
) }, /* 0x6f ~(P&~(S^D)) */
207 { OP(SRC
,DST
,GXnand
), OP(PAT
,DST
,GXand
) }, /* 0x70 P&~(D&S) */
208 { OP(SRC
,TMP
,GXcopy
), OP(DST
,SRC
,GXxor
),
209 OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXand
),
210 OP(TMP
,DST
,GXequiv
) }, /* 0x71 ~S^((S^D)&(P^D))*/
211 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXxor
),
212 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXxor
) }, /* 0x72 S^(D|(P^S)) */
213 { OP(PAT
,DST
,GXorInverted
), OP(SRC
,DST
,GXnand
) },/* 0x73 ~(S&(D|~P)) */
214 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXxor
),
215 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXxor
) }, /* 0x74 D^(S|(P^D)) */
216 { OP(PAT
,SRC
,GXorInverted
), OP(SRC
,DST
,GXnand
) },/* 0x75 ~(D&(S|~P)) */
217 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXandReverse
),
218 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXxor
) }, /* 0x76 S^(D|(P&~S)) */
219 { OP(SRC
,DST
,GXnand
) }, /* 0x77 ~(S&D) */
220 { OP(SRC
,DST
,GXand
), OP(PAT
,DST
,GXxor
) }, /* 0x78 P^(D&S) */
221 { OP(DST
,TMP
,GXcopy
), OP(SRC
,DST
,GXor
),
222 OP(PAT
,DST
,GXand
), OP(SRC
,DST
,GXxor
),
223 OP(TMP
,DST
,GXequiv
) }, /* 0x79 ~D^S^(P&(D|S)) */
224 { OP(DST
,SRC
,GXorInverted
), OP(PAT
,SRC
,GXand
),
225 OP(SRC
,DST
,GXxor
) }, /* 0x7a D^(P&(S|~D)) */
226 { OP(PAT
,DST
,GXequiv
), OP(SRC
,DST
,GXnand
) }, /* 0x7b ~(S&~(D^P)) */
227 { OP(SRC
,DST
,GXorInverted
), OP(PAT
,DST
,GXand
),
228 OP(SRC
,DST
,GXxor
) }, /* 0x7c S^(P&(D|~S)) */
229 { OP(PAT
,SRC
,GXequiv
), OP(SRC
,DST
,GXnand
) }, /* 0x7d ~(D&~(P^S)) */
230 { OP(SRC
,DST
,GXxor
), OP(PAT
,SRC
,GXxor
),
231 OP(SRC
,DST
,GXor
) }, /* 0x7e (S^P)|(S^D) */
232 { OP(PAT
,SRC
,GXand
), OP(SRC
,DST
,GXnand
) }, /* 0x7f ~(D&P&S) */
233 { OP(PAT
,SRC
,GXand
), OP(SRC
,DST
,GXand
) }, /* 0x80 D&P&S */
234 { OP(SRC
,DST
,GXxor
), OP(PAT
,SRC
,GXxor
),
235 OP(SRC
,DST
,GXnor
) }, /* 0x81 ~((S^P)|(S^D)) */
236 { OP(PAT
,SRC
,GXequiv
), OP(SRC
,DST
,GXand
) }, /* 0x82 D&~(P^S) */
237 { OP(SRC
,DST
,GXorInverted
), OP(PAT
,DST
,GXand
),
238 OP(SRC
,DST
,GXequiv
) }, /* 0x83 ~S^(P&(D|~S)) */
239 { OP(PAT
,DST
,GXequiv
), OP(SRC
,DST
,GXand
) }, /* 0x84 S&~(D^P) */
240 { OP(PAT
,SRC
,GXorInverted
), OP(SRC
,DST
,GXand
),
241 OP(PAT
,DST
,GXequiv
) }, /* 0x85 ~P^(D&(S|~P)) */
242 { OP(DST
,TMP
,GXcopy
), OP(SRC
,DST
,GXor
),
243 OP(PAT
,DST
,GXand
), OP(SRC
,DST
,GXxor
),
244 OP(TMP
,DST
,GXxor
) }, /* 0x86 D^S^(P&(D|S)) */
245 { OP(SRC
,DST
,GXand
), OP(PAT
,DST
,GXequiv
) }, /* 0x87 ~P^(D&S) */
246 { OP(SRC
,DST
,GXand
) }, /* 0x88 S&D */
247 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXandReverse
),
248 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXequiv
) }, /* 0x89 ~S^(D|(P&~S)) */
249 { OP(PAT
,SRC
,GXorInverted
), OP(SRC
,DST
,GXand
) }, /* 0x8a D&(S|~P) */
250 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXxor
),
251 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXequiv
) }, /* 0x8b ~D^(S|(P^D)) */
252 { OP(PAT
,DST
,GXorInverted
), OP(SRC
,DST
,GXand
) }, /* 0x8c S&(D|~P) */
253 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXxor
),
254 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXequiv
) }, /* 0x8d ~S^(D|(P^S)) */
255 { OP(SRC
,TMP
,GXcopy
), OP(DST
,SRC
,GXxor
),
256 OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXand
),
257 OP(TMP
,DST
,GXxor
) }, /* 0x8e S^((S^D)&(P^D))*/
258 { OP(SRC
,DST
,GXnand
), OP(PAT
,DST
,GXnand
) }, /* 0x8f ~(P&~(D&S)) */
259 { OP(SRC
,DST
,GXequiv
), OP(PAT
,DST
,GXand
) }, /* 0x90 P&~(D^S) */
260 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXorReverse
),
261 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXequiv
) }, /* 0x91 ~S^(D&(P|~S)) */
262 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXor
),
263 OP(SRC
,DST
,GXand
), OP(PAT
,DST
,GXxor
),
264 OP(TMP
,DST
,GXxor
) }, /* 0x92 D^P^(S&(D|P)) */
265 { OP(PAT
,DST
,GXand
), OP(SRC
,DST
,GXequiv
) }, /* 0x93 ~S^(P&D) */
266 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXor
),
267 OP(SRC
,DST
,GXand
), OP(PAT
,DST
,GXxor
),
268 OP(TMP
,DST
,GXxor
) }, /* 0x94 S^P^(D&(P|S)) */
269 { OP(PAT
,SRC
,GXand
), OP(SRC
,DST
,GXequiv
) }, /* 0x95 ~D^(P&S) */
270 { OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXxor
) }, /* 0x96 D^P^S */
271 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXnor
),
272 OP(SRC
,DST
,GXor
), OP(PAT
,DST
,GXxor
),
273 OP(TMP
,DST
,GXxor
) }, /* 0x97 S^P^(D|~(P|S)) */
274 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXnor
),
275 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXequiv
) }, /* 0x98 ~S^(D|~(P|S)) */
276 { OP(SRC
,DST
,GXequiv
) }, /* 0x99 ~S^D */
277 { OP(PAT
,SRC
,GXandReverse
), OP(SRC
,DST
,GXxor
) }, /* 0x9a D^(P&~S) */
278 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXor
),
279 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXequiv
) }, /* 0x9b ~S^(D&(P|S)) */
280 { OP(PAT
,DST
,GXandReverse
), OP(SRC
,DST
,GXxor
) }, /* 0x9c S^(P&~D) */
281 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXor
),
282 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXequiv
) }, /* 0x9d ~D^(S&(P|D)) */
283 { OP(DST
,TMP
,GXcopy
), OP(SRC
,DST
,GXand
),
284 OP(PAT
,DST
,GXor
), OP(SRC
,DST
,GXxor
),
285 OP(TMP
,DST
,GXxor
) }, /* 0x9e D^S^(P|(D&S)) */
286 { OP(SRC
,DST
,GXxor
), OP(PAT
,DST
,GXnand
) }, /* 0x9f ~(P&(D^S)) */
287 { OP(PAT
,DST
,GXand
) }, /* 0xa0 D&P */
288 { OP(PAT
,SRC
,GXandInverted
), OP(SRC
,DST
,GXor
),
289 OP(PAT
,DST
,GXequiv
) }, /* 0xa1 ~P^(D|(S&~P)) */
290 { OP(PAT
,SRC
,GXorReverse
), OP(SRC
,DST
,GXand
) }, /* 0xa2 D&(P|~S) */
291 { OP(DST
,SRC
,GXxor
), OP(PAT
,SRC
,GXor
),
292 OP(SRC
,DST
,GXequiv
) }, /* 0xa3 ~D^(P|(S^D)) */
293 { OP(PAT
,SRC
,GXnor
), OP(SRC
,DST
,GXor
),
294 OP(PAT
,DST
,GXequiv
) }, /* 0xa4 ~P^(D|~(S|P)) */
295 { OP(PAT
,DST
,GXequiv
) }, /* 0xa5 ~P^D */
296 { OP(PAT
,SRC
,GXandInverted
), OP(SRC
,DST
,GXxor
) },/* 0xa6 D^(S&~P) */
297 { OP(PAT
,SRC
,GXor
), OP(SRC
,DST
,GXand
),
298 OP(PAT
,DST
,GXequiv
) }, /* 0xa7 ~P^(D&(S|P)) */
299 { OP(PAT
,SRC
,GXor
), OP(SRC
,DST
,GXand
) }, /* 0xa8 D&(P|S) */
300 { OP(PAT
,SRC
,GXor
), OP(SRC
,DST
,GXequiv
) }, /* 0xa9 ~D^(P|S) */
301 { OP(SRC
,DST
,GXnoop
) }, /* 0xaa D */
302 { OP(PAT
,SRC
,GXnor
), OP(SRC
,DST
,GXor
) }, /* 0xab D|~(P|S) */
303 { OP(SRC
,DST
,GXxor
), OP(PAT
,DST
,GXand
),
304 OP(SRC
,DST
,GXxor
) }, /* 0xac S^(P&(D^S)) */
305 { OP(DST
,SRC
,GXand
), OP(PAT
,SRC
,GXor
),
306 OP(SRC
,DST
,GXequiv
) }, /* 0xad ~D^(P|(S&D)) */
307 { OP(PAT
,SRC
,GXandInverted
), OP(SRC
,DST
,GXor
) }, /* 0xae D|(S&~P) */
308 { OP(PAT
,DST
,GXorInverted
) }, /* 0xaf D|~P */
309 { OP(SRC
,DST
,GXorInverted
), OP(PAT
,DST
,GXand
) }, /* 0xb0 P&(D|~S) */
310 { OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXor
),
311 OP(PAT
,DST
,GXequiv
) }, /* 0xb1 ~P^(D|(S^P)) */
312 { OP(SRC
,TMP
,GXcopy
), OP(SRC
,DST
,GXxor
),
313 OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXor
),
314 OP(TMP
,DST
,GXxor
) }, /* 0xb2 S^((S^P)|(S^D))*/
315 { OP(PAT
,DST
,GXnand
), OP(SRC
,DST
,GXnand
) }, /* 0xb3 ~(S&~(D&P)) */
316 { OP(SRC
,DST
,GXandReverse
), OP(PAT
,DST
,GXxor
) }, /* 0xb4 P^(S&~D) */
317 { OP(DST
,SRC
,GXor
), OP(PAT
,SRC
,GXand
),
318 OP(SRC
,DST
,GXequiv
) }, /* 0xb5 ~D^(P&(S|D)) */
319 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXand
),
320 OP(SRC
,DST
,GXor
), OP(PAT
,DST
,GXxor
),
321 OP(TMP
,DST
,GXxor
) }, /* 0xb6 D^P^(S|(D&P)) */
322 { OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXnand
) }, /* 0xb7 ~(S&(D^P)) */
323 { OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXand
),
324 OP(PAT
,DST
,GXxor
) }, /* 0xb8 P^(S&(D^P)) */
325 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXand
),
326 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXequiv
) }, /* 0xb9 ~D^(S|(P&D)) */
327 { OP(PAT
,SRC
,GXandReverse
), OP(SRC
,DST
,GXor
) }, /* 0xba D|(P&~S) */
328 { OP(SRC
,DST
,GXorInverted
) }, /* 0xbb ~S|D */
329 { OP(SRC
,DST
,GXnand
), OP(PAT
,DST
,GXand
),
330 OP(SRC
,DST
,GXxor
) }, /* 0xbc S^(P&~(D&S)) */
331 { OP(DST
,SRC
,GXxor
), OP(PAT
,DST
,GXxor
),
332 OP(SRC
,DST
,GXnand
) }, /* 0xbd ~((S^D)&(P^D)) */
333 { OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXor
) }, /* 0xbe D|(P^S) */
334 { OP(PAT
,SRC
,GXnand
), OP(SRC
,DST
,GXor
) }, /* 0xbf D|~(P&S) */
335 { OP(PAT
,SRC
,GXand
) }, /* 0xc0 P&S */
336 { OP(SRC
,DST
,GXandInverted
), OP(PAT
,DST
,GXor
),
337 OP(SRC
,DST
,GXequiv
) }, /* 0xc1 ~S^(P|(D&~S)) */
338 { OP(SRC
,DST
,GXnor
), OP(PAT
,DST
,GXor
),
339 OP(SRC
,DST
,GXequiv
) }, /* 0xc2 ~S^(P|~(D|S)) */
340 { OP(PAT
,SRC
,GXequiv
) }, /* 0xc3 ~P^S */
341 { OP(PAT
,DST
,GXorReverse
), OP(SRC
,DST
,GXand
) }, /* 0xc4 S&(P|~D) */
342 { OP(SRC
,DST
,GXxor
), OP(PAT
,DST
,GXor
),
343 OP(SRC
,DST
,GXequiv
) }, /* 0xc5 ~S^(P|(D^S)) */
344 { OP(PAT
,DST
,GXandInverted
), OP(SRC
,DST
,GXxor
) },/* 0xc6 S^(D&~P) */
345 { OP(PAT
,DST
,GXor
), OP(SRC
,DST
,GXand
),
346 OP(PAT
,DST
,GXequiv
) }, /* 0xc7 ~P^(S&(D|P)) */
347 { OP(PAT
,DST
,GXor
), OP(SRC
,DST
,GXand
) }, /* 0xc8 S&(D|P) */
348 { OP(PAT
,DST
,GXor
), OP(SRC
,DST
,GXequiv
) }, /* 0xc9 ~S^(P|D) */
349 { OP(DST
,SRC
,GXxor
), OP(PAT
,SRC
,GXand
),
350 OP(SRC
,DST
,GXxor
) }, /* 0xca D^(P&(S^D)) */
351 { OP(SRC
,DST
,GXand
), OP(PAT
,DST
,GXor
),
352 OP(SRC
,DST
,GXequiv
) }, /* 0xcb ~S^(P|(D&S)) */
353 { OP(SRC
,DST
,GXcopy
) }, /* 0xcc S */
354 { OP(PAT
,DST
,GXnor
), OP(SRC
,DST
,GXor
) }, /* 0xcd S|~(D|P) */
355 { OP(PAT
,DST
,GXandInverted
), OP(SRC
,DST
,GXor
) }, /* 0xce S|(D&~P) */
356 { OP(PAT
,SRC
,GXorInverted
) }, /* 0xcf S|~P */
357 { OP(SRC
,DST
,GXorReverse
), OP(PAT
,DST
,GXand
) }, /* 0xd0 P&(S|~D) */
358 { OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXor
),
359 OP(PAT
,DST
,GXequiv
) }, /* 0xd1 ~P^(S|(D^P)) */
360 { OP(SRC
,DST
,GXandInverted
), OP(PAT
,DST
,GXxor
) },/* 0xd2 P^(D&~S) */
361 { OP(SRC
,DST
,GXor
), OP(PAT
,DST
,GXand
),
362 OP(SRC
,DST
,GXequiv
) }, /* 0xd3 ~S^(P&(D|S)) */
363 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXxor
),
364 OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXand
),
365 OP(TMP
,DST
,GXxor
) }, /* 0xd4 S^((S^P)&(D^P))*/
366 { OP(PAT
,SRC
,GXnand
), OP(SRC
,DST
,GXnand
) }, /* 0xd5 ~(D&~(P&S)) */
367 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXand
),
368 OP(SRC
,DST
,GXor
), OP(PAT
,DST
,GXxor
),
369 OP(TMP
,DST
,GXxor
) }, /* 0xd6 S^P^(D|(P&S)) */
370 { OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXnand
) }, /* 0xd7 ~(D&(P^S)) */
371 { OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXand
),
372 OP(PAT
,DST
,GXxor
) }, /* 0xd8 P^(D&(S^P)) */
373 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXand
),
374 OP(SRC
,DST
,GXor
), OP(TMP
,DST
,GXequiv
) }, /* 0xd9 ~S^(D|(P&S)) */
375 { OP(DST
,SRC
,GXnand
), OP(PAT
,SRC
,GXand
),
376 OP(SRC
,DST
,GXxor
) }, /* 0xda D^(P&~(S&D)) */
377 { OP(SRC
,DST
,GXxor
), OP(PAT
,SRC
,GXxor
),
378 OP(SRC
,DST
,GXnand
) }, /* 0xdb ~((S^P)&(S^D)) */
379 { OP(PAT
,DST
,GXandReverse
), OP(SRC
,DST
,GXor
) }, /* 0xdc S|(P&~D) */
380 { OP(SRC
,DST
,GXorReverse
) }, /* 0xdd S|~D */
381 { OP(PAT
,DST
,GXxor
), OP(SRC
,DST
,GXor
) }, /* 0xde S|(D^P) */
382 { OP(PAT
,DST
,GXnand
), OP(SRC
,DST
,GXor
) }, /* 0xdf S|~(D&P) */
383 { OP(SRC
,DST
,GXor
), OP(PAT
,DST
,GXand
) }, /* 0xe0 P&(D|S) */
384 { OP(SRC
,DST
,GXor
), OP(PAT
,DST
,GXequiv
) }, /* 0xe1 ~P^(D|S) */
385 { OP(DST
,TMP
,GXcopy
), OP(PAT
,DST
,GXxor
),
386 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXxor
) }, /* 0xe2 D^(S&(P^D)) */
387 { OP(PAT
,DST
,GXand
), OP(SRC
,DST
,GXor
),
388 OP(PAT
,DST
,GXequiv
) }, /* 0xe3 ~P^(S|(D&P)) */
389 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXxor
),
390 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXxor
) }, /* 0xe4 S^(D&(P^S)) */
391 { OP(PAT
,SRC
,GXand
), OP(SRC
,DST
,GXor
),
392 OP(PAT
,DST
,GXequiv
) }, /* 0xe5 ~P^(D|(S&P)) */
393 { OP(SRC
,TMP
,GXcopy
), OP(PAT
,SRC
,GXnand
),
394 OP(SRC
,DST
,GXand
), OP(TMP
,DST
,GXxor
) }, /* 0xe6 S^(D&~(P&S)) */
395 { OP(PAT
,SRC
,GXxor
), OP(PAT
,DST
,GXxor
),
396 OP(SRC
,DST
,GXnand
) }, /* 0xe7 ~((S^P)&(D^P)) */
397 { OP(SRC
,TMP
,GXcopy
), OP(SRC
,DST
,GXxor
),
398 OP(PAT
,SRC
,GXxor
), OP(SRC
,DST
,GXand
),
399 OP(TMP
,DST
,GXxor
) }, /* 0xe8 S^((S^P)&(S^D))*/
400 { OP(DST
,TMP
,GXcopy
), OP(SRC
,DST
,GXnand
),
401 OP(PAT
,DST
,GXand
), OP(SRC
,DST
,GXxor
),
402 OP(TMP
,DST
,GXequiv
) }, /* 0xe9 ~D^S^(P&~(S&D))*/
403 { OP(PAT
,SRC
,GXand
), OP(SRC
,DST
,GXor
) }, /* 0xea D|(P&S) */
404 { OP(PAT
,SRC
,GXequiv
), OP(SRC
,DST
,GXor
) }, /* 0xeb D|~(P^S) */
405 { OP(PAT
,DST
,GXand
), OP(SRC
,DST
,GXor
) }, /* 0xec S|(D&P) */
406 { OP(PAT
,DST
,GXequiv
), OP(SRC
,DST
,GXor
) }, /* 0xed S|~(D^P) */
407 { OP(SRC
,DST
,GXor
) }, /* 0xee S|D */
408 { OP(PAT
,DST
,GXorInverted
), OP(SRC
,DST
,GXor
) }, /* 0xef S|D|~P */
409 { OP(PAT
,DST
,GXcopy
) }, /* 0xf0 P */
410 { OP(SRC
,DST
,GXnor
), OP(PAT
,DST
,GXor
) }, /* 0xf1 P|~(D|S) */
411 { OP(SRC
,DST
,GXandInverted
), OP(PAT
,DST
,GXor
) }, /* 0xf2 P|(D&~S) */
412 { OP(PAT
,SRC
,GXorReverse
) }, /* 0xf3 P|~S */
413 { OP(SRC
,DST
,GXandReverse
), OP(PAT
,DST
,GXor
) }, /* 0xf4 P|(S&~D) */
414 { OP(PAT
,DST
,GXorReverse
) }, /* 0xf5 P|~D */
415 { OP(SRC
,DST
,GXxor
), OP(PAT
,DST
,GXor
) }, /* 0xf6 P|(D^S) */
416 { OP(SRC
,DST
,GXnand
), OP(PAT
,DST
,GXor
) }, /* 0xf7 P|~(S&D) */
417 { OP(SRC
,DST
,GXand
), OP(PAT
,DST
,GXor
) }, /* 0xf8 P|(D&S) */
418 { OP(SRC
,DST
,GXequiv
), OP(PAT
,DST
,GXor
) }, /* 0xf9 P|~(D^S) */
419 { OP(PAT
,DST
,GXor
) }, /* 0xfa D|P */
420 { OP(PAT
,SRC
,GXorReverse
), OP(SRC
,DST
,GXor
) }, /* 0xfb D|P|~S */
421 { OP(PAT
,SRC
,GXor
) }, /* 0xfc P|S */
422 { OP(SRC
,DST
,GXorReverse
), OP(PAT
,DST
,GXor
) }, /* 0xfd P|S|~D */
423 { OP(SRC
,DST
,GXor
), OP(PAT
,DST
,GXor
) }, /* 0xfe P|D|S */
424 { OP(PAT
,DST
,GXset
) } /* 0xff 1 */
428 #ifdef BITBLT_TEST /* Opcodes test */
430 static int do_bitop( int s
, int d
, int rop
)
435 case GXclear
: res
= 0; break;
436 case GXand
: res
= s
& d
; break;
437 case GXandReverse
: res
= s
& ~d
; break;
438 case GXcopy
: res
= s
; break;
439 case GXandInverted
: res
= ~s
& d
; break;
440 case GXnoop
: res
= d
; break;
441 case GXxor
: res
= s
^ d
; break;
442 case GXor
: res
= s
| d
; break;
443 case GXnor
: res
= ~(s
| d
); break;
444 case GXequiv
: res
= ~s
^ d
; break;
445 case GXinvert
: res
= ~d
; break;
446 case GXorReverse
: res
= s
| ~d
; break;
447 case GXcopyInverted
: res
= ~s
; break;
448 case GXorInverted
: res
= ~s
| d
; break;
449 case GXnand
: res
= ~(s
& d
); break;
450 case GXset
: res
= 1; break;
457 int rop
, i
, res
, src
, dst
, pat
, tmp
, dstUsed
;
460 for (rop
= 0; rop
< 256; rop
++)
463 for (i
= 0; i
< 8; i
++)
468 for (opcode
= BITBLT_Opcodes
[rop
]; *opcode
; opcode
++)
472 case OP_ARGS(DST
,TMP
):
473 tmp
= do_bitop( dst
, tmp
, *opcode
& 0xf );
475 case OP_ARGS(DST
,SRC
):
476 src
= do_bitop( dst
, src
, *opcode
& 0xf );
478 case OP_ARGS(SRC
,TMP
):
479 tmp
= do_bitop( src
, tmp
, *opcode
& 0xf );
481 case OP_ARGS(SRC
,DST
):
482 dst
= do_bitop( src
, dst
, *opcode
& 0xf );
485 case OP_ARGS(PAT
,TMP
):
486 tmp
= do_bitop( pat
, tmp
, *opcode
& 0xf );
488 case OP_ARGS(PAT
,DST
):
489 dst
= do_bitop( pat
, dst
, *opcode
& 0xf );
492 case OP_ARGS(PAT
,SRC
):
493 src
= do_bitop( pat
, src
, *opcode
& 0xf );
495 case OP_ARGS(TMP
,DST
):
496 dst
= do_bitop( tmp
, dst
, *opcode
& 0xf );
499 case OP_ARGS(TMP
,SRC
):
500 src
= do_bitop( tmp
, src
, *opcode
& 0xf );
503 printf( "Invalid opcode %x\n", *opcode
);
506 if (!dstUsed
) dst
= src
;
507 if (dst
) res
|= 1 << i
;
509 if (res
!= rop
) printf( "%02x: ERROR, res=%02x\n", rop
, res
);
513 #endif /* BITBLT_TEST */
516 /***********************************************************************
519 * Stretch a row of pixels. Helper function for BITBLT_StretchImage.
521 static void BITBLT_StretchRow( int *rowSrc
, int *rowDst
,
522 short startDst
, short widthDst
,
523 int xinc
, WORD mode
)
525 register int xsrc
= xinc
* startDst
;
529 case STRETCH_ANDSCANS
:
530 for(; widthDst
> 0; widthDst
--, xsrc
+= xinc
)
531 *rowDst
++ &= rowSrc
[xsrc
>> 16];
533 case STRETCH_ORSCANS
:
534 for(; widthDst
> 0; widthDst
--, xsrc
+= xinc
)
535 *rowDst
++ |= rowSrc
[xsrc
>> 16];
537 case STRETCH_DELETESCANS
:
538 for(; widthDst
> 0; widthDst
--, xsrc
+= xinc
)
539 *rowDst
++ = rowSrc
[xsrc
>> 16];
545 /***********************************************************************
548 * Shrink a row of pixels. Helper function for BITBLT_StretchImage.
550 static void BITBLT_ShrinkRow( int *rowSrc
, int *rowDst
,
551 short startSrc
, short widthSrc
,
552 int xinc
, WORD mode
)
554 register int xdst
= xinc
* startSrc
;
558 case STRETCH_ORSCANS
:
559 for(; widthSrc
> 0; widthSrc
--, xdst
+= xinc
)
560 rowDst
[xdst
>> 16] |= *rowSrc
++;
562 case STRETCH_ANDSCANS
:
563 for(; widthSrc
> 0; widthSrc
--, xdst
+= xinc
)
564 rowDst
[xdst
>> 16] &= *rowSrc
++;
566 case STRETCH_DELETESCANS
:
567 for(; widthSrc
> 0; widthSrc
--, xdst
+= xinc
)
568 rowDst
[xdst
>> 16] = *rowSrc
++;
574 /***********************************************************************
577 * Retrieve a row from an image. Helper function for BITBLT_StretchImage.
579 static void BITBLT_GetRow( XImage
*image
, int *pdata
, short row
,
580 short start
, short width
, short depthDst
,
581 int fg
, int bg
, BOOL swap
)
585 pdata
+= swap
? start
+width
-1 : start
;
586 if (image
->depth
== depthDst
) /* color -> color */
588 if (COLOR_PixelToPalette
&& (depthDst
!= 1))
589 if (swap
) for (i
= 0; i
< width
; i
++)
590 *pdata
-- = COLOR_PixelToPalette
[XGetPixel( image
, i
, row
)];
591 else for (i
= 0; i
< width
; i
++)
592 *pdata
++ = COLOR_PixelToPalette
[XGetPixel( image
, i
, row
)];
594 if (swap
) for (i
= 0; i
< width
; i
++)
595 *pdata
-- = XGetPixel( image
, i
, row
);
596 else for (i
= 0; i
< width
; i
++)
597 *pdata
++ = XGetPixel( image
, i
, row
);
601 if (image
->depth
== 1) /* monochrome -> color */
603 if (COLOR_PixelToPalette
)
605 fg
= COLOR_PixelToPalette
[fg
];
606 bg
= COLOR_PixelToPalette
[bg
];
608 if (swap
) for (i
= 0; i
< width
; i
++)
609 *pdata
-- = XGetPixel( image
, i
, row
) ? bg
: fg
;
610 else for (i
= 0; i
< width
; i
++)
611 *pdata
++ = XGetPixel( image
, i
, row
) ? bg
: fg
;
613 else /* color -> monochrome */
615 if (swap
) for (i
= 0; i
< width
; i
++)
616 *pdata
-- = (XGetPixel( image
, i
, row
) == bg
) ? 1 : 0;
617 else for (i
= 0; i
< width
; i
++)
618 *pdata
++ = (XGetPixel( image
, i
, row
) == bg
) ? 1 : 0;
624 /***********************************************************************
625 * BITBLT_StretchImage
627 * Stretch an X image.
629 static void BITBLT_StretchImage( XImage
*srcImage
, XImage
*dstImage
,
630 short widthSrc
, short heightSrc
,
631 short widthDst
, short heightDst
,
632 RECT
*visRectSrc
, RECT
*visRectDst
,
633 int foreground
, int background
, WORD mode
)
635 int *rowSrc
, *rowDst
, *pixel
;
636 int xinc
, yinc
, ysrc
, ydst
;
638 BOOL hstretch
, vstretch
, hswap
, vswap
;
640 hswap
= ((int)widthSrc
* widthDst
) < 0;
641 vswap
= ((int)heightSrc
* heightDst
) < 0;
642 widthSrc
= abs(widthSrc
);
643 heightSrc
= abs(heightSrc
);
644 widthDst
= abs(widthDst
);
645 heightDst
= abs(heightDst
);
647 dprintf_bitblt( stddeb
, "BITBLT_StretchImage: %dx%d -> %dx%d (mode=%d,h=%d,v=%d)\n",
648 widthSrc
, heightSrc
, widthDst
, heightDst
, mode
, hswap
, vswap
);
650 if (!(rowSrc
= (int *)malloc( (widthSrc
+widthDst
)*sizeof(int) ))) return;
651 rowDst
= rowSrc
+ widthSrc
;
653 /* When stretching, all modes are the same, and DELETESCANS is faster */
654 if ((widthSrc
< widthDst
) && (heightSrc
< heightDst
))
655 mode
= STRETCH_DELETESCANS
;
657 if (mode
!= STRETCH_DELETESCANS
)
658 memset( rowDst
, (mode
== STRETCH_ANDSCANS
) ? 0xff : 0x00,
659 widthDst
*sizeof(int) );
661 hstretch
= ((widthSrc
< widthDst
) || (mode
== STRETCH_DELETESCANS
));
662 vstretch
= ((heightSrc
< heightDst
) || (mode
== STRETCH_DELETESCANS
));
663 xinc
= hstretch
? ((int)widthSrc
<< 16) / widthDst
:
664 ((int)widthDst
<< 16) / widthSrc
;
668 yinc
= ((int)heightSrc
<< 16) / heightDst
;
669 ydst
= visRectDst
->top
;
670 ysrc
= yinc
* ydst
+ (vswap
? heightSrc
<<16 : 0);
674 yinc
= ((int)heightDst
<< 16) / heightSrc
;
675 ysrc
= visRectSrc
->top
;
676 ydst
= yinc
* ysrc
- (vswap
? (heightDst
-1)<<16 : 0);
679 while(vstretch
? (ydst
< visRectDst
->bottom
) : (ysrc
< visRectSrc
->bottom
))
681 /* Retrieve a source row */
682 BITBLT_GetRow( srcImage
, rowSrc
, vstretch
? ysrc
>> 16 : ysrc
,
683 visRectSrc
->left
, visRectSrc
->right
- visRectSrc
->left
,
684 dstImage
->depth
, foreground
, background
, hswap
);
686 /* Stretch or shrink it */
688 BITBLT_StretchRow( rowSrc
, rowDst
, visRectDst
->left
+
689 (hswap
? widthDst
: 0),
690 visRectDst
->right
-visRectDst
->left
, xinc
, mode
);
691 else BITBLT_ShrinkRow( rowSrc
, rowDst
, visRectSrc
->left
,
692 visRectSrc
->right
-visRectSrc
->left
, xinc
, mode
);
694 /* When shrinking, merge several source rows into the destination */
697 if (mode
== STRETCH_DELETESCANS
)
699 /* Simply skip the overlapping rows */
700 while (((ydst
+ yinc
) >> 16 == ydst
>> 16) &&
701 (ysrc
< visRectSrc
->bottom
-1))
707 else if (((ydst
+ yinc
) >> 16 == ydst
>> 16) &&
708 (ysrc
< visRectSrc
->bottom
-1))
712 continue; /* Restart loop for next overlapping row */
716 /* Store the destination row */
718 pixel
= rowDst
+ visRectDst
->right
- 1 + (hswap
? widthDst
: 0);
720 y
= visRectDst
->bottom
- (vstretch
? ydst
: ydst
>> 16);
722 y
= (vstretch
? ydst
: ydst
>> 16) - visRectDst
->top
;
723 for (x
= visRectDst
->right
-visRectDst
->left
-1; x
>= 0; x
--)
724 XPutPixel( dstImage
, x
, y
, *pixel
-- );
725 if (mode
!= STRETCH_DELETESCANS
)
726 memset( rowDst
, (mode
== STRETCH_ANDSCANS
) ? 0xff : 0x00,
727 widthDst
*sizeof(int) );
729 /* If stretching, make copies of the destination row */
733 char *pdata
= dstImage
->data
+ dstImage
->bytes_per_line
* y
;
734 while (((ysrc
+ yinc
) >> 16 == ysrc
>> 16) &&
735 (ydst
< visRectDst
->bottom
-1))
739 memcpy( pdata
- dstImage
->bytes_per_line
, pdata
,
740 dstImage
->bytes_per_line
);
741 pdata
-= dstImage
->bytes_per_line
;
745 memcpy( pdata
+ dstImage
->bytes_per_line
, pdata
,
746 dstImage
->bytes_per_line
);
747 pdata
+= dstImage
->bytes_per_line
;
766 /***********************************************************************
767 * BITBLT_GetSrcAreaStretch
769 * Retrieve an area from the source DC, stretching and mapping all the
770 * pixels to Windows colors.
772 static void BITBLT_GetSrcAreaStretch( DC
*dcSrc
, DC
*dcDst
,
773 Pixmap pixmap
, GC gc
,
774 short xSrc
, short ySrc
,
775 short widthSrc
, short heightSrc
,
776 short xDst
, short yDst
,
777 short widthDst
, short heightDst
,
778 RECT
*visRectSrc
, RECT
*visRectDst
)
780 XImage
*imageSrc
, *imageDst
;
782 RECT rectSrc
= *visRectSrc
;
783 RECT rectDst
= *visRectDst
;
784 OffsetRect( &rectSrc
, -xSrc
, -ySrc
);
785 OffsetRect( &rectDst
, -xDst
, -yDst
);
786 imageSrc
= XGetImage( display
, dcSrc
->u
.x
.drawable
,
787 visRectSrc
->left
, visRectSrc
->top
,
788 visRectSrc
->right
- visRectSrc
->left
,
789 visRectSrc
->bottom
- visRectSrc
->top
,
790 AllPlanes
, ZPixmap
);
791 XCREATEIMAGE( imageDst
, rectDst
.right
- rectDst
.left
,
792 rectDst
.bottom
- rectDst
.top
, dcDst
->w
.bitsPerPixel
);
793 BITBLT_StretchImage( imageSrc
, imageDst
, widthSrc
, heightSrc
,
794 widthDst
, heightDst
, &rectSrc
, &rectDst
,
795 dcDst
->w
.textPixel
, dcDst
->w
.bitsPerPixel
!= 1 ?
796 dcDst
->w
.backgroundPixel
: dcSrc
->w
.backgroundPixel
,
797 dcDst
->w
.stretchBltMode
);
798 XPutImage( display
, pixmap
, gc
, imageDst
, 0, 0, 0, 0,
799 rectDst
.right
- rectDst
.left
, rectDst
.bottom
- rectDst
.top
);
800 XDestroyImage( imageSrc
);
801 XDestroyImage( imageDst
);
805 /***********************************************************************
808 * Retrieve an area from the source DC, mapping all the
809 * pixels to Windows colors.
811 static void BITBLT_GetSrcArea( DC
*dcSrc
, DC
*dcDst
, Pixmap pixmap
, GC gc
,
812 short xSrc
, short ySrc
,
815 XImage
*imageSrc
, *imageDst
;
817 short width
= visRectSrc
->right
- visRectSrc
->left
;
818 short height
= visRectSrc
->bottom
- visRectSrc
->top
;
820 if (dcSrc
->w
.bitsPerPixel
== dcDst
->w
.bitsPerPixel
)
822 if (!COLOR_PixelToPalette
||
823 (dcDst
->w
.bitsPerPixel
== 1)) /* monochrome -> monochrome */
825 XCopyArea( display
, dcSrc
->u
.x
.drawable
, pixmap
, gc
,
826 visRectSrc
->left
, visRectSrc
->top
, width
, height
, 0, 0);
828 else /* color -> color */
830 imageSrc
= XGetImage( display
, dcSrc
->u
.x
.drawable
,
831 visRectSrc
->left
, visRectSrc
->top
,
832 width
, height
, AllPlanes
, ZPixmap
);
833 for (y
= 0; y
< height
; y
++)
834 for (x
= 0; x
< width
; x
++)
835 XPutPixel(imageSrc
, x
, y
,
836 COLOR_PixelToPalette
[XGetPixel(imageSrc
, x
, y
)]);
837 XPutImage( display
, pixmap
, gc
, imageSrc
,
838 0, 0, 0, 0, width
, height
);
839 XDestroyImage( imageSrc
);
844 if (dcSrc
->w
.bitsPerPixel
== 1) /* monochrome -> color */
846 if (COLOR_PixelToPalette
)
848 XSetBackground( display
, gc
,
849 COLOR_PixelToPalette
[dcDst
->w
.textPixel
] );
850 XSetForeground( display
, gc
,
851 COLOR_PixelToPalette
[dcDst
->w
.backgroundPixel
]);
855 XSetBackground( display
, gc
, dcDst
->w
.textPixel
);
856 XSetForeground( display
, gc
, dcDst
->w
.backgroundPixel
);
858 XCopyPlane( display
, dcSrc
->u
.x
.drawable
, pixmap
, gc
,
859 visRectSrc
->left
, visRectSrc
->top
,
860 width
, height
, 0, 0, 1 );
862 else /* color -> monochrome */
864 imageSrc
= XGetImage( display
, dcSrc
->u
.x
.drawable
,
865 visRectSrc
->left
, visRectSrc
->top
,
866 width
, height
, AllPlanes
, ZPixmap
);
867 XCREATEIMAGE( imageDst
, width
, height
, dcDst
->w
.bitsPerPixel
);
868 for (y
= 0; y
< height
; y
++)
869 for (x
= 0; x
< width
; x
++)
870 XPutPixel(imageDst
, x
, y
, (XGetPixel(imageSrc
,x
,y
) ==
871 dcSrc
->w
.backgroundPixel
) );
872 XPutImage( display
, pixmap
, gc
, imageDst
,
873 0, 0, 0, 0, width
, height
);
874 XDestroyImage( imageSrc
);
875 XDestroyImage( imageDst
);
881 /***********************************************************************
884 * Retrieve an area from the destination DC, mapping all the
885 * pixels to Windows colors.
887 static void BITBLT_GetDstArea( DC
*dc
, Pixmap pixmap
, GC gc
, RECT
*visRectDst
)
889 short width
= visRectDst
->right
- visRectDst
->left
;
890 short height
= visRectDst
->bottom
- visRectDst
->top
;
892 if (!COLOR_PixelToPalette
|| (dc
->w
.bitsPerPixel
== 1))
894 XCopyArea( display
, dc
->u
.x
.drawable
, pixmap
, gc
,
895 visRectDst
->left
, visRectDst
->top
, width
, height
, 0, 0 );
900 XImage
*image
= XGetImage( display
, dc
->u
.x
.drawable
,
901 visRectDst
->left
, visRectDst
->top
,
902 width
, height
, AllPlanes
, ZPixmap
);
903 for (y
= 0; y
< height
; y
++)
904 for (x
= 0; x
< width
; x
++)
905 XPutPixel( image
, x
, y
,
906 COLOR_PixelToPalette
[XGetPixel( image
, x
, y
)]);
907 XPutImage( display
, pixmap
, gc
, image
, 0, 0, 0, 0, width
, height
);
912 /***********************************************************************
915 * Put an area back into the destination DC, mapping the pixel
916 * colors to X pixels.
918 static void BITBLT_PutDstArea( DC
*dc
, Pixmap pixmap
, GC gc
, RECT
*visRectDst
)
920 short width
= visRectDst
->right
- visRectDst
->left
;
921 short height
= visRectDst
->bottom
- visRectDst
->top
;
923 if (!COLOR_PaletteToPixel
)
925 XCopyArea( display
, pixmap
, dc
->u
.x
.drawable
, gc
, 0, 0,
926 width
, height
, visRectDst
->left
, visRectDst
->top
);
931 XImage
*image
= XGetImage( display
, pixmap
, 0, 0, width
, height
,
932 AllPlanes
, ZPixmap
);
933 for (y
= 0; y
< height
; y
++)
934 for (x
= 0; x
< width
; x
++)
936 XPutPixel( image
, x
, y
,
937 COLOR_PaletteToPixel
[XGetPixel( image
, x
, y
)]);
939 XPutImage( display
, dc
->u
.x
.drawable
, gc
, image
, 0, 0,
940 visRectDst
->left
, visRectDst
->top
, width
, height
);
941 XDestroyImage( image
);
946 /***********************************************************************
947 * BITBLT_GetVisRectangles
949 * Get the source and destination visible rectangles for StretchBlt().
950 * Return FALSE if one of the rectangles is empty.
952 static BOOL
BITBLT_GetVisRectangles( DC
*dcDst
, short xDst
, short yDst
,
953 short widthDst
, short heightDst
,
954 DC
*dcSrc
, short xSrc
, short ySrc
,
955 short widthSrc
, short heightSrc
,
956 RECT
*visRectSrc
, RECT
*visRectDst
)
958 RECT tmpRect
, clipRect
;
960 if (widthSrc
< 0) { widthSrc
= -widthSrc
; xSrc
-= widthSrc
; }
961 if (widthDst
< 0) { widthDst
= -widthDst
; xDst
-= widthDst
; }
962 if (heightSrc
< 0) { heightSrc
= -heightSrc
; ySrc
-= heightSrc
; }
963 if (heightDst
< 0) { heightDst
= -heightDst
; yDst
-= heightDst
; }
965 /* Get the destination visible rectangle */
967 SetRect( &tmpRect
, xDst
, yDst
, xDst
+ widthDst
, yDst
+ heightDst
);
968 GetRgnBox( dcDst
->w
.hGCClipRgn
, &clipRect
);
969 OffsetRect( &clipRect
, dcDst
->w
.DCOrgX
, dcDst
->w
.DCOrgY
);
970 if (!IntersectRect( visRectDst
, &tmpRect
, &clipRect
)) return FALSE
;
972 /* Get the source visible rectangle */
974 if (!dcSrc
) return TRUE
;
975 SetRect( &tmpRect
, xSrc
, ySrc
, xSrc
+ widthSrc
, ySrc
+ heightSrc
);
976 /* Apparently the clip region is only for output, so use hVisRgn here */
977 GetRgnBox( dcSrc
->w
.hVisRgn
, &clipRect
);
978 OffsetRect( &clipRect
, dcSrc
->w
.DCOrgX
, dcSrc
->w
.DCOrgY
);
979 if (!IntersectRect( visRectSrc
, &tmpRect
, &clipRect
)) return FALSE
;
981 /* Intersect the rectangles */
983 if ((widthSrc
== widthDst
) && (heightSrc
== heightDst
)) /* no stretching */
985 OffsetRect( visRectSrc
, xDst
- xSrc
, yDst
- ySrc
);
986 if (!IntersectRect( &tmpRect
, visRectSrc
, visRectDst
)) return FALSE
;
987 *visRectSrc
= *visRectDst
= tmpRect
;
988 OffsetRect( visRectSrc
, xSrc
- xDst
, ySrc
- yDst
);
990 else /* stretching */
992 visRectSrc
->left
= xDst
+ (visRectSrc
->left
-xSrc
)*widthDst
/widthSrc
;
993 visRectSrc
->top
= yDst
+ (visRectSrc
->top
-ySrc
)*heightDst
/heightSrc
;
994 visRectSrc
->right
= xDst
+
995 ((visRectSrc
->right
-xSrc
) * widthDst
) / widthSrc
;
996 visRectSrc
->bottom
= yDst
+
997 ((visRectSrc
->bottom
-ySrc
) * heightDst
) / heightSrc
;
998 if (!IntersectRect( &tmpRect
, visRectSrc
, visRectDst
)) return FALSE
;
999 *visRectSrc
= *visRectDst
= tmpRect
;
1000 visRectSrc
->left
= xSrc
+ (visRectSrc
->left
-xDst
)*widthSrc
/widthDst
;
1001 visRectSrc
->top
= ySrc
+ (visRectSrc
->top
-yDst
)*heightSrc
/heightDst
;
1002 visRectSrc
->right
= xSrc
+
1003 ((visRectSrc
->right
-xDst
) * widthSrc
) / widthDst
;
1004 visRectSrc
->bottom
= ySrc
+
1005 ((visRectSrc
->bottom
-yDst
) * heightSrc
) / heightDst
;
1006 if (IsRectEmpty( visRectSrc
)) return FALSE
;
1012 /***********************************************************************
1013 * BITBLT_InternalStretchBlt
1015 * Implementation of PatBlt(), BitBlt() and StretchBlt().
1017 BOOL
BITBLT_InternalStretchBlt( DC
*dcDst
, short xDst
, short yDst
,
1018 short widthDst
, short heightDst
,
1019 DC
*dcSrc
, short xSrc
, short ySrc
,
1020 short widthSrc
, short heightSrc
, DWORD rop
)
1022 BOOL usePat
, useSrc
, useDst
, destUsed
, fStretch
, fNullBrush
;
1023 RECT visRectDst
, visRectSrc
;
1024 short width
, height
;
1026 Pixmap pixmaps
[3] = { 0, 0, 0 }; /* pixmaps for DST, SRC, TMP */
1029 usePat
= (((rop
>> 4) & 0x0f0000) != (rop
& 0x0f0000));
1030 useSrc
= (((rop
>> 2) & 0x330000) != (rop
& 0x330000));
1031 useDst
= (((rop
>> 1) & 0x550000) != (rop
& 0x550000));
1032 if (!dcSrc
&& useSrc
) return FALSE
;
1034 /* Map the coordinates to device coords */
1036 xDst
= dcDst
->w
.DCOrgX
+ XLPTODP( dcDst
, xDst
);
1037 yDst
= dcDst
->w
.DCOrgY
+ YLPTODP( dcDst
, yDst
);
1038 widthDst
= widthDst
* dcDst
->w
.VportExtX
/ dcDst
->w
.WndExtX
;
1039 heightDst
= heightDst
* dcDst
->w
.VportExtY
/ dcDst
->w
.WndExtY
;
1041 dprintf_bitblt( stddeb
, " vportdst=%d,%d-%d,%d wnddst=%d,%d-%d,%d\n",
1042 dcDst
->w
.VportOrgX
, dcDst
->w
.VportOrgY
,
1043 dcDst
->w
.VportExtX
, dcDst
->w
.VportExtY
,
1044 dcDst
->w
.WndOrgX
, dcDst
->w
.WndOrgY
,
1045 dcDst
->w
.WndExtX
, dcDst
->w
.WndExtY
);
1046 dprintf_bitblt( stddeb
, " rectdst=%d,%d-%d,%d orgdst=%d,%d\n",
1047 xDst
, yDst
, widthDst
, heightDst
,
1048 dcDst
->w
.DCOrgX
, dcDst
->w
.DCOrgY
);
1052 xSrc
= dcSrc
->w
.DCOrgX
+ XLPTODP( dcSrc
, xSrc
);
1053 ySrc
= dcSrc
->w
.DCOrgY
+ YLPTODP( dcSrc
, ySrc
);
1054 widthSrc
= widthSrc
* dcSrc
->w
.VportExtX
/ dcSrc
->w
.WndExtX
;
1055 heightSrc
= heightSrc
* dcSrc
->w
.VportExtY
/ dcSrc
->w
.WndExtY
;
1056 fStretch
= (widthSrc
!= widthDst
) || (heightSrc
!= heightDst
);
1057 dprintf_bitblt( stddeb
," vportsrc=%d,%d-%d,%d wndsrc=%d,%d-%d,%d\n",
1058 dcSrc
->w
.VportOrgX
, dcSrc
->w
.VportOrgY
,
1059 dcSrc
->w
.VportExtX
, dcSrc
->w
.VportExtY
,
1060 dcSrc
->w
.WndOrgX
, dcSrc
->w
.WndOrgY
,
1061 dcSrc
->w
.WndExtX
, dcSrc
->w
.WndExtY
);
1062 dprintf_bitblt( stddeb
, " rectsrc=%d,%d-%d,%d orgsrc=%d,%d\n",
1063 xSrc
, ySrc
, widthSrc
, heightSrc
,
1064 dcSrc
->w
.DCOrgX
, dcSrc
->w
.DCOrgY
);
1065 if (!BITBLT_GetVisRectangles( dcDst
, xDst
, yDst
, widthDst
, heightDst
,
1066 dcSrc
, xSrc
, ySrc
, widthSrc
, heightSrc
,
1067 &visRectSrc
, &visRectDst
))
1069 dprintf_bitblt( stddeb
, " vissrc=%d,%d-%d,%d visdst=%d,%d-%d,%d\n",
1070 visRectSrc
.left
, visRectSrc
.top
,
1071 visRectSrc
.right
, visRectSrc
.bottom
,
1072 visRectDst
.left
, visRectDst
.top
,
1073 visRectDst
.right
, visRectDst
.bottom
);
1078 if (!BITBLT_GetVisRectangles( dcDst
, xDst
, yDst
, widthDst
, heightDst
,
1079 NULL
, 0, 0, 0, 0, NULL
, &visRectDst
))
1081 dprintf_bitblt( stddeb
, " vissrc=none visdst=%d,%d-%d,%d\n",
1082 visRectDst
.left
, visRectDst
.top
,
1083 visRectDst
.right
, visRectDst
.bottom
);
1086 width
= visRectDst
.right
- visRectDst
.left
;
1087 height
= visRectDst
.bottom
- visRectDst
.top
;
1089 if (!fStretch
) switch(rop
) /* A few optimisations */
1091 case BLACKNESS
: /* 0x00 */
1092 if ((dcDst
->w
.bitsPerPixel
== 1) || !COLOR_PaletteToPixel
)
1093 XSetFunction( display
, dcDst
->u
.x
.gc
, GXclear
);
1096 XSetFunction( display
, dcDst
->u
.x
.gc
, GXcopy
);
1097 XSetForeground( display
, dcDst
->u
.x
.gc
, COLOR_PaletteToPixel
[0] );
1098 XSetFillStyle( display
, dcDst
->u
.x
.gc
, FillSolid
);
1100 XFillRectangle( display
, dcDst
->u
.x
.drawable
, dcDst
->u
.x
.gc
,
1101 visRectDst
.left
, visRectDst
.top
, width
, height
);
1104 case PATINVERT
: /* 0x5a */
1105 /* FIXME: This is not really correct, but for now PATINVERT is */
1106 /* used to draw the window moving frame, so it has to be fast. */
1107 if (!DC_SetupGCForBrush( dcDst
)) return TRUE
;
1108 XSetFunction( display
, dcDst
->u
.x
.gc
, GXxor
);
1109 XFillRectangle( display
, dcDst
->u
.x
.drawable
, dcDst
->u
.x
.gc
,
1110 visRectDst
.left
, visRectDst
.top
, width
, height
);
1113 case SRCCOPY
: /* 0xcc */
1114 if (dcSrc
->w
.bitsPerPixel
== dcDst
->w
.bitsPerPixel
)
1116 XSetFunction( display
, dcDst
->u
.x
.gc
, GXcopy
);
1117 XCopyArea( display
, dcSrc
->u
.x
.drawable
,
1118 dcDst
->u
.x
.drawable
, dcDst
->u
.x
.gc
,
1119 visRectSrc
.left
, visRectSrc
.top
,
1120 width
, height
, visRectDst
.left
, visRectDst
.top
);
1123 if (dcSrc
->w
.bitsPerPixel
== 1)
1125 XSetBackground( display
, dcDst
->u
.x
.gc
, dcDst
->w
.textPixel
);
1126 XSetForeground( display
, dcDst
->u
.x
.gc
, dcDst
->w
.backgroundPixel
);
1127 XSetFunction( display
, dcDst
->u
.x
.gc
, GXcopy
);
1128 XCopyPlane( display
, dcSrc
->u
.x
.drawable
,
1129 dcDst
->u
.x
.drawable
, dcDst
->u
.x
.gc
,
1130 visRectSrc
.left
, visRectSrc
.top
,
1131 width
, height
, visRectDst
.left
, visRectDst
.top
, 1 );
1136 case PATCOPY
: /* 0xf0 */
1137 if (!DC_SetupGCForBrush( dcDst
)) return TRUE
;
1138 XSetFunction( display
, dcDst
->u
.x
.gc
, GXcopy
);
1139 XFillRectangle( display
, dcDst
->u
.x
.drawable
, dcDst
->u
.x
.gc
,
1140 visRectDst
.left
, visRectDst
.top
, width
, height
);
1143 case WHITENESS
: /* 0xff */
1144 if ((dcDst
->w
.bitsPerPixel
== 1) || !COLOR_PaletteToPixel
)
1145 XSetFunction( display
, dcDst
->u
.x
.gc
, GXset
);
1148 XSetFunction( display
, dcDst
->u
.x
.gc
, GXcopy
);
1149 XSetForeground( display
, dcDst
->u
.x
.gc
,
1150 COLOR_PaletteToPixel
[COLOR_ColormapSize
-1] );
1151 XSetFillStyle( display
, dcDst
->u
.x
.gc
, FillSolid
);
1153 XFillRectangle( display
, dcDst
->u
.x
.drawable
, dcDst
->u
.x
.gc
,
1154 visRectDst
.left
, visRectDst
.top
, width
, height
);
1158 tmpGC
= XCreateGC( display
, dcDst
->u
.x
.drawable
, 0, NULL
);
1159 pixmaps
[DST
] = XCreatePixmap( display
, rootWindow
, width
, height
,
1160 dcDst
->w
.bitsPerPixel
);
1163 pixmaps
[SRC
] = XCreatePixmap( display
, rootWindow
, width
, height
,
1164 dcDst
->w
.bitsPerPixel
);
1166 BITBLT_GetSrcAreaStretch( dcSrc
, dcDst
, pixmaps
[SRC
], tmpGC
,
1167 xSrc
, ySrc
, widthSrc
, heightSrc
,
1168 xDst
, yDst
, widthDst
, heightDst
,
1169 &visRectSrc
, &visRectDst
);
1171 BITBLT_GetSrcArea( dcSrc
, dcDst
, pixmaps
[SRC
], tmpGC
,
1172 xSrc
, ySrc
, &visRectSrc
);
1174 if (useDst
) BITBLT_GetDstArea( dcDst
, pixmaps
[DST
], tmpGC
, &visRectDst
);
1175 if (usePat
) fNullBrush
= !DC_SetupGCForPatBlt( dcDst
, tmpGC
, TRUE
);
1176 else fNullBrush
= FALSE
;
1179 for (opcode
= BITBLT_Opcodes
[(rop
>> 16) & 0xff]; *opcode
; opcode
++)
1181 if (OP_DST(*opcode
) == DST
) destUsed
= TRUE
;
1182 XSetFunction( display
, tmpGC
, OP_ROP(*opcode
) );
1183 switch(OP_SRCDST(*opcode
))
1185 case OP_ARGS(DST
,TMP
):
1186 case OP_ARGS(SRC
,TMP
):
1188 pixmaps
[TMP
] = XCreatePixmap( display
, rootWindow
,
1190 dcDst
->w
.bitsPerPixel
);
1192 case OP_ARGS(DST
,SRC
):
1193 case OP_ARGS(SRC
,DST
):
1194 case OP_ARGS(TMP
,SRC
):
1195 case OP_ARGS(TMP
,DST
):
1196 XCopyArea( display
, pixmaps
[OP_SRC(*opcode
)],
1197 pixmaps
[OP_DST(*opcode
)], tmpGC
,
1198 0, 0, width
, height
, 0, 0 );
1201 case OP_ARGS(PAT
,TMP
):
1202 if (!pixmaps
[TMP
] && !fNullBrush
)
1203 pixmaps
[TMP
] = XCreatePixmap( display
, rootWindow
,
1205 dcDst
->w
.bitsPerPixel
);
1207 case OP_ARGS(PAT
,DST
):
1208 case OP_ARGS(PAT
,SRC
):
1210 XFillRectangle( display
, pixmaps
[OP_DST(*opcode
)],
1211 tmpGC
, 0, 0, width
, height
);
1215 XSetFunction( display
, dcDst
->u
.x
.gc
, GXcopy
);
1216 BITBLT_PutDstArea( dcDst
, pixmaps
[destUsed
? DST
: SRC
],
1217 dcDst
->u
.x
.gc
, &visRectDst
);
1218 XFreePixmap( display
, pixmaps
[DST
] );
1219 if (pixmaps
[SRC
]) XFreePixmap( display
, pixmaps
[SRC
] );
1220 if (pixmaps
[TMP
]) XFreePixmap( display
, pixmaps
[TMP
] );
1221 XFreeGC( display
, tmpGC
);
1226 /***********************************************************************
1229 BOOL
PatBlt( HDC hdc
, short left
, short top
,
1230 short width
, short height
, DWORD rop
)
1232 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
1235 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
1236 if (!dc
) return FALSE
;
1237 MF_MetaParam6(dc
, META_PATBLT
, left
, top
, width
, height
,
1238 HIWORD(rop
), LOWORD(rop
));
1242 dprintf_bitblt(stddeb
, "PatBlt: %04x %d,%d %dx%d %06lx\n",
1243 hdc
, left
, top
, width
, height
, rop
);
1245 return CallTo32_LargeStack( (int(*)())BITBLT_InternalStretchBlt
, 11,
1246 dc
, left
, top
, width
, height
,
1247 NULL
, 0, 0, 0, 0, rop
);
1251 /***********************************************************************
1254 BOOL
BitBlt( HDC hdcDst
, INT xDst
, INT yDst
, INT width
, INT height
,
1255 HDC hdcSrc
, INT xSrc
, INT ySrc
, DWORD rop
)
1259 if (!(dcDst
= (DC
*)GDI_GetObjPtr( hdcDst
, DC_MAGIC
)))
1261 dcDst
= (DC
*)GDI_GetObjPtr( hdcDst
, METAFILE_DC_MAGIC
);
1262 if (!dcDst
) return FALSE
;
1263 return MF_BitBlt( dcDst
, xDst
, yDst
, width
, height
,
1264 hdcSrc
, xSrc
, ySrc
, rop
);
1266 dcSrc
= (DC
*) GDI_GetObjPtr( hdcSrc
, DC_MAGIC
);
1268 dprintf_bitblt(stddeb
,
1269 "BitBlt: %04x %d,%d %d bpp -> %04x %d,%d %dx%dx%d rop=%06lx\n",
1270 hdcSrc
, xSrc
, ySrc
, dcSrc
? dcSrc
->w
.bitsPerPixel
: 0,
1271 hdcDst
, xDst
, yDst
, width
, height
, dcDst
->w
.bitsPerPixel
, rop
);
1273 return CallTo32_LargeStack( (int(*)())BITBLT_InternalStretchBlt
, 11,
1274 dcDst
, xDst
, yDst
, width
, height
,
1275 dcSrc
, xSrc
, ySrc
, width
, height
, rop
);
1279 /***********************************************************************
1280 * StretchBlt (GDI.35)
1282 BOOL
StretchBlt( HDC hdcDst
, short xDst
, short yDst
,
1283 short widthDst
, short heightDst
,
1284 HDC hdcSrc
, short xSrc
, short ySrc
,
1285 short widthSrc
, short heightSrc
, DWORD rop
)
1289 if (!(dcDst
= (DC
*) GDI_GetObjPtr( hdcDst
, DC_MAGIC
)))
1291 if (!(dcDst
= (DC
*)GDI_GetObjPtr( hdcDst
, METAFILE_DC_MAGIC
)))
1293 return MF_StretchBlt( dcDst
, xDst
, yDst
, widthDst
, heightDst
,
1294 hdcSrc
, xSrc
, ySrc
, widthSrc
, heightSrc
, rop
);
1297 dcSrc
= (DC
*) GDI_GetObjPtr( hdcSrc
, DC_MAGIC
);
1298 dprintf_bitblt(stddeb
,
1299 "StretchBlt: %04x %d,%d %dx%dx%d -> %04x %d,%d %dx%dx%d rop=%06lx\n",
1300 hdcSrc
, xSrc
, ySrc
, widthSrc
, heightSrc
,
1301 dcSrc
? dcSrc
->w
.bitsPerPixel
: 0, hdcDst
, xDst
, yDst
,
1302 widthDst
, heightDst
, dcDst
->w
.bitsPerPixel
, rop
);
1304 return CallTo32_LargeStack( (int(*)())BITBLT_InternalStretchBlt
, 11,
1305 dcDst
, xDst
, yDst
, widthDst
, heightDst
,
1306 dcSrc
, xSrc
, ySrc
, widthSrc
, heightSrc
, rop
);
1308 /***********************************************************************
1309 * FastWindowFrame (GDI.400)
1312 FastWindowFrame(WORD x1
,DWORD x2
,WORD x3
,WORD x4
,DWORD x5
) {
1313 dprintf_gdi(stdnimp
,"FastWindowFrame (%04x, %08lx, %04x, %04x, %08lx) // unimplemented!\n",x1
,x2
,x3
,x4
,x5
);
1314 return 0xFFFF; /* failed? */