1 | /* $Id$ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuest -- VirtualBox Win 2000/XP guest display driver
|
---|
4 | *
|
---|
5 | * Video HW Acceleration support functions.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | *
|
---|
19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
20 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
21 | * additional information or have any questions.
|
---|
22 | */
|
---|
23 | #include "driver.h"
|
---|
24 | #include "dd.h"
|
---|
25 | #undef CO_E_NOTINITIALIZED
|
---|
26 | #include <winerror.h>
|
---|
27 | #include <iprt/asm.h>
|
---|
28 |
|
---|
29 | #define MEMTAG 'AWHV'
|
---|
30 | PVBOXVHWASURFDESC vboxVHWASurfDescAlloc()
|
---|
31 | {
|
---|
32 | return EngAllocMem(FL_NONPAGED_MEMORY | FL_ZERO_MEMORY, sizeof(VBOXVHWASURFDESC), MEMTAG);
|
---|
33 | }
|
---|
34 |
|
---|
35 | void vboxVHWASurfDescFree(PVBOXVHWASURFDESC pDesc)
|
---|
36 | {
|
---|
37 | EngFreeMem(pDesc);
|
---|
38 | }
|
---|
39 |
|
---|
40 | #define VBOX_DD(_f) DD##_f
|
---|
41 | #define VBOX_VHWA(_f) VBOXVHWA_##_f
|
---|
42 | #define VBOX_DD2VHWA(_out, _in, _f) do {if((_in) & VBOX_DD(_f)) _out |= VBOX_VHWA(_f); }while(0)
|
---|
43 | #define VBOX_DD_VHWA_PAIR(_v) {VBOX_DD(_v), VBOX_VHWA(_v)}
|
---|
44 | #define VBOX_DD_DUMMY_PAIR(_v) {VBOX_DD(_v), 0}
|
---|
45 |
|
---|
46 |
|
---|
47 | static const uint32_t g_SupportedCapList[][2] = {
|
---|
48 | VBOX_DD_VHWA_PAIR(CAPS_BLT),
|
---|
49 | VBOX_DD_VHWA_PAIR(CAPS_BLTQUEUE),
|
---|
50 | VBOX_DD_VHWA_PAIR(CAPS_BLTCOLORFILL),
|
---|
51 | VBOX_DD_VHWA_PAIR(CAPS_BLTFOURCC),
|
---|
52 | VBOX_DD_VHWA_PAIR(CAPS_BLTSTRETCH),
|
---|
53 | VBOX_DD_VHWA_PAIR(CAPS_OVERLAY),
|
---|
54 | VBOX_DD_VHWA_PAIR(CAPS_OVERLAYCANTCLIP),
|
---|
55 | VBOX_DD_VHWA_PAIR(CAPS_OVERLAYFOURCC),
|
---|
56 | VBOX_DD_VHWA_PAIR(CAPS_OVERLAYSTRETCH),
|
---|
57 | VBOX_DD_VHWA_PAIR(CAPS_COLORKEY),
|
---|
58 | VBOX_DD_VHWA_PAIR(CAPS_COLORKEYHWASSIST)
|
---|
59 | };
|
---|
60 |
|
---|
61 | static const uint32_t g_SupportedCap2List[][2] = {
|
---|
62 | VBOX_DD_VHWA_PAIR(CAPS2_COPYFOURCC),
|
---|
63 | };
|
---|
64 |
|
---|
65 |
|
---|
66 | static const uint32_t g_SupportedSCapList[][2] = {
|
---|
67 | VBOX_DD_VHWA_PAIR(SCAPS_FLIP),
|
---|
68 | VBOX_DD_VHWA_PAIR(SCAPS_PRIMARYSURFACE),
|
---|
69 | VBOX_DD_VHWA_PAIR(SCAPS_OVERLAY),
|
---|
70 | VBOX_DD_VHWA_PAIR(SCAPS_VISIBLE),
|
---|
71 | VBOX_DD_VHWA_PAIR(SCAPS_VIDEOMEMORY),
|
---|
72 | VBOX_DD_VHWA_PAIR(SCAPS_OFFSCREENPLAIN),
|
---|
73 | VBOX_DD_VHWA_PAIR(SCAPS_LOCALVIDMEM),
|
---|
74 | VBOX_DD_VHWA_PAIR(SCAPS_COMPLEX)
|
---|
75 | };
|
---|
76 |
|
---|
77 | static const uint32_t gSupportedSDList[][2] = {
|
---|
78 | VBOX_DD_VHWA_PAIR(SD_BACKBUFFERCOUNT),
|
---|
79 | VBOX_DD_VHWA_PAIR(SD_CAPS),
|
---|
80 | VBOX_DD_VHWA_PAIR(SD_CKDESTBLT),
|
---|
81 | VBOX_DD_VHWA_PAIR(SD_CKDESTOVERLAY),
|
---|
82 | VBOX_DD_VHWA_PAIR(SD_CKSRCBLT),
|
---|
83 | VBOX_DD_VHWA_PAIR(SD_CKSRCOVERLAY),
|
---|
84 | VBOX_DD_VHWA_PAIR(SD_HEIGHT),
|
---|
85 | VBOX_DD_VHWA_PAIR(SD_PITCH),
|
---|
86 | VBOX_DD_VHWA_PAIR(SD_PIXELFORMAT),
|
---|
87 | VBOX_DD_VHWA_PAIR(SD_WIDTH),
|
---|
88 | };
|
---|
89 |
|
---|
90 | static const uint32_t g_SupportedPFList[][2] = {
|
---|
91 | VBOX_DD_VHWA_PAIR(PF_RGB),
|
---|
92 | VBOX_DD_VHWA_PAIR(PF_RGBTOYUV),
|
---|
93 | VBOX_DD_VHWA_PAIR(PF_YUV),
|
---|
94 | VBOX_DD_VHWA_PAIR(PF_FOURCC)
|
---|
95 | };
|
---|
96 |
|
---|
97 | static const uint32_t g_SupportedCKeyCapList[][2] = {
|
---|
98 | VBOX_DD_VHWA_PAIR(CKEYCAPS_DESTBLT),
|
---|
99 | VBOX_DD_VHWA_PAIR(CKEYCAPS_DESTBLTCLRSPACE),
|
---|
100 | VBOX_DD_VHWA_PAIR(CKEYCAPS_DESTBLTCLRSPACEYUV),
|
---|
101 | VBOX_DD_VHWA_PAIR(CKEYCAPS_DESTBLTYUV),
|
---|
102 | VBOX_DD_VHWA_PAIR(CKEYCAPS_DESTOVERLAY),
|
---|
103 | VBOX_DD_VHWA_PAIR(CKEYCAPS_DESTOVERLAYCLRSPACE),
|
---|
104 | VBOX_DD_VHWA_PAIR(CKEYCAPS_DESTOVERLAYCLRSPACEYUV),
|
---|
105 | VBOX_DD_VHWA_PAIR(CKEYCAPS_DESTOVERLAYONEACTIVE),
|
---|
106 | VBOX_DD_VHWA_PAIR(CKEYCAPS_DESTOVERLAYYUV),
|
---|
107 | VBOX_DD_VHWA_PAIR(CKEYCAPS_NOCOSTOVERLAY),
|
---|
108 | VBOX_DD_VHWA_PAIR(CKEYCAPS_SRCBLT),
|
---|
109 | VBOX_DD_VHWA_PAIR(CKEYCAPS_SRCBLTCLRSPACE),
|
---|
110 | VBOX_DD_VHWA_PAIR(CKEYCAPS_SRCBLTCLRSPACEYUV),
|
---|
111 | VBOX_DD_VHWA_PAIR(CKEYCAPS_SRCBLTYUV),
|
---|
112 | VBOX_DD_VHWA_PAIR(CKEYCAPS_SRCOVERLAY),
|
---|
113 | VBOX_DD_VHWA_PAIR(CKEYCAPS_SRCOVERLAYCLRSPACE),
|
---|
114 | VBOX_DD_VHWA_PAIR(CKEYCAPS_SRCOVERLAYCLRSPACEYUV),
|
---|
115 | VBOX_DD_VHWA_PAIR(CKEYCAPS_SRCOVERLAYONEACTIVE),
|
---|
116 | VBOX_DD_VHWA_PAIR(CKEYCAPS_SRCOVERLAYYUV)
|
---|
117 | };
|
---|
118 |
|
---|
119 | //static const uint32_t g_SupportedOverList[][2] = {
|
---|
120 | // VBOX_DD_VHWA_PAIR(OVER_DDFX),
|
---|
121 | // VBOX_DD_VHWA_PAIR(OVER_HIDE),
|
---|
122 | // VBOX_DD_VHWA_PAIR(OVER_KEYDEST),
|
---|
123 | // VBOX_DD_VHWA_PAIR(OVER_KEYDESTOVERRIDE),
|
---|
124 | // VBOX_DD_VHWA_PAIR(OVER_KEYSRC),
|
---|
125 | // VBOX_DD_VHWA_PAIR(OVER_KEYSRCOVERRIDE),
|
---|
126 | // VBOX_DD_VHWA_PAIR(OVER_SHOW)
|
---|
127 | //};
|
---|
128 | //
|
---|
129 | //static const uint32_t g_SupportedCKeyList[][2] = {
|
---|
130 | // VBOX_DD_VHWA_PAIR(CKEY_COLORSPACE),
|
---|
131 | // VBOX_DD_VHWA_PAIR(CKEY_DESTBLT),
|
---|
132 | // VBOX_DD_VHWA_PAIR(CKEY_DESTOVERLAY),
|
---|
133 | // VBOX_DD_VHWA_PAIR(CKEY_SRCBLTE),
|
---|
134 | // VBOX_DD_VHWA_PAIR(CKEY_SRCOVERLAY)
|
---|
135 | //};
|
---|
136 |
|
---|
137 | static uint32_t g_SupportedVHWACaps;
|
---|
138 | static uint32_t g_SupportedVHWASCaps;
|
---|
139 | static uint32_t g_SupportedVHWAPFs;
|
---|
140 | static uint32_t g_SupportedVHWASDs;
|
---|
141 | static uint32_t g_SupportedDDCaps;
|
---|
142 | static uint32_t g_SupportedDDSCaps;
|
---|
143 | static uint32_t g_SupportedDDPFs;
|
---|
144 | static uint32_t g_SupportedDDSDs;
|
---|
145 |
|
---|
146 | static uint32_t g_SupportedVHWACKeyCaps;
|
---|
147 | static uint32_t g_SupportedDDCKeyCaps;
|
---|
148 |
|
---|
149 | static uint32_t g_SupportedOVERs;
|
---|
150 | static uint32_t g_SupportedCKEYs;
|
---|
151 |
|
---|
152 |
|
---|
153 | void vboxVHWAInit()
|
---|
154 | {
|
---|
155 | int i;
|
---|
156 | g_SupportedVHWACaps = 0;
|
---|
157 | g_SupportedVHWASCaps = 0;
|
---|
158 | g_SupportedVHWAPFs = 0;
|
---|
159 | g_SupportedVHWASDs = 0;
|
---|
160 | g_SupportedDDCaps = 0;
|
---|
161 | g_SupportedDDSCaps = 0;
|
---|
162 | g_SupportedDDPFs = 0;
|
---|
163 | g_SupportedDDSDs = 0;
|
---|
164 |
|
---|
165 | g_SupportedVHWACKeyCaps = 0;
|
---|
166 | g_SupportedDDCKeyCaps = 0;
|
---|
167 |
|
---|
168 | for(i = 0; i < sizeof(g_SupportedCapList)/sizeof(g_SupportedCapList[0]); i++)
|
---|
169 | {
|
---|
170 | g_SupportedDDCaps |= g_SupportedCapList[i][0];
|
---|
171 | g_SupportedVHWACaps |= g_SupportedCapList[i][1];
|
---|
172 | }
|
---|
173 |
|
---|
174 | for(i = 0; i < sizeof(g_SupportedSCapList)/sizeof(g_SupportedSCapList[0]); i++)
|
---|
175 | {
|
---|
176 | g_SupportedDDSCaps |= g_SupportedSCapList[i][0];
|
---|
177 | g_SupportedVHWASCaps |= g_SupportedSCapList[i][1];
|
---|
178 | }
|
---|
179 |
|
---|
180 | for(i = 0; i < sizeof(g_SupportedPFList)/sizeof(g_SupportedPFList[0]); i++)
|
---|
181 | {
|
---|
182 | g_SupportedDDPFs |= g_SupportedPFList[i][0];
|
---|
183 | g_SupportedVHWAPFs |= g_SupportedPFList[i][1];
|
---|
184 | }
|
---|
185 |
|
---|
186 | for(i = 0; i < sizeof(gSupportedSDList)/sizeof(gSupportedSDList[0]); i++)
|
---|
187 | {
|
---|
188 | g_SupportedDDSDs |= gSupportedSDList[i][0];
|
---|
189 | g_SupportedVHWASDs |= gSupportedSDList[i][1];
|
---|
190 | }
|
---|
191 |
|
---|
192 | for(i = 0; i < sizeof(g_SupportedCKeyCapList)/sizeof(g_SupportedCKeyCapList[0]); i++)
|
---|
193 | {
|
---|
194 | g_SupportedDDCKeyCaps |= g_SupportedCKeyCapList[i][0];
|
---|
195 | g_SupportedVHWACKeyCaps |= g_SupportedCKeyCapList[i][1];
|
---|
196 | }
|
---|
197 |
|
---|
198 | g_SupportedOVERs = VBOXVHWA_OVER_DDFX
|
---|
199 | | VBOXVHWA_OVER_HIDE
|
---|
200 | | VBOXVHWA_OVER_KEYDEST
|
---|
201 | | VBOXVHWA_OVER_KEYDESTOVERRIDE
|
---|
202 | | VBOXVHWA_OVER_KEYSRC
|
---|
203 | | VBOXVHWA_OVER_KEYSRCOVERRIDE
|
---|
204 | | VBOXVHWA_OVER_SHOW;
|
---|
205 |
|
---|
206 | g_SupportedCKEYs = VBOXVHWA_CKEY_COLORSPACE
|
---|
207 | | VBOXVHWA_CKEY_DESTBLT
|
---|
208 | | VBOXVHWA_CKEY_DESTOVERLAY
|
---|
209 | | VBOXVHWA_CKEY_SRCBLT
|
---|
210 | | VBOXVHWA_CKEY_SRCOVERLAY;
|
---|
211 | }
|
---|
212 |
|
---|
213 | void vboxVHWATerm()
|
---|
214 | {
|
---|
215 |
|
---|
216 | }
|
---|
217 |
|
---|
218 | uint32_t vboxVHWAUnsupportedDDCAPS(uint32_t caps)
|
---|
219 | {
|
---|
220 | return caps & (~g_SupportedDDCaps);
|
---|
221 | }
|
---|
222 |
|
---|
223 | uint32_t vboxVHWAUnsupportedDDSCAPS(uint32_t caps)
|
---|
224 | {
|
---|
225 | return caps & (~g_SupportedDDSCaps);
|
---|
226 | }
|
---|
227 |
|
---|
228 | uint32_t vboxVHWAUnsupportedDDPFS(uint32_t caps)
|
---|
229 | {
|
---|
230 | return caps & (~g_SupportedDDPFs);
|
---|
231 | }
|
---|
232 |
|
---|
233 | uint32_t vboxVHWAUnsupportedDSS(uint32_t caps)
|
---|
234 | {
|
---|
235 | return caps & (~g_SupportedDDSDs);
|
---|
236 | }
|
---|
237 |
|
---|
238 | uint32_t vboxVHWAUnsupportedDDCEYCAPS(uint32_t caps)
|
---|
239 | {
|
---|
240 | return caps & (~g_SupportedDDCKeyCaps);
|
---|
241 | }
|
---|
242 |
|
---|
243 | uint32_t vboxVHWASupportedDDCEYCAPS(uint32_t caps)
|
---|
244 | {
|
---|
245 | return caps & (g_SupportedDDCKeyCaps);
|
---|
246 | }
|
---|
247 |
|
---|
248 |
|
---|
249 | uint32_t vboxVHWASupportedDDCAPS(uint32_t caps)
|
---|
250 | {
|
---|
251 | return caps & (g_SupportedDDCaps);
|
---|
252 | }
|
---|
253 |
|
---|
254 | uint32_t vboxVHWASupportedDDSCAPS(uint32_t caps)
|
---|
255 | {
|
---|
256 | return caps & (g_SupportedDDSCaps);
|
---|
257 | }
|
---|
258 |
|
---|
259 | uint32_t vboxVHWASupportedDDPFS(uint32_t caps)
|
---|
260 | {
|
---|
261 | return caps & (g_SupportedDDPFs);
|
---|
262 | }
|
---|
263 |
|
---|
264 | uint32_t vboxVHWASupportedDSS(uint32_t caps)
|
---|
265 | {
|
---|
266 | return caps & (g_SupportedDDSDs);
|
---|
267 | }
|
---|
268 |
|
---|
269 | uint32_t vboxVHWASupportedOVERs(uint32_t caps)
|
---|
270 | {
|
---|
271 | return caps & (g_SupportedOVERs);
|
---|
272 | }
|
---|
273 |
|
---|
274 | uint32_t vboxVHWAUnsupportedOVERs(uint32_t caps)
|
---|
275 | {
|
---|
276 | return caps & (~g_SupportedOVERs);
|
---|
277 | }
|
---|
278 |
|
---|
279 | uint32_t vboxVHWASupportedCKEYs(uint32_t caps)
|
---|
280 | {
|
---|
281 | return caps & (g_SupportedCKEYs);
|
---|
282 | }
|
---|
283 |
|
---|
284 | uint32_t vboxVHWAUnsupportedCKEYs(uint32_t caps)
|
---|
285 | {
|
---|
286 | return caps & (~g_SupportedCKEYs);
|
---|
287 | }
|
---|
288 |
|
---|
289 | uint32_t vboxVHWAFromDDOVERs(uint32_t caps) { return caps; }
|
---|
290 | uint32_t vboxVHWAToDDOVERs(uint32_t caps) { return caps; }
|
---|
291 | uint32_t vboxVHWAFromDDCKEYs(uint32_t caps) { return caps; }
|
---|
292 | uint32_t vboxVHWAToDDCKEYs(uint32_t caps) { return caps; }
|
---|
293 |
|
---|
294 | void vboxVHWAFromDDOVERLAYFX(VBOXVHWA_OVERLAYFX *pVHWAOverlay, DDOVERLAYFX *pDdOverlay)
|
---|
295 | {
|
---|
296 | //TODO: fxFlags
|
---|
297 | vboxVHWAFromDDCOLORKEY(&pVHWAOverlay->DstCK, &pDdOverlay->dckDestColorkey);
|
---|
298 | vboxVHWAFromDDCOLORKEY(&pVHWAOverlay->SrcCK, &pDdOverlay->dckSrcColorkey);
|
---|
299 | }
|
---|
300 |
|
---|
301 | uint32_t vboxVHWAFromDDCAPS(uint32_t caps)
|
---|
302 | {
|
---|
303 | uint32_t vhwaCaps = 0;
|
---|
304 | int i;
|
---|
305 | for(i = 0; i < sizeof(g_SupportedCapList)/sizeof(g_SupportedCapList[0]); i++)
|
---|
306 | {
|
---|
307 | if(caps & g_SupportedCapList[i][0])
|
---|
308 | {
|
---|
309 | vhwaCaps |= g_SupportedCapList[i][1];
|
---|
310 | }
|
---|
311 | }
|
---|
312 | return vhwaCaps;
|
---|
313 | }
|
---|
314 |
|
---|
315 | uint32_t vboxVHWAToDDCAPS(uint32_t caps)
|
---|
316 | {
|
---|
317 | uint32_t vhwaCaps = 0;
|
---|
318 | int i;
|
---|
319 | for(i = 0; i < sizeof(g_SupportedCapList)/sizeof(g_SupportedCapList[0]); i++)
|
---|
320 | {
|
---|
321 | if(caps & g_SupportedCapList[i][1])
|
---|
322 | {
|
---|
323 | vhwaCaps |= g_SupportedCapList[i][0];
|
---|
324 | }
|
---|
325 | }
|
---|
326 | return vhwaCaps;
|
---|
327 | }
|
---|
328 |
|
---|
329 | uint32_t vboxVHWAFromDDCAPS2(uint32_t caps)
|
---|
330 | {
|
---|
331 | return caps;
|
---|
332 | }
|
---|
333 |
|
---|
334 | uint32_t vboxVHWAToDDCAPS2(uint32_t caps)
|
---|
335 | {
|
---|
336 | return caps;
|
---|
337 | }
|
---|
338 |
|
---|
339 | uint32_t vboxVHWAFromDDSCAPS(uint32_t caps)
|
---|
340 | {
|
---|
341 | uint32_t vhwaCaps = 0;
|
---|
342 | int i;
|
---|
343 | for(i = 0; i < sizeof(g_SupportedSCapList)/sizeof(g_SupportedSCapList[0]); i++)
|
---|
344 | {
|
---|
345 | if(caps & g_SupportedSCapList[i][0])
|
---|
346 | {
|
---|
347 | vhwaCaps |= g_SupportedSCapList[i][1];
|
---|
348 | }
|
---|
349 | }
|
---|
350 | return vhwaCaps;
|
---|
351 | }
|
---|
352 |
|
---|
353 | uint32_t vboxVHWAToDDSCAPS(uint32_t caps)
|
---|
354 | {
|
---|
355 | uint32_t vhwaCaps = 0;
|
---|
356 | int i;
|
---|
357 | for(i = 0; i < sizeof(g_SupportedSCapList)/sizeof(g_SupportedSCapList[0]); i++)
|
---|
358 | {
|
---|
359 | if(caps & g_SupportedSCapList[i][1])
|
---|
360 | {
|
---|
361 | vhwaCaps |= g_SupportedSCapList[i][0];
|
---|
362 | }
|
---|
363 | }
|
---|
364 | return vhwaCaps;
|
---|
365 | }
|
---|
366 |
|
---|
367 | uint32_t vboxVHWAFromDDPFS(uint32_t caps)
|
---|
368 | {
|
---|
369 | uint32_t vhwaCaps = 0;
|
---|
370 | int i;
|
---|
371 | for(i = 0; i < sizeof(g_SupportedPFList)/sizeof(g_SupportedPFList[0]); i++)
|
---|
372 | {
|
---|
373 | if(caps & g_SupportedPFList[i][0])
|
---|
374 | {
|
---|
375 | vhwaCaps |= g_SupportedPFList[i][1];
|
---|
376 | }
|
---|
377 | }
|
---|
378 | return vhwaCaps;
|
---|
379 | }
|
---|
380 |
|
---|
381 | uint32_t vboxVHWAToDDPFS(uint32_t caps)
|
---|
382 | {
|
---|
383 | uint32_t vhwaCaps = 0;
|
---|
384 | int i;
|
---|
385 | for(i = 0; i < sizeof(g_SupportedPFList)/sizeof(g_SupportedPFList[0]); i++)
|
---|
386 | {
|
---|
387 | if(caps & g_SupportedPFList[i][1])
|
---|
388 | {
|
---|
389 | vhwaCaps |= g_SupportedPFList[i][0];
|
---|
390 | }
|
---|
391 | }
|
---|
392 | return vhwaCaps;
|
---|
393 | }
|
---|
394 |
|
---|
395 | uint32_t vboxVHWAFromDDCKEYCAPS(uint32_t caps)
|
---|
396 | {
|
---|
397 | uint32_t vhwaCaps = 0;
|
---|
398 | int i;
|
---|
399 | for(i = 0; i < sizeof(g_SupportedCKeyCapList)/sizeof(g_SupportedCKeyCapList[0]); i++)
|
---|
400 | {
|
---|
401 | if(caps & g_SupportedCKeyCapList[i][0])
|
---|
402 | {
|
---|
403 | vhwaCaps |= g_SupportedCKeyCapList[i][1];
|
---|
404 | }
|
---|
405 | }
|
---|
406 | return vhwaCaps;
|
---|
407 | }
|
---|
408 |
|
---|
409 | uint32_t vboxVHWAToDDCKEYCAPS(uint32_t caps)
|
---|
410 | {
|
---|
411 | uint32_t vhwaCaps = 0;
|
---|
412 | int i;
|
---|
413 | for(i = 0; i < sizeof(g_SupportedCKeyCapList)/sizeof(g_SupportedCKeyCapList[0]); i++)
|
---|
414 | {
|
---|
415 | if(caps & g_SupportedCKeyCapList[i][1])
|
---|
416 | {
|
---|
417 | vhwaCaps |= g_SupportedCKeyCapList[i][0];
|
---|
418 | }
|
---|
419 | }
|
---|
420 | return vhwaCaps;
|
---|
421 | }
|
---|
422 |
|
---|
423 | uint32_t vboxVHWAToDDBLTs(uint32_t caps)
|
---|
424 | {
|
---|
425 | return caps;
|
---|
426 | }
|
---|
427 |
|
---|
428 | uint32_t vboxVHWAFromDDBLTs(uint32_t caps)
|
---|
429 | {
|
---|
430 | return caps;
|
---|
431 | }
|
---|
432 |
|
---|
433 | void vboxVHWAFromDDBLTFX(VBOXVHWA_BLTFX *pVHWABlt, DDBLTFX *pDdBlt)
|
---|
434 | {
|
---|
435 | // pVHWABlt->flags;
|
---|
436 | // uint32_t rop;
|
---|
437 | // uint32_t rotationOp;
|
---|
438 | // uint32_t rotation;
|
---|
439 |
|
---|
440 | pVHWABlt->fillColor = pDdBlt->dwFillColor;
|
---|
441 |
|
---|
442 | vboxVHWAFromDDCOLORKEY(&pVHWABlt->DstCK, &pDdBlt->ddckDestColorkey);
|
---|
443 | vboxVHWAFromDDCOLORKEY(&pVHWABlt->SrcCK, &pDdBlt->ddckSrcColorkey);
|
---|
444 | }
|
---|
445 |
|
---|
446 | int vboxVHWAFromDDPIXELFORMAT(VBOXVHWA_PIXELFORMAT *pVHWAFormat, DDPIXELFORMAT *pDdFormat)
|
---|
447 | {
|
---|
448 | uint32_t unsup = vboxVHWAUnsupportedDDPFS(pDdFormat->dwFlags);
|
---|
449 | Assert(!unsup);
|
---|
450 | if(unsup)
|
---|
451 | return VERR_GENERAL_FAILURE;
|
---|
452 |
|
---|
453 | pVHWAFormat->flags = vboxVHWAFromDDPFS(pDdFormat->dwFlags);
|
---|
454 | pVHWAFormat->fourCC = pDdFormat->dwFourCC;
|
---|
455 | pVHWAFormat->c.rgbBitCount = pDdFormat->dwRGBBitCount;
|
---|
456 | pVHWAFormat->m1.rgbRBitMask = pDdFormat->dwRBitMask;
|
---|
457 | pVHWAFormat->m2.rgbGBitMask = pDdFormat->dwGBitMask;
|
---|
458 | pVHWAFormat->m3.rgbBBitMask = pDdFormat->dwBBitMask;
|
---|
459 | return VINF_SUCCESS;
|
---|
460 | }
|
---|
461 |
|
---|
462 | void vboxVHWAFromDDCOLORKEY(VBOXVHWA_COLORKEY *pVHWACKey, DDCOLORKEY *pDdCKey)
|
---|
463 | {
|
---|
464 | pVHWACKey->low = pDdCKey->dwColorSpaceLowValue;
|
---|
465 | pVHWACKey->high = pDdCKey->dwColorSpaceHighValue;
|
---|
466 | }
|
---|
467 |
|
---|
468 | int vboxVHWAFromDDSURFACEDESC(VBOXVHWA_SURFACEDESC *pVHWADesc, DDSURFACEDESC *pDdDesc)
|
---|
469 | {
|
---|
470 | uint32_t unsupds = vboxVHWAUnsupportedDSS(pDdDesc->dwFlags);
|
---|
471 | Assert(!unsupds);
|
---|
472 | if(unsupds)
|
---|
473 | return VERR_GENERAL_FAILURE;
|
---|
474 |
|
---|
475 | pVHWADesc->flags = 0;
|
---|
476 |
|
---|
477 | if(pDdDesc->dwFlags & DDSD_BACKBUFFERCOUNT)
|
---|
478 | {
|
---|
479 | pVHWADesc->flags |= VBOXVHWA_SD_BACKBUFFERCOUNT;
|
---|
480 | pVHWADesc->cBackBuffers = pDdDesc->dwBackBufferCount;
|
---|
481 | }
|
---|
482 | if(pDdDesc->dwFlags & DDSD_CAPS)
|
---|
483 | {
|
---|
484 | uint32_t unsup = vboxVHWAUnsupportedDDSCAPS(pDdDesc->ddsCaps.dwCaps);
|
---|
485 | Assert(!unsup);
|
---|
486 | if(unsup)
|
---|
487 | return VERR_GENERAL_FAILURE;
|
---|
488 | pVHWADesc->flags |= VBOXVHWA_SD_CAPS;
|
---|
489 | pVHWADesc->surfCaps = vboxVHWAFromDDSCAPS(pDdDesc->ddsCaps.dwCaps);
|
---|
490 | }
|
---|
491 | if(pDdDesc->dwFlags & DDSD_CKDESTBLT)
|
---|
492 | {
|
---|
493 | pVHWADesc->flags |= VBOXVHWA_SD_CKDESTBLT;
|
---|
494 | vboxVHWAFromDDCOLORKEY(&pVHWADesc->DstBltCK, &pDdDesc->ddckCKDestBlt);
|
---|
495 | }
|
---|
496 | if(pDdDesc->dwFlags & DDSD_CKDESTOVERLAY)
|
---|
497 | {
|
---|
498 | pVHWADesc->flags |= VBOXVHWA_SD_CKDESTOVERLAY;
|
---|
499 | vboxVHWAFromDDCOLORKEY(&pVHWADesc->DstOverlayCK, &pDdDesc->ddckCKDestOverlay);
|
---|
500 | }
|
---|
501 | if(pDdDesc->dwFlags & DDSD_CKSRCBLT)
|
---|
502 | {
|
---|
503 | pVHWADesc->flags |= VBOXVHWA_SD_CKSRCBLT;
|
---|
504 | vboxVHWAFromDDCOLORKEY(&pVHWADesc->SrcBltCK, &pDdDesc->ddckCKSrcBlt);
|
---|
505 | }
|
---|
506 | if(pDdDesc->dwFlags & DDSD_CKSRCOVERLAY)
|
---|
507 | {
|
---|
508 | pVHWADesc->flags |= VBOXVHWA_SD_CKSRCOVERLAY;
|
---|
509 | vboxVHWAFromDDCOLORKEY(&pVHWADesc->SrcOverlayCK, &pDdDesc->ddckCKSrcOverlay);
|
---|
510 | }
|
---|
511 | if(pDdDesc->dwFlags & DDSD_HEIGHT)
|
---|
512 | {
|
---|
513 | pVHWADesc->flags |= VBOXVHWA_SD_HEIGHT;
|
---|
514 | pVHWADesc->height = pDdDesc->dwHeight;
|
---|
515 | }
|
---|
516 | if(pDdDesc->dwFlags & DDSD_WIDTH)
|
---|
517 | {
|
---|
518 | pVHWADesc->flags |= VBOXVHWA_SD_WIDTH;
|
---|
519 | pVHWADesc->width = pDdDesc->dwWidth;
|
---|
520 | }
|
---|
521 | if(pDdDesc->dwFlags & DDSD_PITCH)
|
---|
522 | {
|
---|
523 | pVHWADesc->flags |= VBOXVHWA_SD_PITCH;
|
---|
524 | pVHWADesc->pitch = pDdDesc->lPitch;
|
---|
525 | }
|
---|
526 | if(pDdDesc->dwFlags & DDSD_PIXELFORMAT)
|
---|
527 | {
|
---|
528 | int rc = vboxVHWAFromDDPIXELFORMAT(&pVHWADesc->PixelFormat, &pDdDesc->ddpfPixelFormat);
|
---|
529 | if(RT_FAILURE(rc))
|
---|
530 | return rc;
|
---|
531 | pVHWADesc->flags |= VBOXVHWA_SD_PIXELFORMAT;
|
---|
532 | }
|
---|
533 | return VINF_SUCCESS;
|
---|
534 | }
|
---|
535 |
|
---|
536 | void vboxVHWAFromRECTL(VBOXVHWA_RECTL *pDst, RECTL *pSrc)
|
---|
537 | {
|
---|
538 | // Assert(pSrc->left <= pSrc->right);
|
---|
539 | // Assert(pSrc->top <= pSrc->bottom);
|
---|
540 | pDst->left = pSrc->left;
|
---|
541 | pDst->top = pSrc->top;
|
---|
542 | pDst->right = pSrc->right;
|
---|
543 | pDst->bottom = pSrc->bottom;
|
---|
544 | }
|
---|
545 |
|
---|
546 | #define MIN(_a, _b) (_a) < (_b) ? (_a) : (_b)
|
---|
547 | #define MAX(_a, _b) (_a) > (_b) ? (_a) : (_b)
|
---|
548 |
|
---|
549 | void vboxVHWARectUnited(RECTL * pDst, RECTL * pRect1, RECTL * pRect2)
|
---|
550 | {
|
---|
551 | pDst->left = MIN(pRect1->left, pRect2->left);
|
---|
552 | pDst->top = MIN(pRect1->top, pRect2->top);
|
---|
553 | pDst->right = MAX(pRect1->right, pRect2->right);
|
---|
554 | pDst->bottom = MAX(pRect1->bottom, pRect2->bottom);
|
---|
555 | }
|
---|
556 |
|
---|
557 | bool vboxVHWARectIsEmpty(RECTL * pRect)
|
---|
558 | {
|
---|
559 | return pRect->left == pRect->right-1 && pRect->top == pRect->bottom-1;
|
---|
560 | }
|
---|
561 |
|
---|
562 | bool vboxVHWARectIntersect(RECTL * pRect1, RECTL * pRect2)
|
---|
563 | {
|
---|
564 | return !((pRect1->left < pRect2->left && pRect1->right < pRect2->left)
|
---|
565 | || (pRect2->left < pRect1->left && pRect2->right < pRect1->left)
|
---|
566 | || (pRect1->top < pRect2->top && pRect1->bottom < pRect2->top)
|
---|
567 | || (pRect2->top < pRect1->top && pRect2->bottom < pRect1->top));
|
---|
568 | }
|
---|
569 |
|
---|
570 | bool vboxVHWARectInclude(RECTL * pRect1, RECTL * pRect2)
|
---|
571 | {
|
---|
572 | return ((pRect1->left <= pRect2->left && pRect1->right >= pRect2->right)
|
---|
573 | && (pRect1->top <= pRect2->top && pRect1->bottom >= pRect2->bottom));
|
---|
574 | }
|
---|
575 |
|
---|
576 |
|
---|
577 | bool vboxVHWARegionIntersects(PVBOXVHWAREGION pReg, RECTL * pRect)
|
---|
578 | {
|
---|
579 | if(!pReg->bValid)
|
---|
580 | return false;
|
---|
581 | return vboxVHWARectIntersect(&pReg->Rect, pRect);
|
---|
582 | }
|
---|
583 |
|
---|
584 | bool vboxVHWARegionIncludes(PVBOXVHWAREGION pReg, RECTL * pRect)
|
---|
585 | {
|
---|
586 | if(!pReg->bValid)
|
---|
587 | return false;
|
---|
588 | return vboxVHWARectInclude(&pReg->Rect, pRect);
|
---|
589 | }
|
---|
590 |
|
---|
591 | bool vboxVHWARegionIncluded(PVBOXVHWAREGION pReg, RECTL * pRect)
|
---|
592 | {
|
---|
593 | if(!pReg->bValid)
|
---|
594 | return true;
|
---|
595 | return vboxVHWARectInclude(pRect, &pReg->Rect);
|
---|
596 | }
|
---|
597 |
|
---|
598 | void vboxVHWARegionSet(PVBOXVHWAREGION pReg, RECTL * pRect)
|
---|
599 | {
|
---|
600 | if(vboxVHWARectIsEmpty(pRect))
|
---|
601 | {
|
---|
602 | pReg->bValid = false;
|
---|
603 | }
|
---|
604 | else
|
---|
605 | {
|
---|
606 | pReg->Rect = *pRect;
|
---|
607 | pReg->bValid = true;
|
---|
608 | }
|
---|
609 | }
|
---|
610 |
|
---|
611 | void vboxVHWARegionAdd(PVBOXVHWAREGION pReg, RECTL * pRect)
|
---|
612 | {
|
---|
613 | if(vboxVHWARectIsEmpty(pRect))
|
---|
614 | {
|
---|
615 | return;
|
---|
616 | }
|
---|
617 | else if(!pReg->bValid)
|
---|
618 | {
|
---|
619 | vboxVHWARegionSet(pReg, pRect);
|
---|
620 | }
|
---|
621 | else
|
---|
622 | {
|
---|
623 | vboxVHWARectUnited(&pReg->Rect, &pReg->Rect, pRect);
|
---|
624 | }
|
---|
625 | }
|
---|
626 |
|
---|
627 | void vboxVHWARegionInit(PVBOXVHWAREGION pReg)
|
---|
628 | {
|
---|
629 | pReg->bValid = false;
|
---|
630 | }
|
---|
631 |
|
---|
632 | void vboxVHWARegionClear(PVBOXVHWAREGION pReg)
|
---|
633 | {
|
---|
634 | pReg->bValid = false;
|
---|
635 | }
|
---|
636 |
|
---|
637 | bool vboxVHWARegionValid(PVBOXVHWAREGION pReg)
|
---|
638 | {
|
---|
639 | return pReg->bValid;
|
---|
640 | }
|
---|
641 |
|
---|
642 | void vboxVHWARegionTrySubstitute(PVBOXVHWAREGION pReg, const RECTL *pRect)
|
---|
643 | {
|
---|
644 | if(!pReg->bValid)
|
---|
645 | return;
|
---|
646 |
|
---|
647 | if(pReg->Rect.left >= pRect->left && pReg->Rect.right <= pRect->right)
|
---|
648 | {
|
---|
649 | LONG t = MAX(pReg->Rect.top, pRect->top);
|
---|
650 | LONG b = MIN(pReg->Rect.bottom, pRect->bottom);
|
---|
651 | if(t < b)
|
---|
652 | {
|
---|
653 | pReg->Rect.top = t;
|
---|
654 | pReg->Rect.bottom = b;
|
---|
655 | }
|
---|
656 | else
|
---|
657 | {
|
---|
658 | pReg->bValid = false;
|
---|
659 | }
|
---|
660 | }
|
---|
661 | else if(pReg->Rect.top >= pRect->top && pReg->Rect.bottom <= pRect->bottom)
|
---|
662 | {
|
---|
663 | LONG l = MAX(pReg->Rect.left, pRect->left);
|
---|
664 | LONG r = MIN(pReg->Rect.right, pRect->right);
|
---|
665 | if(l < r)
|
---|
666 | {
|
---|
667 | pReg->Rect.left = l;
|
---|
668 | pReg->Rect.right = r;
|
---|
669 | }
|
---|
670 | else
|
---|
671 | {
|
---|
672 | pReg->bValid = false;
|
---|
673 | }
|
---|
674 | }
|
---|
675 | }
|
---|