Release 950122
[wine/multimedia.git] / objects / bitblt.c
blob41f889d5da4ea12c1821ab3bcdeccb5aeab4a17a
1 /*
2 * GDI bit-blit operations
4 * Copyright 1993, 1994 Alexandre Julliard
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <X11/Xlib.h>
10 #include <X11/Intrinsic.h>
11 #include "bitmap.h"
12 #include "color.h"
13 #include "dc.h"
14 #include "metafile.h"
15 #include "options.h"
16 #include "stddebug.h"
17 /* #define DEBUG_BITBLT */
18 #include "debug.h"
21 #define DST 0 /* Destination drawable */
22 #define SRC 1 /* Source drawable */
23 #define TMP 2 /* Temporary drawable */
24 #define PAT 3 /* Pattern (brush) in destination DC */
26 #define OP(src,dst,rop) (OP_ARGS(src,dst) << 4 | (rop))
27 #define OP_ARGS(src,dst) (((src) << 2) | (dst))
29 #define OP_SRC(opcode) ((opcode) >> 6)
30 #define OP_DST(opcode) (((opcode) >> 4) & 3)
31 #define OP_SRCDST(opcode) ((opcode) >> 4)
32 #define OP_ROP(opcode) ((opcode) & 0x0f)
34 #define MAX_OP_LEN 6 /* Longest opcode + 1 for the terminating 0 */
36 static const unsigned char BITBLT_Opcodes[256][MAX_OP_LEN] =
38 { OP(PAT,DST,GXclear) }, /* 0x00 0 */
39 { OP(PAT,SRC,GXor), OP(SRC,DST,GXnor) }, /* 0x01 ~(D|(P|S)) */
40 { OP(PAT,SRC,GXnor), OP(SRC,DST,GXand) }, /* 0x02 D&~(P|S) */
41 { OP(PAT,SRC,GXnor) }, /* 0x03 ~(P|S) */
42 { OP(PAT,DST,GXnor), OP(SRC,DST,GXand) }, /* 0x04 S&~(D|P) */
43 { OP(PAT,DST,GXnor) }, /* 0x05 ~(D|P) */
44 { OP(SRC,DST,GXequiv), OP(PAT,DST,GXnor), }, /* 0x06 ~(P|~(D^S)) */
45 { OP(SRC,DST,GXand), OP(PAT,DST,GXnor) }, /* 0x07 ~(P|(D&S)) */
46 { OP(PAT,DST,GXandInverted), OP(SRC,DST,GXand) },/* 0x08 S&D&~P */
47 { OP(SRC,DST,GXxor), OP(PAT,DST,GXnor) }, /* 0x09 ~(P|(D^S)) */
48 { OP(PAT,DST,GXandInverted) }, /* 0x0a D&~P */
49 { OP(SRC,DST,GXandReverse), OP(PAT,DST,GXnor) }, /* 0x0b ~(P|(S&~D)) */
50 { OP(PAT,SRC,GXandInverted) }, /* 0x0c S&~P */
51 { OP(SRC,DST,GXandInverted), OP(PAT,DST,GXnor) },/* 0x0d ~(P|(D&~S)) */
52 { OP(SRC,DST,GXnor), OP(PAT,DST,GXnor) }, /* 0x0e ~(P|~(D|S)) */
53 { OP(PAT,DST,GXcopyInverted) }, /* 0x0f ~P */
54 { OP(SRC,DST,GXnor), OP(PAT,DST,GXand) }, /* 0x10 P&~(S|D) */
55 { OP(SRC,DST,GXnor) }, /* 0x11 ~(D|S) */
56 { OP(PAT,DST,GXequiv), OP(SRC,DST,GXnor) }, /* 0x12 ~(S|~(D^P)) */
57 { OP(PAT,DST,GXand), OP(SRC,DST,GXnor) }, /* 0x13 ~(S|(D&P)) */
58 { OP(PAT,SRC,GXequiv), OP(SRC,DST,GXnor) }, /* 0x14 ~(D|~(P^S)) */
59 { OP(PAT,SRC,GXand), OP(SRC,DST,GXnor) }, /* 0x15 ~(D|(P&S)) */
60 { OP(SRC,TMP,GXcopy), OP(PAT,TMP,GXnand),
61 OP(TMP,DST,GXand), OP(SRC,DST,GXxor),
62 OP(PAT,DST,GXxor) }, /* 0x16 P^S^(D&~(P&S) */
63 { OP(SRC,TMP,GXcopy), OP(SRC,DST,GXxor),
64 OP(PAT,SRC,GXxor), OP(SRC,DST,GXand),
65 OP(TMP,DST,GXequiv) }, /* 0x17 ~S^((S^P)&(S^D))*/
66 { OP(PAT,SRC,GXxor), OP(PAT,DST,GXxor),
67 OP(SRC,DST,GXand) }, /* 0x18 (S^P)&(D^P) */
68 { OP(SRC,TMP,GXcopy), OP(PAT,TMP,GXnand),
69 OP(TMP,DST,GXand), OP(SRC,DST,GXequiv) }, /* 0x19 ~S^(D&~(P&S)) */
70 { OP(PAT,SRC,GXand), OP(SRC,DST,GXor),
71 OP(PAT,DST,GXxor) }, /* 0x1a P^(D|(S&P)) */
72 { OP(SRC,TMP,GXcopy), OP(PAT,TMP,GXxor),
73 OP(TMP,DST,GXand), OP(SRC,DST,GXequiv) }, /* 0x1b ~S^(D&(P^S)) */
74 { OP(PAT,DST,GXand), OP(SRC,DST,GXor),
75 OP(PAT,DST,GXxor) }, /* 0x1c P^(S|(D&P)) */
76 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXxor),
77 OP(SRC,DST,GXand), OP(TMP,DST,GXequiv) }, /* 0x1d ~D^(S&(D^P)) */
78 { OP(SRC,DST,GXor), OP(PAT,DST,GXxor) }, /* 0x1e P^(D|S) */
79 { OP(SRC,DST,GXor), OP(PAT,DST,GXnand) }, /* 0x1f ~(P&(D|S)) */
80 { OP(PAT,SRC,GXandReverse), OP(SRC,DST,GXand) }, /* 0x20 D&(P&~S) */
81 { OP(PAT,DST,GXxor), OP(SRC,DST,GXnor) }, /* 0x21 ~(S|(D^P)) */
82 { OP(SRC,DST,GXandInverted) }, /* 0x22 ~S&D */
83 { OP(PAT,DST,GXandReverse), OP(SRC,DST,GXnor) }, /* 0x23 ~(S|(P&~D)) */
84 { OP(SRC,DST,GXxor), OP(PAT,SRC,GXxor),
85 OP(SRC,DST,GXand) }, /* 0x24 (S^P)&(S^D) */
86 { OP(PAT,SRC,GXnand), OP(SRC,DST,GXand),
87 OP(PAT,DST,GXequiv) }, /* 0x25 ~P^(D&~(S&P)) */
88 { OP(SRC,TMP,GXcopy), OP(PAT,TMP,GXand),
89 OP(TMP,DST,GXor), OP(SRC,DST,GXxor) }, /* 0x26 S^(D|(S&P)) */
90 { OP(SRC,TMP,GXcopy), OP(PAT,TMP,GXequiv),
91 OP(TMP,DST,GXor), OP(SRC,DST,GXxor) }, /* 0x27 S^(D|~(P^S)) */
92 { OP(PAT,SRC,GXxor), OP(SRC,DST,GXand) }, /* 0x28 D&(P^S) */
93 { OP(SRC,TMP,GXcopy), OP(PAT,TMP,GXand),
94 OP(TMP,DST,GXor), OP(SRC,DST,GXxor),
95 OP(PAT,DST,GXequiv) }, /* 0x29 ~P^S^(D|(P&S)) */
96 { OP(PAT,SRC,GXnand), OP(SRC,DST,GXand) }, /* 0x2a D&~(P&S) */
97 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXxor),
98 OP(PAT,DST,GXxor), OP(SRC,DST,GXand),
99 OP(TMP,DST,GXequiv) }, /* 0x2b ~S^((P^S)&(P^D))*/
100 { OP(SRC,DST,GXor), OP(PAT,DST,GXand),
101 OP(SRC,DST,GXxor) }, /* 0x2c S^(P&(S|D)) */
102 { OP(SRC,DST,GXorReverse), OP(PAT,DST,GXxor) }, /* 0x2d P^(S|~D) */
103 { OP(PAT,DST,GXxor), OP(SRC,DST,GXor),
104 OP(PAT,DST,GXxor) }, /* 0x2e P^(S|(D^P)) */
105 { OP(SRC,DST,GXorReverse), OP(PAT,DST,GXnand) }, /* 0x2f ~(P&(S|~D)) */
106 { OP(PAT,SRC,GXandReverse) }, /* 0x30 P&~S */
107 { OP(PAT,DST,GXandInverted), OP(SRC,DST,GXnor) },/* 0x31 ~(S|(D&~P)) */
108 { OP(SRC,DST,GXor), OP(PAT,DST,GXor),
109 OP(SRC,DST,GXxor) }, /* 0x32 S^(D|P|S) */
110 { OP(SRC,DST,GXcopyInverted) }, /* 0x33 ~S */
111 { OP(SRC,DST,GXand), OP(PAT,DST,GXor),
112 OP(SRC,DST,GXxor) }, /* 0x34 S^(P|(D&S)) */
113 { OP(SRC,DST,GXequiv), OP(PAT,DST,GXor),
114 OP(SRC,DST,GXxor) }, /* 0x35 S^(P|~(D^S)) */
115 { OP(PAT,DST,GXor), OP(SRC,DST,GXxor) }, /* 0x36 S^(D|P) */
116 { OP(PAT,DST,GXor), OP(SRC,DST,GXnand) }, /* 0x37 ~(S&(D|P)) */
117 { OP(PAT,DST,GXor), OP(SRC,DST,GXand),
118 OP(PAT,DST,GXxor) }, /* 0x38 P^(S&(D|P)) */
119 { OP(PAT,DST,GXorReverse), OP(SRC,DST,GXxor) }, /* 0x39 S^(P|~D) */
120 { OP(SRC,DST,GXxor), OP(PAT,DST,GXor),
121 OP(SRC,DST,GXxor) }, /* 0x3a S^(P|(D^S)) */
122 { OP(PAT,DST,GXorReverse), OP(SRC,DST,GXnand) }, /* 0x3b ~(S&(P|~D)) */
123 { OP(PAT,SRC,GXxor) }, /* 0x3c P^S */
124 { OP(SRC,DST,GXnor), OP(PAT,DST,GXor),
125 OP(SRC,DST,GXxor) }, /* 0x3d S^(P|~(D|S)) */
126 { OP(SRC,DST,GXandInverted), OP(PAT,DST,GXor),
127 OP(SRC,DST,GXxor) }, /* 0x3e S^(P|(D&~S)) */
128 { OP(PAT,SRC,GXnand) }, /* 0x3f ~(P&S) */
129 { OP(SRC,DST,GXandReverse), OP(PAT,DST,GXand) }, /* 0x40 P&S&~D */
130 { OP(PAT,SRC,GXxor), OP(SRC,DST,GXnor) }, /* 0x41 ~(D|(P^S)) */
131 { OP(DST,SRC,GXxor), OP(PAT,DST,GXxor),
132 OP(SRC,DST,GXand) }, /* 0x42 (S^D)&(P^D) */
133 { OP(SRC,DST,GXnand), OP(PAT,DST,GXand),
134 OP(SRC,DST,GXequiv) }, /* 0x43 ~S^(P&~(D&S)) */
135 { OP(SRC,DST,GXandReverse) }, /* 0x44 S&~D */
136 { OP(PAT,SRC,GXandReverse), OP(SRC,DST,GXnor) }, /* 0x45 ~(D|(P&~S)) */
137 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXand),
138 OP(SRC,DST,GXor), OP(TMP,DST,GXxor) }, /* 0x46 D^(S|(P&D)) */
139 { OP(PAT,DST,GXxor), OP(SRC,DST,GXand),
140 OP(PAT,DST,GXequiv) }, /* 0x47 ~P^(S&(D^P)) */
141 { OP(PAT,DST,GXxor), OP(SRC,DST,GXand) }, /* 0x48 S&(P^D) */
142 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXand),
143 OP(SRC,DST,GXor), OP(TMP,DST,GXxor),
144 OP(PAT,DST,GXequiv) }, /* 0x49 ~P^D^(S|(P&D)) */
145 { OP(DST,SRC,GXor), OP(PAT,SRC,GXand),
146 OP(SRC,DST,GXxor) }, /* 0x4a D^(P&(S|D)) */
147 { OP(SRC,DST,GXorInverted), OP(PAT,DST,GXxor) }, /* 0x4b P^(D|~S) */
148 { OP(PAT,DST,GXnand), OP(SRC,DST,GXand) }, /* 0x4c S&~(D&P) */
149 { OP(SRC,TMP,GXcopy), OP(SRC,DST,GXxor),
150 OP(PAT,SRC,GXxor), OP(SRC,DST,GXor),
151 OP(TMP,DST,GXequiv) }, /* 0x4d ~S^((S^P)|(S^D))*/
152 { OP(PAT,SRC,GXxor), OP(SRC,DST,GXor),
153 OP(PAT,DST,GXxor) }, /* 0x4e P^(D|(S^P)) */
154 { OP(SRC,DST,GXorInverted), OP(PAT,DST,GXnand) },/* 0x4f ~(P&(D|~S)) */
155 { OP(PAT,DST,GXandReverse) }, /* 0x50 P&~D */
156 { OP(PAT,SRC,GXandInverted), OP(SRC,DST,GXnor) },/* 0x51 ~(D|(S&~P)) */
157 { OP(DST,SRC,GXand), OP(PAT,SRC,GXor),
158 OP(SRC,DST,GXxor) }, /* 0x52 D^(P|(S&D)) */
159 { OP(SRC,DST,GXxor), OP(PAT,DST,GXand),
160 OP(SRC,DST,GXequiv) }, /* 0x53 ~S^(P&(D^S)) */
161 { OP(PAT,SRC,GXnor), OP(SRC,DST,GXnor) }, /* 0x54 ~(D|~(P|S)) */
162 { OP(PAT,DST,GXinvert) }, /* 0x55 ~D */
163 { OP(PAT,SRC,GXor), OP(SRC,DST,GXxor) }, /* 0x56 D^(P|S) */
164 { OP(PAT,SRC,GXor), OP(SRC,DST,GXnand) }, /* 0x57 ~(D&(P|S)) */
165 { OP(PAT,SRC,GXor), OP(SRC,DST,GXand),
166 OP(PAT,DST,GXxor) }, /* 0x58 P^(D&(P|S)) */
167 { OP(PAT,SRC,GXorReverse), OP(SRC,DST,GXxor) }, /* 0x59 D^(P|~S) */
168 { OP(PAT,DST,GXxor) }, /* 0x5a D^P */
169 { OP(DST,SRC,GXnor), OP(PAT,SRC,GXor),
170 OP(SRC,DST,GXxor) }, /* 0x5b D^(P|~(S|D)) */
171 { OP(DST,SRC,GXxor), OP(PAT,SRC,GXor),
172 OP(SRC,DST,GXxor) }, /* 0x5c D^(P|(S^D)) */
173 { OP(PAT,SRC,GXorReverse), OP(SRC,DST,GXnand) }, /* 0x5d ~(D&(P|~S)) */
174 { OP(DST,SRC,GXandInverted), OP(PAT,SRC,GXor),
175 OP(SRC,DST,GXxor) }, /* 0x5e D^(P|(S&~D)) */
176 { OP(PAT,DST,GXnand) }, /* 0x5f ~(D&P) */
177 { OP(SRC,DST,GXxor), OP(PAT,DST,GXand) }, /* 0x60 P&(D^S) */
178 { OP(DST,TMP,GXcopy), OP(SRC,DST,GXand),
179 OP(PAT,DST,GXor), OP(SRC,DST,GXxor),
180 OP(TMP,DST,GXequiv) }, /* 0x61 ~D^S^(P|(D&S)) */
181 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXor),
182 OP(SRC,DST,GXand), OP(TMP,DST,GXxor) }, /* 0x62 D^(S&(P|D)) */
183 { OP(PAT,DST,GXorInverted), OP(SRC,DST,GXxor) }, /* 0x63 S^(D|~P) */
184 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXor),
185 OP(SRC,DST,GXand), OP(TMP,DST,GXxor) }, /* 0x64 S^(D&(P|S)) */
186 { OP(PAT,SRC,GXorInverted), OP(SRC,DST,GXxor) }, /* 0x65 D^(S|~P) */
187 { OP(SRC,DST,GXxor) }, /* 0x66 S^D */
188 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXnor),
189 OP(SRC,DST,GXor), OP(TMP,DST,GXxor) }, /* 0x67 S^(D|~(S|P) */
190 { OP(DST,TMP,GXcopy), OP(SRC,DST,GXnor),
191 OP(PAT,DST,GXor), OP(SRC,DST,GXxor),
192 OP(TMP,DST,GXequiv) }, /* 0x68 ~D^S^(P|~(D|S))*/
193 { OP(SRC,DST,GXxor), OP(PAT,DST,GXequiv) }, /* 0x69 ~P^(D^S) */
194 { OP(PAT,SRC,GXand), OP(SRC,DST,GXxor) }, /* 0x6a D^(P&S) */
195 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXor),
196 OP(SRC,DST,GXand), OP(TMP,DST,GXxor),
197 OP(PAT,DST,GXequiv) }, /* 0x6b ~P^S^(D&(P|S)) */
198 { OP(PAT,DST,GXand), OP(SRC,DST,GXxor) }, /* 0x6c S^(D&P) */
199 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXor),
200 OP(SRC,DST,GXand), OP(TMP,DST,GXxor),
201 OP(PAT,DST,GXequiv) }, /* 0x6d ~P^D^(S&(P|D)) */
202 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXorReverse),
203 OP(SRC,DST,GXand), OP(TMP,DST,GXxor) }, /* 0x6e S^(D&(P|~S)) */
204 { OP(SRC,DST,GXequiv), OP(PAT,DST,GXnand) }, /* 0x6f ~(P&~(S^D)) */
205 { OP(SRC,DST,GXnand), OP(PAT,DST,GXand) }, /* 0x70 P&~(D&S) */
206 { OP(SRC,TMP,GXcopy), OP(DST,SRC,GXxor),
207 OP(PAT,DST,GXxor), OP(SRC,DST,GXand),
208 OP(TMP,DST,GXequiv) }, /* 0x71 ~S^((S^D)&(P^D))*/
209 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXxor),
210 OP(SRC,DST,GXor), OP(TMP,DST,GXxor) }, /* 0x72 S^(D|(P^S)) */
211 { OP(PAT,DST,GXorInverted), OP(SRC,DST,GXnand) },/* 0x73 ~(S&(D|~P)) */
212 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXxor),
213 OP(SRC,DST,GXor), OP(TMP,DST,GXxor) }, /* 0x74 D^(S|(P^D)) */
214 { OP(PAT,SRC,GXorInverted), OP(SRC,DST,GXnand) },/* 0x75 ~(D&(S|~P)) */
215 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXandReverse),
216 OP(SRC,DST,GXor), OP(TMP,DST,GXxor) }, /* 0x76 S^(D|(P&~S)) */
217 { OP(SRC,DST,GXnand) }, /* 0x77 ~(S&D) */
218 { OP(SRC,DST,GXand), OP(PAT,DST,GXxor) }, /* 0x78 P^(D&S) */
219 { OP(DST,TMP,GXcopy), OP(SRC,DST,GXor),
220 OP(PAT,DST,GXand), OP(SRC,DST,GXxor),
221 OP(TMP,DST,GXequiv) }, /* 0x79 ~D^S^(P&(D|S)) */
222 { OP(DST,SRC,GXorInverted), OP(PAT,SRC,GXand),
223 OP(SRC,DST,GXxor) }, /* 0x7a D^(P&(S|~D)) */
224 { OP(PAT,DST,GXequiv), OP(SRC,DST,GXnand) }, /* 0x7b ~(S&~(D^P)) */
225 { OP(SRC,DST,GXorInverted), OP(PAT,DST,GXand),
226 OP(SRC,DST,GXxor) }, /* 0x7c S^(P&(D|~S)) */
227 { OP(PAT,SRC,GXequiv), OP(SRC,DST,GXnand) }, /* 0x7d ~(D&~(P^S)) */
228 { OP(SRC,DST,GXxor), OP(PAT,SRC,GXxor),
229 OP(SRC,DST,GXor) }, /* 0x7e (S^P)|(S^D) */
230 { OP(PAT,SRC,GXand), OP(SRC,DST,GXnand) }, /* 0x7f ~(D&P&S) */
231 { OP(PAT,SRC,GXand), OP(SRC,DST,GXand) }, /* 0x80 D&P&S */
232 { OP(SRC,DST,GXxor), OP(PAT,SRC,GXxor),
233 OP(SRC,DST,GXnor) }, /* 0x81 ~((S^P)|(S^D)) */
234 { OP(PAT,SRC,GXequiv), OP(SRC,DST,GXand) }, /* 0x82 D&~(P^S) */
235 { OP(SRC,DST,GXorInverted), OP(PAT,DST,GXand),
236 OP(SRC,DST,GXequiv) }, /* 0x83 ~S^(P&(D|~S)) */
237 { OP(PAT,DST,GXequiv), OP(SRC,DST,GXand) }, /* 0x84 S&~(D^P) */
238 { OP(PAT,SRC,GXorInverted), OP(SRC,DST,GXand),
239 OP(PAT,DST,GXequiv) }, /* 0x85 ~P^(D&(S|~P)) */
240 { OP(DST,TMP,GXcopy), OP(SRC,DST,GXor),
241 OP(PAT,DST,GXand), OP(SRC,DST,GXxor),
242 OP(TMP,DST,GXxor) }, /* 0x86 D^S^(P&(D|S)) */
243 { OP(SRC,DST,GXand), OP(PAT,DST,GXequiv) }, /* 0x87 ~P^(D&S) */
244 { OP(SRC,DST,GXand) }, /* 0x88 S&D */
245 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXandReverse),
246 OP(SRC,DST,GXor), OP(TMP,DST,GXequiv) }, /* 0x89 ~S^(D|(P&~S)) */
247 { OP(PAT,SRC,GXorInverted), OP(SRC,DST,GXand) }, /* 0x8a D&(S|~P) */
248 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXxor),
249 OP(SRC,DST,GXor), OP(TMP,DST,GXequiv) }, /* 0x8b ~D^(S|(P^D)) */
250 { OP(PAT,DST,GXorInverted), OP(SRC,DST,GXand) }, /* 0x8c S&(D|~P) */
251 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXxor),
252 OP(SRC,DST,GXor), OP(TMP,DST,GXequiv) }, /* 0x8d ~S^(D|(P^S)) */
253 { OP(SRC,TMP,GXcopy), OP(DST,SRC,GXxor),
254 OP(PAT,DST,GXxor), OP(SRC,DST,GXand),
255 OP(TMP,DST,GXxor) }, /* 0x8e S^((S^D)&(P^D))*/
256 { OP(SRC,DST,GXnand), OP(PAT,DST,GXnand) }, /* 0x8f ~(P&~(D&S)) */
257 { OP(SRC,DST,GXequiv), OP(PAT,DST,GXand) }, /* 0x90 P&~(D^S) */
258 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXorReverse),
259 OP(SRC,DST,GXand), OP(TMP,DST,GXequiv) }, /* 0x91 ~S^(D&(P|~S)) */
260 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXor),
261 OP(SRC,DST,GXand), OP(PAT,DST,GXxor),
262 OP(TMP,DST,GXxor) }, /* 0x92 D^P^(S&(D|P)) */
263 { OP(PAT,DST,GXand), OP(SRC,DST,GXequiv) }, /* 0x93 ~S^(P&D) */
264 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXor),
265 OP(SRC,DST,GXand), OP(PAT,DST,GXxor),
266 OP(TMP,DST,GXxor) }, /* 0x94 S^P^(D&(P|S)) */
267 { OP(PAT,SRC,GXand), OP(SRC,DST,GXequiv) }, /* 0x95 ~D^(P&S) */
268 { OP(PAT,SRC,GXxor), OP(SRC,DST,GXxor) }, /* 0x96 D^P^S */
269 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXnor),
270 OP(SRC,DST,GXor), OP(PAT,DST,GXxor),
271 OP(TMP,DST,GXxor) }, /* 0x97 S^P^(D|~(P|S)) */
272 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXnor),
273 OP(SRC,DST,GXor), OP(TMP,DST,GXequiv) }, /* 0x98 ~S^(D|~(P|S)) */
274 { OP(SRC,DST,GXequiv) }, /* 0x99 ~S^D */
275 { OP(PAT,SRC,GXandReverse), OP(SRC,DST,GXxor) }, /* 0x9a D^(P&~S) */
276 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXor),
277 OP(SRC,DST,GXand), OP(TMP,DST,GXequiv) }, /* 0x9b ~S^(D&(P|S)) */
278 { OP(PAT,DST,GXandReverse), OP(SRC,DST,GXxor) }, /* 0x9c S^(P&~D) */
279 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXor),
280 OP(SRC,DST,GXand), OP(TMP,DST,GXequiv) }, /* 0x9d ~D^(S&(P|D)) */
281 { OP(DST,TMP,GXcopy), OP(SRC,DST,GXand),
282 OP(PAT,DST,GXor), OP(SRC,DST,GXxor),
283 OP(TMP,DST,GXxor) }, /* 0x9e D^S^(P|(D&S)) */
284 { OP(SRC,DST,GXxor), OP(PAT,DST,GXnand) }, /* 0x9f ~(P&(D^S)) */
285 { OP(PAT,DST,GXand) }, /* 0xa0 D&P */
286 { OP(PAT,SRC,GXandInverted), OP(SRC,DST,GXor),
287 OP(PAT,DST,GXequiv) }, /* 0xa1 ~P^(D|(S&~P)) */
288 { OP(PAT,SRC,GXorReverse), OP(SRC,DST,GXand) }, /* 0xa2 D&(P|~S) */
289 { OP(DST,SRC,GXxor), OP(PAT,SRC,GXor),
290 OP(SRC,DST,GXequiv) }, /* 0xa3 ~D^(P|(S^D)) */
291 { OP(PAT,SRC,GXnor), OP(SRC,DST,GXor),
292 OP(PAT,DST,GXequiv) }, /* 0xa4 ~P^(D|~(S|P)) */
293 { OP(PAT,DST,GXequiv) }, /* 0xa5 ~P^D */
294 { OP(PAT,SRC,GXandInverted), OP(SRC,DST,GXxor) },/* 0xa6 D^(S&~P) */
295 { OP(PAT,SRC,GXor), OP(SRC,DST,GXand),
296 OP(PAT,DST,GXequiv) }, /* 0xa7 ~P^(D&(S|P)) */
297 { OP(PAT,SRC,GXor), OP(SRC,DST,GXand) }, /* 0xa8 D&(P|S) */
298 { OP(PAT,SRC,GXor), OP(SRC,DST,GXequiv) }, /* 0xa9 ~D^(P|S) */
299 { OP(SRC,DST,GXnoop) }, /* 0xaa D */
300 { OP(PAT,SRC,GXnor), OP(SRC,DST,GXor) }, /* 0xab D|~(P|S) */
301 { OP(SRC,DST,GXxor), OP(PAT,DST,GXand),
302 OP(SRC,DST,GXxor) }, /* 0xac S^(P&(D^S)) */
303 { OP(DST,SRC,GXand), OP(PAT,SRC,GXor),
304 OP(SRC,DST,GXequiv) }, /* 0xad ~D^(P|(S&D)) */
305 { OP(PAT,SRC,GXandInverted), OP(SRC,DST,GXor) }, /* 0xae D|(S&~P) */
306 { OP(PAT,DST,GXorInverted) }, /* 0xaf D|~P */
307 { OP(SRC,DST,GXorInverted), OP(PAT,DST,GXand) }, /* 0xb0 P&(D|~S) */
308 { OP(PAT,SRC,GXxor), OP(SRC,DST,GXor),
309 OP(PAT,DST,GXequiv) }, /* 0xb1 ~P^(D|(S^P)) */
310 { OP(SRC,TMP,GXcopy), OP(SRC,DST,GXxor),
311 OP(PAT,SRC,GXxor), OP(SRC,DST,GXor),
312 OP(TMP,DST,GXxor) }, /* 0xb2 S^((S^P)|(S^D))*/
313 { OP(PAT,DST,GXnand), OP(SRC,DST,GXnand) }, /* 0xb3 ~(S&~(D&P)) */
314 { OP(SRC,DST,GXandReverse), OP(PAT,DST,GXxor) }, /* 0xb4 P^(S&~D) */
315 { OP(DST,SRC,GXor), OP(PAT,SRC,GXand),
316 OP(SRC,DST,GXequiv) }, /* 0xb5 ~D^(P&(S|D)) */
317 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXand),
318 OP(SRC,DST,GXor), OP(PAT,DST,GXxor),
319 OP(TMP,DST,GXxor) }, /* 0xb6 D^P^(S|(D&P)) */
320 { OP(PAT,DST,GXxor), OP(SRC,DST,GXnand) }, /* 0xb7 ~(S&(D^P)) */
321 { OP(PAT,DST,GXxor), OP(SRC,DST,GXand),
322 OP(PAT,DST,GXxor) }, /* 0xb8 P^(S&(D^P)) */
323 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXand),
324 OP(SRC,DST,GXor), OP(TMP,DST,GXequiv) }, /* 0xb9 ~D^(S|(P&D)) */
325 { OP(PAT,SRC,GXandReverse), OP(SRC,DST,GXor) }, /* 0xba D|(P&~S) */
326 { OP(SRC,DST,GXorInverted) }, /* 0xbb ~S|D */
327 { OP(SRC,DST,GXnand), OP(PAT,DST,GXand),
328 OP(SRC,DST,GXxor) }, /* 0xbc S^(P&~(D&S)) */
329 { OP(DST,SRC,GXxor), OP(PAT,DST,GXxor),
330 OP(SRC,DST,GXnand) }, /* 0xbd ~((S^D)&(P^D)) */
331 { OP(PAT,SRC,GXxor), OP(SRC,DST,GXor) }, /* 0xbe D|(P^S) */
332 { OP(PAT,SRC,GXnand), OP(SRC,DST,GXor) }, /* 0xbf D|~(P&S) */
333 { OP(PAT,SRC,GXand) }, /* 0xc0 P&S */
334 { OP(SRC,DST,GXandInverted), OP(PAT,DST,GXor),
335 OP(SRC,DST,GXequiv) }, /* 0xc1 ~S^(P|(D&~S)) */
336 { OP(SRC,DST,GXnor), OP(PAT,DST,GXor),
337 OP(SRC,DST,GXequiv) }, /* 0xc2 ~S^(P|~(D|S)) */
338 { OP(PAT,SRC,GXequiv) }, /* 0xc3 ~P^S */
339 { OP(PAT,DST,GXorReverse), OP(SRC,DST,GXand) }, /* 0xc4 S&(P|~D) */
340 { OP(SRC,DST,GXxor), OP(PAT,DST,GXor),
341 OP(SRC,DST,GXequiv) }, /* 0xc5 ~S^(P|(D^S)) */
342 { OP(PAT,DST,GXandInverted), OP(SRC,DST,GXxor) },/* 0xc6 S^(D&~P) */
343 { OP(PAT,DST,GXor), OP(SRC,DST,GXand),
344 OP(PAT,DST,GXequiv) }, /* 0xc7 ~P^(S&(D|P)) */
345 { OP(PAT,DST,GXor), OP(SRC,DST,GXand) }, /* 0xc8 S&(D|P) */
346 { OP(PAT,DST,GXor), OP(SRC,DST,GXequiv) }, /* 0xc9 ~S^(P|D) */
347 { OP(DST,SRC,GXxor), OP(PAT,SRC,GXand),
348 OP(SRC,DST,GXxor) }, /* 0xca D^(P&(S^D)) */
349 { OP(SRC,DST,GXand), OP(PAT,DST,GXor),
350 OP(SRC,DST,GXequiv) }, /* 0xcb ~S^(P|(D&S)) */
351 { OP(SRC,DST,GXcopy) }, /* 0xcc S */
352 { OP(PAT,DST,GXnor), OP(SRC,DST,GXor) }, /* 0xcd S|~(D|P) */
353 { OP(PAT,DST,GXandInverted), OP(SRC,DST,GXor) }, /* 0xce S|(D&~P) */
354 { OP(PAT,SRC,GXorInverted) }, /* 0xcf S|~P */
355 { OP(SRC,DST,GXorReverse), OP(PAT,DST,GXand) }, /* 0xd0 P&(S|~D) */
356 { OP(PAT,DST,GXxor), OP(SRC,DST,GXor),
357 OP(PAT,DST,GXequiv) }, /* 0xd1 ~P^(S|(D^P)) */
358 { OP(SRC,DST,GXandInverted), OP(PAT,DST,GXxor) },/* 0xd2 P^(D&~S) */
359 { OP(SRC,DST,GXor), OP(PAT,DST,GXand),
360 OP(SRC,DST,GXequiv) }, /* 0xd3 ~S^(P&(D|S)) */
361 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXxor),
362 OP(PAT,DST,GXxor), OP(SRC,DST,GXand),
363 OP(TMP,DST,GXxor) }, /* 0xd4 S^((S^P)&(D^P))*/
364 { OP(PAT,SRC,GXnand), OP(SRC,DST,GXnand) }, /* 0xd5 ~(D&~(P&S)) */
365 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXand),
366 OP(SRC,DST,GXor), OP(PAT,DST,GXxor),
367 OP(TMP,DST,GXxor) }, /* 0xd6 S^P^(D|(P&S)) */
368 { OP(PAT,SRC,GXxor), OP(SRC,DST,GXnand) }, /* 0xd7 ~(D&(P^S)) */
369 { OP(PAT,SRC,GXxor), OP(SRC,DST,GXand),
370 OP(PAT,DST,GXxor) }, /* 0xd8 P^(D&(S^P)) */
371 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXand),
372 OP(SRC,DST,GXor), OP(TMP,DST,GXequiv) }, /* 0xd9 ~S^(D|(P&S)) */
373 { OP(DST,SRC,GXnand), OP(PAT,SRC,GXand),
374 OP(SRC,DST,GXxor) }, /* 0xda D^(P&~(S&D)) */
375 { OP(SRC,DST,GXxor), OP(PAT,SRC,GXxor),
376 OP(SRC,DST,GXnand) }, /* 0xdb ~((S^P)&(S^D)) */
377 { OP(PAT,DST,GXandReverse), OP(SRC,DST,GXor) }, /* 0xdc S|(P&~D) */
378 { OP(SRC,DST,GXorReverse) }, /* 0xdd S|~D */
379 { OP(PAT,DST,GXxor), OP(SRC,DST,GXor) }, /* 0xde S|(D^P) */
380 { OP(PAT,DST,GXnand), OP(SRC,DST,GXor) }, /* 0xdf S|~(D&P) */
381 { OP(SRC,DST,GXor), OP(PAT,DST,GXand) }, /* 0xe0 P&(D|S) */
382 { OP(SRC,DST,GXor), OP(PAT,DST,GXequiv) }, /* 0xe1 ~P^(D|S) */
383 { OP(DST,TMP,GXcopy), OP(PAT,DST,GXxor),
384 OP(SRC,DST,GXand), OP(TMP,DST,GXxor) }, /* 0xe2 D^(S&(P^D)) */
385 { OP(PAT,DST,GXand), OP(SRC,DST,GXor),
386 OP(PAT,DST,GXequiv) }, /* 0xe3 ~P^(S|(D&P)) */
387 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXxor),
388 OP(SRC,DST,GXand), OP(TMP,DST,GXxor) }, /* 0xe4 S^(D&(P^S)) */
389 { OP(PAT,SRC,GXand), OP(SRC,DST,GXor),
390 OP(PAT,DST,GXequiv) }, /* 0xe5 ~P^(D|(S&P)) */
391 { OP(SRC,TMP,GXcopy), OP(PAT,SRC,GXnand),
392 OP(SRC,DST,GXand), OP(TMP,DST,GXxor) }, /* 0xe6 S^(D&~(P&S)) */
393 { OP(PAT,SRC,GXxor), OP(PAT,DST,GXxor),
394 OP(SRC,DST,GXnand) }, /* 0xe7 ~((S^P)&(D^P)) */
395 { OP(SRC,TMP,GXcopy), OP(SRC,DST,GXxor),
396 OP(PAT,SRC,GXxor), OP(SRC,DST,GXand),
397 OP(TMP,DST,GXxor) }, /* 0xe8 S^((S^P)&(S^D))*/
398 { OP(DST,TMP,GXcopy), OP(SRC,DST,GXnand),
399 OP(PAT,DST,GXand), OP(SRC,DST,GXxor),
400 OP(TMP,DST,GXequiv) }, /* 0xe9 ~D^S^(P&~(S&D))*/
401 { OP(PAT,SRC,GXand), OP(SRC,DST,GXor) }, /* 0xea D|(P&S) */
402 { OP(PAT,SRC,GXequiv), OP(SRC,DST,GXor) }, /* 0xeb D|~(P^S) */
403 { OP(PAT,DST,GXand), OP(SRC,DST,GXor) }, /* 0xec S|(D&P) */
404 { OP(PAT,DST,GXequiv), OP(SRC,DST,GXor) }, /* 0xed S|~(D^P) */
405 { OP(SRC,DST,GXor) }, /* 0xee S|D */
406 { OP(PAT,DST,GXorInverted), OP(SRC,DST,GXor) }, /* 0xef S|D|~P */
407 { OP(PAT,DST,GXcopy) }, /* 0xf0 P */
408 { OP(SRC,DST,GXnor), OP(PAT,DST,GXor) }, /* 0xf1 P|~(D|S) */
409 { OP(SRC,DST,GXandInverted), OP(PAT,DST,GXor) }, /* 0xf2 P|(D&~S) */
410 { OP(PAT,SRC,GXorReverse) }, /* 0xf3 P|~S */
411 { OP(SRC,DST,GXandReverse), OP(PAT,DST,GXor) }, /* 0xf4 P|(S&~D) */
412 { OP(PAT,DST,GXorReverse) }, /* 0xf5 P|~D */
413 { OP(SRC,DST,GXxor), OP(PAT,DST,GXor) }, /* 0xf6 P|(D^S) */
414 { OP(SRC,DST,GXnand), OP(PAT,DST,GXor) }, /* 0xf7 P|~(S&D) */
415 { OP(SRC,DST,GXand), OP(PAT,DST,GXor) }, /* 0xf8 P|(D&S) */
416 { OP(SRC,DST,GXequiv), OP(PAT,DST,GXor) }, /* 0xf9 P|~(D^S) */
417 { OP(PAT,DST,GXor) }, /* 0xfa D|P */
418 { OP(PAT,SRC,GXorReverse), OP(SRC,DST,GXor) }, /* 0xfb D|P|~S */
419 { OP(PAT,SRC,GXor) }, /* 0xfc P|S */
420 { OP(SRC,DST,GXorReverse), OP(PAT,DST,GXor) }, /* 0xfd P|S|~D */
421 { OP(SRC,DST,GXor), OP(PAT,DST,GXor) }, /* 0xfe P|D|S */
422 { OP(PAT,DST,GXset) } /* 0xff 1 */
426 #ifdef BITBLT_TEST /* Opcodes test */
428 static int do_bitop( int s, int d, int rop )
430 int res;
431 switch(rop)
433 case GXclear: res = 0; break;
434 case GXand: res = s & d; break;
435 case GXandReverse: res = s & ~d; break;
436 case GXcopy: res = s; break;
437 case GXandInverted: res = ~s & d; break;
438 case GXnoop: res = d; break;
439 case GXxor: res = s ^ d; break;
440 case GXor: res = s | d; break;
441 case GXnor: res = ~(s | d); break;
442 case GXequiv: res = ~s ^ d; break;
443 case GXinvert: res = ~d; break;
444 case GXorReverse: res = s | ~d; break;
445 case GXcopyInverted: res = ~s; break;
446 case GXorInverted: res = ~s | d; break;
447 case GXnand: res = ~(s & d); break;
448 case GXset: res = 1; break;
450 return res & 1;
453 main()
455 int rop, i, res, src, dst, pat, tmp, dstUsed;
456 const BYTE *opcode;
458 for (rop = 0; rop < 256; rop++)
460 res = dstUsed = 0;
461 for (i = 0; i < 8; i++)
463 pat = (i >> 2) & 1;
464 src = (i >> 1) & 1;
465 dst = i & 1;
466 for (opcode = BITBLT_Opcodes[rop]; *opcode; opcode++)
468 switch(*opcode >> 4)
470 case OP_ARGS(DST,TMP):
471 tmp = do_bitop( dst, tmp, *opcode & 0xf );
472 break;
473 case OP_ARGS(DST,SRC):
474 src = do_bitop( dst, src, *opcode & 0xf );
475 break;
476 case OP_ARGS(SRC,TMP):
477 tmp = do_bitop( src, tmp, *opcode & 0xf );
478 break;
479 case OP_ARGS(SRC,DST):
480 dst = do_bitop( src, dst, *opcode & 0xf );
481 dstUsed = 1;
482 break;
483 case OP_ARGS(PAT,TMP):
484 tmp = do_bitop( pat, tmp, *opcode & 0xf );
485 break;
486 case OP_ARGS(PAT,DST):
487 dst = do_bitop( pat, dst, *opcode & 0xf );
488 dstUsed = 1;
489 break;
490 case OP_ARGS(PAT,SRC):
491 src = do_bitop( pat, src, *opcode & 0xf );
492 break;
493 case OP_ARGS(TMP,DST):
494 dst = do_bitop( tmp, dst, *opcode & 0xf );
495 dstUsed = 1;
496 break;
497 case OP_ARGS(TMP,SRC):
498 src = do_bitop( tmp, src, *opcode & 0xf );
499 break;
500 default:
501 printf( "Invalid opcode %x\n", *opcode );
504 if (!dstUsed) dst = src;
505 if (dst) res |= 1 << i;
507 if (res != rop) printf( "%02x: ERROR, res=%02x\n", rop, res );
511 #endif /* BITBLT_TEST */
514 /***********************************************************************
515 * BITBLT_StretchRow
517 * Stretch a row of pixels. Helper function for BITBLT_StretchImage.
519 static void BITBLT_StretchRow( int *rowSrc, int *rowDst,
520 short startDst, short widthDst,
521 int xinc, WORD mode )
523 register int xsrc = xinc * startDst;
524 rowDst += startDst;
525 switch(mode)
527 case STRETCH_ANDSCANS:
528 for(; widthDst > 0; widthDst--, xsrc += xinc)
529 *rowDst++ &= rowSrc[xsrc >> 16];
530 break;
531 case STRETCH_ORSCANS:
532 for(; widthDst > 0; widthDst--, xsrc += xinc)
533 *rowDst++ |= rowSrc[xsrc >> 16];
534 break;
535 case STRETCH_DELETESCANS:
536 for(; widthDst > 0; widthDst--, xsrc += xinc)
537 *rowDst++ = rowSrc[xsrc >> 16];
538 break;
543 /***********************************************************************
544 * BITBLT_ShrinkRow
546 * Shrink a row of pixels. Helper function for BITBLT_StretchImage.
548 static void BITBLT_ShrinkRow( int *rowSrc, int *rowDst,
549 short startSrc, short widthSrc,
550 int xinc, WORD mode )
552 register int xdst = xinc * startSrc;
553 rowSrc += startSrc;
554 switch(mode)
556 case STRETCH_ORSCANS:
557 for(; widthSrc > 0; widthSrc--, xdst += xinc)
558 rowDst[xdst >> 16] |= *rowSrc++;
559 break;
560 case STRETCH_ANDSCANS:
561 for(; widthSrc > 0; widthSrc--, xdst += xinc)
562 rowDst[xdst >> 16] &= *rowSrc++;
563 break;
564 case STRETCH_DELETESCANS:
565 for(; widthSrc > 0; widthSrc--, xdst += xinc)
566 rowDst[xdst >> 16] = *rowSrc++;
567 break;
572 /***********************************************************************
573 * BITBLT_GetRow
575 * Retrieve a row from an image. Helper function for BITBLT_StretchImage.
577 static void BITBLT_GetRow( XImage *image, int *pdata, short row,
578 short start, short width, short depthDst,
579 int fg, int bg, BOOL swap)
581 register short i;
583 pdata += swap ? start+width-1 : start;
584 if (image->depth == depthDst)
586 if (COLOR_PixelToPalette && (depthDst != 1))
587 if (swap) for (i = 0; i < width; i++)
588 *pdata-- = COLOR_PixelToPalette[XGetPixel( image, i, row )];
589 else for (i = 0; i < width; i++)
590 *pdata++ = COLOR_PixelToPalette[XGetPixel( image, i, row )];
591 else
592 if (swap) for (i = 0; i < width; i++)
593 *pdata-- = XGetPixel( image, i, row );
594 else for (i = 0; i < width; i++)
595 *pdata++ = XGetPixel( image, i, row );
597 else
599 if (image->depth == 1)
600 if (swap) for (i = 0; i < width; i++)
601 *pdata-- = XGetPixel( image, i, row ) ? bg : fg;
602 else for (i = 0; i < width; i++)
603 *pdata++ = XGetPixel( image, i, row ) ? bg : fg;
604 else
605 if (swap) for (i = 0; i < width; i++)
606 *pdata-- = (XGetPixel( image, i, row ) == bg) ? 1 : 0;
607 else for (i = 0; i < width; i++)
608 *pdata++ = (XGetPixel( image, i, row ) == bg) ? 1 : 0;
613 /***********************************************************************
614 * BITBLT_StretchImage
616 * Stretch an X image.
618 static void BITBLT_StretchImage( XImage *srcImage, XImage *dstImage,
619 short widthSrc, short heightSrc,
620 short widthDst, short heightDst,
621 RECT *visRectSrc, RECT *visRectDst,
622 int foreground, int background, WORD mode )
624 int *rowSrc, *rowDst, *pixel;
625 int xinc, yinc, ysrc, ydst;
626 register short x, y;
627 BOOL hstretch, vstretch, hswap, vswap;
629 hswap = ((int)widthSrc * widthDst) < 0;
630 vswap = ((int)heightSrc * heightDst) < 0;
631 widthSrc = abs(widthSrc);
632 heightSrc = abs(heightSrc);
633 widthDst = abs(widthDst);
634 heightDst = abs(heightDst);
636 dprintf_bitblt( stddeb, "BITBLT_StretchImage: %dx%d -> %dx%d (mode=%d,h=%d,v=%d)\n",
637 widthSrc, heightSrc, widthDst, heightDst, mode, hswap, vswap );
639 if (!(rowSrc = (int *)malloc( (widthSrc+widthDst)*sizeof(int) ))) return;
640 rowDst = rowSrc + widthSrc;
642 /* When stretching, all modes are the same, and DELETESCANS is faster */
643 if ((widthSrc < widthDst) && (heightSrc < heightDst))
644 mode = STRETCH_DELETESCANS;
646 if (mode != STRETCH_DELETESCANS)
647 memset( rowDst, (mode == STRETCH_ANDSCANS) ? 0xff : 0x00,
648 widthDst*sizeof(int) );
650 hstretch = ((widthSrc < widthDst) || (mode == STRETCH_DELETESCANS));
651 vstretch = ((heightSrc < heightDst) || (mode == STRETCH_DELETESCANS));
652 xinc = hstretch ? ((int)widthSrc << 16) / widthDst :
653 ((int)widthDst << 16) / widthSrc;
655 if (vstretch)
657 yinc = ((int)heightSrc << 16) / heightDst;
658 ydst = visRectDst->top;
659 ysrc = yinc * ydst;
661 else
663 yinc = ((int)heightDst << 16) / heightSrc;
664 ysrc = visRectSrc->top;
665 ydst = yinc * ysrc;
668 while(vstretch ? (ydst < visRectDst->bottom) : (ysrc < visRectSrc->bottom))
670 /* Retrieve a source row */
671 BITBLT_GetRow( srcImage, rowSrc, vstretch ? ysrc >> 16 : ysrc,
672 visRectSrc->left, visRectSrc->right - visRectSrc->left,
673 dstImage->depth, foreground, background, hswap );
675 /* Stretch or shrink it */
676 if (hstretch)
677 BITBLT_StretchRow( rowSrc, rowDst, visRectDst->left,
678 visRectDst->right-visRectDst->left, xinc, mode);
679 else BITBLT_ShrinkRow( rowSrc, rowDst, visRectSrc->left,
680 visRectSrc->right-visRectSrc->left, xinc, mode);
682 /* When shrinking, merge several source rows into the destination */
683 if (!vstretch)
685 if (mode == STRETCH_DELETESCANS)
687 /* Simply skip the overlapping rows */
688 while (((ydst + yinc) >> 16 == ydst >> 16) &&
689 (ysrc < visRectSrc->bottom-1))
691 ydst += yinc;
692 ysrc++;
695 else if (((ydst + yinc) >> 16 == ydst >> 16) &&
696 (ysrc < visRectSrc->bottom-1))
698 ydst += yinc;
699 ysrc++;
700 continue; /* Restart loop for next overlapping row */
704 /* Store the destination row */
706 pixel = rowDst + visRectDst->right - 1;
707 if (vswap)
708 y = visRectDst->bottom - (vstretch ? ydst : ydst >> 16);
709 else
710 y = (vstretch ? ydst : ydst >> 16) - visRectDst->top;
711 for (x = visRectDst->right-visRectDst->left-1; x >= 0; x--)
712 XPutPixel( dstImage, x, y, *pixel-- );
713 if (mode != STRETCH_DELETESCANS)
714 memset( rowDst, (mode == STRETCH_ANDSCANS) ? 0xff : 0x00,
715 widthDst*sizeof(int) );
717 /* If stretching, make copies of the destination row */
719 if (vstretch)
721 char *pdata = dstImage->data + dstImage->bytes_per_line * y;
722 while (((ysrc + yinc) >> 16 == ysrc >> 16) &&
723 (ydst < visRectDst->bottom-1))
725 if (vswap)
727 memcpy( pdata - dstImage->bytes_per_line, pdata,
728 dstImage->bytes_per_line );
729 pdata -= dstImage->bytes_per_line;
731 else
733 memcpy( pdata + dstImage->bytes_per_line, pdata,
734 dstImage->bytes_per_line );
735 pdata += dstImage->bytes_per_line;
737 ysrc += yinc;
738 ydst++;
740 ysrc += yinc;
741 ydst++;
743 else
745 ydst += yinc;
746 ysrc++;
750 free( rowSrc );
754 /***********************************************************************
755 * BITBLT_GetSrcAreaStretch
757 * Retrieve an area from the source DC, stretching and mapping all the
758 * pixels to Windows colors.
760 static void BITBLT_GetSrcAreaStretch( DC *dcSrc, DC *dcDst,
761 Pixmap pixmap, GC gc,
762 short xSrc, short ySrc,
763 short widthSrc, short heightSrc,
764 short xDst, short yDst,
765 short widthDst, short heightDst,
766 RECT *visRectSrc, RECT *visRectDst )
768 XImage *imageSrc, *imageDst;
770 RECT rectSrc = *visRectSrc;
771 RECT rectDst = *visRectDst;
772 OffsetRect( &rectSrc, -xSrc, -ySrc );
773 OffsetRect( &rectDst, -xDst, -yDst );
774 imageSrc = XGetImage( display, dcSrc->u.x.drawable,
775 visRectSrc->left, visRectSrc->top,
776 visRectSrc->right - visRectSrc->left,
777 visRectSrc->bottom - visRectSrc->top,
778 AllPlanes, ZPixmap );
779 XCREATEIMAGE( imageDst, rectDst.right - rectDst.left,
780 rectDst.bottom - rectDst.top, dcDst->w.bitsPerPixel );
781 BITBLT_StretchImage( imageSrc, imageDst, widthSrc, heightSrc,
782 widthDst, heightDst, &rectSrc, &rectDst,
783 dcDst->w.textPixel, dcDst->w.bitsPerPixel != 1 ?
784 dcDst->w.backgroundPixel : dcSrc->w.backgroundPixel,
785 dcDst->w.stretchBltMode );
786 XPutImage( display, pixmap, gc, imageDst, 0, 0, 0, 0,
787 rectDst.right - rectDst.left, rectDst.bottom - rectDst.top );
788 XDestroyImage( imageSrc );
789 XDestroyImage( imageDst );
793 /***********************************************************************
794 * BITBLT_GetSrcArea
796 * Retrieve an area from the source DC, mapping all the
797 * pixels to Windows colors.
799 static void BITBLT_GetSrcArea( DC *dcSrc, DC *dcDst, Pixmap pixmap, GC gc,
800 short xSrc, short ySrc,
801 RECT *visRectSrc )
803 XImage *imageSrc, *imageDst;
804 register short x, y;
805 short width = visRectSrc->right - visRectSrc->left;
806 short height = visRectSrc->bottom - visRectSrc->top;
808 if (dcSrc->w.bitsPerPixel == dcDst->w.bitsPerPixel)
810 if (!COLOR_PixelToPalette ||
811 (dcDst->w.bitsPerPixel == 1)) /* monochrome -> monochrome */
813 XCopyArea( display, dcSrc->u.x.drawable, pixmap, gc,
814 visRectSrc->left, visRectSrc->top, width, height, 0, 0);
816 else /* color -> color */
818 imageSrc = XGetImage( display, dcSrc->u.x.drawable,
819 visRectSrc->left, visRectSrc->top,
820 width, height, AllPlanes, ZPixmap );
821 for (y = 0; y < height; y++)
822 for (x = 0; x < width; x++)
823 XPutPixel(imageSrc, x, y,
824 COLOR_PixelToPalette[XGetPixel(imageSrc, x, y)]);
825 XPutImage( display, pixmap, gc, imageSrc,
826 0, 0, 0, 0, width, height );
827 XDestroyImage( imageSrc );
830 else
832 if (dcSrc->w.bitsPerPixel == 1) /* monochrome -> color */
834 if (COLOR_PixelToPalette)
836 XSetBackground( display, gc,
837 COLOR_PixelToPalette[dcDst->w.textPixel] );
838 XSetForeground( display, gc,
839 COLOR_PixelToPalette[dcDst->w.backgroundPixel]);
841 else
843 XSetBackground( display, gc, dcDst->w.textPixel );
844 XSetForeground( display, gc, dcDst->w.backgroundPixel );
846 XCopyPlane( display, dcSrc->u.x.drawable, pixmap, gc,
847 visRectSrc->left, visRectSrc->top,
848 width, height, 0, 0, 1 );
850 else /* color -> monochrome */
852 imageSrc = XGetImage( display, dcSrc->u.x.drawable,
853 visRectSrc->left, visRectSrc->top,
854 width, height, AllPlanes, ZPixmap );
855 XCREATEIMAGE( imageDst, width, height, dcDst->w.bitsPerPixel );
856 for (y = 0; y < height; y++)
857 for (x = 0; x < width; x++)
858 XPutPixel(imageDst, x, y, (XGetPixel(imageSrc,x,y) ==
859 dcSrc->w.backgroundPixel) );
860 XPutImage( display, pixmap, gc, imageDst,
861 0, 0, 0, 0, width, height );
862 XDestroyImage( imageSrc );
863 XDestroyImage( imageDst );
869 /***********************************************************************
870 * BITBLT_GetDstArea
872 * Retrieve an area from the destination DC, mapping all the
873 * pixels to Windows colors.
875 static void BITBLT_GetDstArea( DC *dc, Pixmap pixmap, GC gc, RECT *visRectDst )
877 short width = visRectDst->right - visRectDst->left;
878 short height = visRectDst->bottom - visRectDst->top;
880 if (!COLOR_PixelToPalette || (dc->w.bitsPerPixel == 1))
882 XCopyArea( display, dc->u.x.drawable, pixmap, gc,
883 visRectDst->left, visRectDst->top, width, height, 0, 0 );
885 else
887 register short x, y;
888 XImage *image = XGetImage( display, dc->u.x.drawable,
889 visRectDst->left, visRectDst->top,
890 width, height, AllPlanes, ZPixmap );
891 for (y = 0; y < height; y++)
892 for (x = 0; x < width; x++)
893 XPutPixel( image, x, y,
894 COLOR_PixelToPalette[XGetPixel( image, x, y )]);
895 XPutImage( display, pixmap, gc, image, 0, 0, 0, 0, width, height );
900 /***********************************************************************
901 * BITBLT_PutDstArea
903 * Put an area back into the destination DC, mapping the pixel
904 * colors to X pixels.
906 static void BITBLT_PutDstArea( DC *dc, Pixmap pixmap, GC gc, RECT *visRectDst )
908 short width = visRectDst->right - visRectDst->left;
909 short height = visRectDst->bottom - visRectDst->top;
911 if (!COLOR_PaletteToPixel)
913 XCopyArea( display, pixmap, dc->u.x.drawable, gc, 0, 0,
914 width, height, visRectDst->left, visRectDst->top );
916 else
918 register short x, y;
919 XImage *image = XGetImage( display, pixmap, 0, 0, width, height,
920 AllPlanes, ZPixmap );
921 for (y = 0; y < height; y++)
922 for (x = 0; x < width; x++)
924 XPutPixel( image, x, y,
925 COLOR_PaletteToPixel[XGetPixel( image, x, y )]);
927 XPutImage( display, dc->u.x.drawable, gc, image, 0, 0,
928 visRectDst->left, visRectDst->top, width, height );
929 XDestroyImage( image );
934 /***********************************************************************
935 * BITBLT_GetVisRectangles
937 * Get the source and destination visible rectangles for StretchBlt().
938 * Return FALSE if one of the rectangles is empty.
940 static BOOL BITBLT_GetVisRectangles( DC *dcDst, short xDst, short yDst,
941 short widthDst, short heightDst,
942 DC *dcSrc, short xSrc, short ySrc,
943 short widthSrc, short heightSrc,
944 RECT *visRectSrc, RECT *visRectDst )
946 RECT tmpRect, clipRect;
948 if (widthSrc < 0) { widthSrc = -widthSrc; xSrc -= widthSrc; }
949 if (widthDst < 0) { widthDst = -widthDst; xDst -= widthDst; }
950 if (heightSrc < 0) { heightSrc = -heightSrc; ySrc -= heightSrc; }
951 if (heightDst < 0) { heightDst = -heightDst; yDst -= heightDst; }
953 /* Get the destination visible rectangle */
955 SetRect( &tmpRect, xDst, yDst, xDst + widthDst, yDst + heightDst );
956 GetRgnBox( dcDst->w.hGCClipRgn, &clipRect );
957 OffsetRect( &clipRect, dcDst->w.DCOrgX, dcDst->w.DCOrgY );
958 if (!IntersectRect( visRectDst, &tmpRect, &clipRect )) return FALSE;
960 /* Get the source visible rectangle */
962 if (!dcSrc) return TRUE;
963 SetRect( &tmpRect, xSrc, ySrc, xSrc + widthSrc, ySrc + heightSrc );
964 GetRgnBox( dcSrc->w.hGCClipRgn, &clipRect );
965 OffsetRect( &clipRect, dcSrc->w.DCOrgX, dcSrc->w.DCOrgY );
966 if (!IntersectRect( visRectSrc, &tmpRect, &clipRect )) return FALSE;
968 /* Intersect the rectangles */
970 if ((widthSrc == widthDst) && (heightSrc == heightDst)) /* no stretching */
972 OffsetRect( visRectSrc, xDst - xSrc, yDst - ySrc );
973 if (!IntersectRect( &tmpRect, visRectSrc, visRectDst )) return FALSE;
974 *visRectSrc = *visRectDst = tmpRect;
975 OffsetRect( visRectSrc, xSrc - xDst, ySrc - yDst );
977 else /* stretching */
979 visRectSrc->left = xDst + (visRectSrc->left-xSrc)*widthDst/widthSrc;
980 visRectSrc->top = yDst + (visRectSrc->top-ySrc)*heightDst/heightSrc;
981 visRectSrc->right = xDst +
982 ((visRectSrc->right-xSrc) * widthDst + widthSrc-1) / widthSrc;
983 visRectSrc->bottom = yDst +
984 ((visRectSrc->bottom-ySrc) * heightDst + heightSrc-1) / heightSrc;
985 if (!IntersectRect( &tmpRect, visRectSrc, visRectDst )) return FALSE;
986 *visRectSrc = *visRectDst = tmpRect;
987 visRectSrc->left = xSrc + (visRectSrc->left-xDst)*widthSrc/widthDst;
988 visRectSrc->top = ySrc + (visRectSrc->top-yDst)*heightSrc/heightDst;
989 visRectSrc->right = xSrc +
990 ((visRectSrc->right-xDst) * widthSrc + widthDst-1) / widthDst;
991 visRectSrc->bottom = ySrc +
992 ((visRectSrc->bottom-yDst) * heightSrc + heightDst-1) / heightDst;
993 if (IsRectEmpty( visRectSrc )) return FALSE;
995 return TRUE;
999 /***********************************************************************
1000 * BITBLT_InternalStretchBlt
1002 * Implementation of PatBlt(), BitBlt() and StretchBlt().
1004 BOOL BITBLT_InternalStretchBlt( DC *dcDst, short xDst, short yDst,
1005 short widthDst, short heightDst,
1006 DC *dcSrc, short xSrc, short ySrc,
1007 short widthSrc, short heightSrc, DWORD rop )
1009 BOOL usePat, useSrc, useDst, destUsed, fStretch, fNullBrush;
1010 RECT visRectDst, visRectSrc;
1011 short width, height;
1012 const BYTE *opcode;
1013 Pixmap pixmaps[3] = { 0, 0, 0 }; /* pixmaps for DST, SRC, TMP */
1014 GC tmpGC = 0;
1016 usePat = (((rop >> 4) & 0x0f0000) != (rop & 0x0f0000));
1017 useSrc = (((rop >> 2) & 0x330000) != (rop & 0x330000));
1018 useDst = (((rop >> 1) & 0x550000) != (rop & 0x550000));
1019 if (!dcSrc && useSrc) return FALSE;
1021 /* Map the coordinates to device coords */
1023 xDst = dcDst->w.DCOrgX + XLPTODP( dcDst, xDst );
1024 yDst = dcDst->w.DCOrgY + YLPTODP( dcDst, yDst );
1025 widthDst = widthDst * dcDst->w.VportExtX / dcDst->w.WndExtX;
1026 heightDst = heightDst * dcDst->w.VportExtY / dcDst->w.WndExtY;
1027 if (useSrc)
1029 xSrc = dcSrc->w.DCOrgX + XLPTODP( dcSrc, xSrc );
1030 ySrc = dcSrc->w.DCOrgY + YLPTODP( dcSrc, ySrc );
1031 widthSrc = widthSrc * dcSrc->w.VportExtX / dcSrc->w.WndExtX;
1032 heightSrc = heightSrc * dcSrc->w.VportExtY / dcSrc->w.WndExtY;
1033 fStretch = (widthSrc != widthDst) || (heightSrc != heightDst);
1034 if (!BITBLT_GetVisRectangles( dcDst, xDst, yDst, widthDst, heightDst,
1035 dcSrc, xSrc, ySrc, widthSrc, heightSrc,
1036 &visRectSrc, &visRectDst ))
1037 return TRUE;
1039 else
1041 fStretch = FALSE;
1042 if (!BITBLT_GetVisRectangles( dcDst, xDst, yDst, widthDst, heightDst,
1043 NULL, 0, 0, 0, 0, NULL, &visRectDst ))
1044 return TRUE;
1047 width = visRectDst.right - visRectDst.left;
1048 height = visRectDst.bottom - visRectDst.top;
1050 if (!fStretch) switch(rop) /* A few optimisations */
1052 case BLACKNESS: /* 0x00 */
1053 if ((dcDst->w.bitsPerPixel == 1) || !COLOR_PaletteToPixel)
1054 XSetFunction( display, dcDst->u.x.gc, GXclear );
1055 else
1057 XSetFunction( display, dcDst->u.x.gc, GXcopy );
1058 XSetForeground( display, dcDst->u.x.gc, COLOR_PaletteToPixel[0] );
1059 XSetFillStyle( display, dcDst->u.x.gc, FillSolid );
1061 XFillRectangle( display, dcDst->u.x.drawable, dcDst->u.x.gc,
1062 visRectDst.left, visRectDst.top, width, height );
1063 return TRUE;
1065 case PATINVERT: /* 0x5a */
1066 /* FIXME: This is not really correct, but for now PATINVERT is */
1067 /* used to draw the window moving frame, so it has to be fast. */
1068 if (!DC_SetupGCForBrush( dcDst )) return TRUE;
1069 XSetFunction( display, dcDst->u.x.gc, GXxor );
1070 XFillRectangle( display, dcDst->u.x.drawable, dcDst->u.x.gc,
1071 visRectDst.left, visRectDst.top, width, height );
1072 return TRUE;
1074 case SRCCOPY: /* 0xcc */
1075 if (dcSrc->w.bitsPerPixel == dcDst->w.bitsPerPixel)
1077 XSetFunction( display, dcDst->u.x.gc, GXcopy );
1078 XCopyArea( display, dcSrc->u.x.drawable,
1079 dcDst->u.x.drawable, dcDst->u.x.gc,
1080 visRectSrc.left, visRectSrc.top,
1081 width, height, visRectDst.left, visRectDst.top );
1082 return TRUE;
1084 if (dcSrc->w.bitsPerPixel == 1)
1086 XSetBackground( display, dcDst->u.x.gc, dcDst->w.textPixel );
1087 XSetForeground( display, dcDst->u.x.gc, dcDst->w.backgroundPixel );
1088 XSetFunction( display, dcDst->u.x.gc, GXcopy );
1089 XCopyPlane( display, dcSrc->u.x.drawable,
1090 dcDst->u.x.drawable, dcDst->u.x.gc,
1091 visRectSrc.left, visRectSrc.top,
1092 width, height, visRectDst.left, visRectDst.top, 1 );
1093 return TRUE;
1095 break;
1097 case PATCOPY: /* 0xf0 */
1098 if (!DC_SetupGCForBrush( dcDst )) return TRUE;
1099 XSetFunction( display, dcDst->u.x.gc, GXcopy );
1100 XFillRectangle( display, dcDst->u.x.drawable, dcDst->u.x.gc,
1101 visRectDst.left, visRectDst.top, width, height );
1102 return TRUE;
1104 case WHITENESS: /* 0xff */
1105 if ((dcDst->w.bitsPerPixel == 1) || !COLOR_PaletteToPixel)
1106 XSetFunction( display, dcDst->u.x.gc, GXset );
1107 else
1109 XSetFunction( display, dcDst->u.x.gc, GXcopy );
1110 XSetForeground( display, dcDst->u.x.gc,
1111 COLOR_PaletteToPixel[COLOR_ColormapSize-1] );
1112 XSetFillStyle( display, dcDst->u.x.gc, FillSolid );
1114 XFillRectangle( display, dcDst->u.x.drawable, dcDst->u.x.gc,
1115 visRectDst.left, visRectDst.top, width, height );
1116 return TRUE;
1119 tmpGC = XCreateGC( display, dcDst->u.x.drawable, 0, NULL );
1120 pixmaps[DST] = XCreatePixmap( display, rootWindow, width, height,
1121 dcDst->w.bitsPerPixel );
1122 if (useSrc)
1124 pixmaps[SRC] = XCreatePixmap( display, rootWindow, width, height,
1125 dcDst->w.bitsPerPixel );
1126 if (fStretch)
1127 BITBLT_GetSrcAreaStretch( dcSrc, dcDst, pixmaps[SRC], tmpGC,
1128 xSrc, ySrc, widthSrc, heightSrc,
1129 xDst, yDst, widthDst, heightDst,
1130 &visRectSrc, &visRectDst );
1131 else
1132 BITBLT_GetSrcArea( dcSrc, dcDst, pixmaps[SRC], tmpGC,
1133 xSrc, ySrc, &visRectSrc );
1135 if (useDst) BITBLT_GetDstArea( dcDst, pixmaps[DST], tmpGC, &visRectDst );
1136 if (usePat) fNullBrush = !DC_SetupGCForPatBlt( dcDst, tmpGC, TRUE );
1137 else fNullBrush = FALSE;
1138 destUsed = FALSE;
1140 for (opcode = BITBLT_Opcodes[(rop >> 16) & 0xff]; *opcode; opcode++)
1142 if (OP_DST(*opcode) == DST) destUsed = TRUE;
1143 XSetFunction( display, tmpGC, OP_ROP(*opcode) );
1144 switch(OP_SRCDST(*opcode))
1146 case OP_ARGS(DST,TMP):
1147 case OP_ARGS(SRC,TMP):
1148 if (!pixmaps[TMP])
1149 pixmaps[TMP] = XCreatePixmap( display, rootWindow,
1150 width, height,
1151 dcDst->w.bitsPerPixel );
1152 /* fall through */
1153 case OP_ARGS(DST,SRC):
1154 case OP_ARGS(SRC,DST):
1155 case OP_ARGS(TMP,SRC):
1156 case OP_ARGS(TMP,DST):
1157 XCopyArea( display, pixmaps[OP_SRC(*opcode)],
1158 pixmaps[OP_DST(*opcode)], tmpGC,
1159 0, 0, width, height, 0, 0 );
1160 break;
1162 case OP_ARGS(PAT,TMP):
1163 if (!pixmaps[TMP] && !fNullBrush)
1164 pixmaps[TMP] = XCreatePixmap( display, rootWindow,
1165 width, height,
1166 dcDst->w.bitsPerPixel );
1167 /* fall through */
1168 case OP_ARGS(PAT,DST):
1169 case OP_ARGS(PAT,SRC):
1170 if (!fNullBrush)
1171 XFillRectangle( display, pixmaps[OP_DST(*opcode)],
1172 tmpGC, 0, 0, width, height );
1173 break;
1176 XSetFunction( display, dcDst->u.x.gc, GXcopy );
1177 BITBLT_PutDstArea( dcDst, pixmaps[destUsed ? DST : SRC],
1178 dcDst->u.x.gc, &visRectDst );
1179 XFreePixmap( display, pixmaps[DST] );
1180 if (pixmaps[SRC]) XFreePixmap( display, pixmaps[SRC] );
1181 if (pixmaps[TMP]) XFreePixmap( display, pixmaps[TMP] );
1182 XFreeGC( display, tmpGC );
1183 return TRUE;
1187 /***********************************************************************
1188 * PatBlt (GDI.29)
1190 BOOL PatBlt( HDC hdc, short left, short top,
1191 short width, short height, DWORD rop)
1193 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1194 if (!dc)
1196 dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
1197 if (!dc) return FALSE;
1198 MF_MetaParam6(dc, META_PATBLT, left, top, width, height,
1199 HIWORD(rop), LOWORD(rop));
1200 return TRUE;
1203 dprintf_bitblt(stddeb, "PatBlt: %d %d,%d %dx%d %06lx\n",
1204 hdc, left, top, width, height, rop );
1206 return BITBLT_InternalStretchBlt( dc, left, top, width, height,
1207 NULL, 0, 0, 0, 0, rop );
1211 /***********************************************************************
1212 * BitBlt (GDI.34)
1214 BOOL BitBlt( HDC hdcDst, short xDst, short yDst, short width, short height,
1215 HDC hdcSrc, short xSrc, short ySrc, DWORD rop )
1217 DC *dcDst, *dcSrc;
1219 if (!(dcDst = (DC *)GDI_GetObjPtr( hdcDst, DC_MAGIC )))
1221 dcDst = (DC *)GDI_GetObjPtr( hdcDst, METAFILE_DC_MAGIC );
1222 if (!dcDst) return FALSE;
1223 return MF_BitBlt( dcDst, xDst, yDst, width, height,
1224 hdcSrc, xSrc, ySrc, rop );
1226 dcSrc = (DC *) GDI_GetObjPtr( hdcSrc, DC_MAGIC );
1228 dprintf_bitblt(stddeb,
1229 "BitBlt: %04x %d,%d %d bpp -> %04x %d,%d %dx%dx%d rop=%06lx\n",
1230 hdcSrc, xSrc, ySrc, dcSrc ? dcSrc->w.bitsPerPixel : 0,
1231 hdcDst, xDst, yDst, width, height, dcDst->w.bitsPerPixel, rop);
1232 dprintf_bitblt(stddeb," src org=%d,%d dst org=%d,%d\n",
1233 dcSrc->w.DCOrgX, dcSrc->w.DCOrgY, dcDst->w.DCOrgX, dcDst->w.DCOrgY );
1234 return BITBLT_InternalStretchBlt( dcDst, xDst, yDst, width, height,
1235 dcSrc, xSrc, ySrc, width, height, rop );
1239 /***********************************************************************
1240 * StretchBlt (GDI.35)
1242 BOOL StretchBlt( HDC hdcDst, short xDst, short yDst,
1243 short widthDst, short heightDst,
1244 HDC hdcSrc, short xSrc, short ySrc,
1245 short widthSrc, short heightSrc, DWORD rop )
1247 DC *dcDst, *dcSrc;
1249 if (!(dcDst = (DC *) GDI_GetObjPtr( hdcDst, DC_MAGIC )))
1251 if (!(dcDst = (DC *)GDI_GetObjPtr( hdcDst, METAFILE_DC_MAGIC )))
1252 return FALSE;
1253 return MF_StretchBlt( dcDst, xDst, yDst, widthDst, heightDst,
1254 hdcSrc, xSrc, ySrc, widthSrc, heightSrc, rop );
1257 dcSrc = (DC *) GDI_GetObjPtr( hdcSrc, DC_MAGIC );
1258 dprintf_bitblt(stddeb,
1259 "StretchBlt: %04x %d,%d %dx%dx%d -> %04x %d,%d %dx%dx%d rop=%06lx\n",
1260 hdcSrc, xSrc, ySrc, widthSrc, heightSrc,
1261 dcSrc ? dcSrc->w.bitsPerPixel : 0, hdcDst, xDst, yDst,
1262 widthDst, heightDst, dcDst->w.bitsPerPixel, rop );
1264 return BITBLT_InternalStretchBlt( dcDst, xDst, yDst, widthDst, heightDst,
1265 dcSrc, xSrc, ySrc, widthSrc, heightSrc,
1266 rop );