VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/enable.c@ 8061

Last change on this file since 8061 was 4736, checked in by vboxsync, 17 years ago

NT4 does not have DrvDeriveSurface.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.6 KB
Line 
1/******************************Module*Header*******************************\
2*
3* *******************
4* * GDI SAMPLE CODE *
5* *******************
6*
7* Module Name: enable.c
8*
9* This module contains the functions that enable and disable the
10* driver, the pdev, and the surface.
11*
12* Copyright (c) 1992-1998 Microsoft Corporation
13\**************************************************************************/
14
15#include "driver.h"
16#include "dd.h"
17#include <VBoxDisplay.h>
18
19// The driver function table with all function index/address pairs
20
21// Hook functions to track dirty rectangles and generate RDP orders.
22// NT4 functions
23DRVFN gadrvfn_nt4[] = {
24 { INDEX_DrvEnablePDEV, (PFN) DrvEnablePDEV }, // 0
25 { INDEX_DrvCompletePDEV, (PFN) DrvCompletePDEV }, // 1
26 { INDEX_DrvDisablePDEV, (PFN) DrvDisablePDEV }, // 2
27 { INDEX_DrvEnableSurface, (PFN) DrvEnableSurface }, // 3
28 { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface }, // 4
29 { INDEX_DrvAssertMode, (PFN) DrvAssertMode }, // 5
30 { INDEX_DrvOffset, (PFN) DrvOffset }, // 6
31 { INDEX_DrvDisableDriver, (PFN) DrvDisableDriver }, // 8
32// { INDEX_DrvCreateDeviceBitmap, (PFN) DrvCreateDeviceBitmap }, // 10
33// { INDEX_DrvDeleteDeviceBitmap, (PFN) DrvDeleteDeviceBitmap }, // 11
34 { INDEX_DrvRealizeBrush, (PFN) DrvRealizeBrush }, // 12
35 { INDEX_DrvDitherColor, (PFN) DrvDitherColor }, // 13
36 { INDEX_DrvStrokePath, (PFN) DrvStrokePath }, // 14
37 { INDEX_DrvFillPath, (PFN) DrvFillPath }, // 15
38 { INDEX_DrvPaint, (PFN) DrvPaint }, // 17
39 { INDEX_DrvBitBlt, (PFN) DrvBitBlt }, // 18
40 { INDEX_DrvCopyBits, (PFN) DrvCopyBits }, // 19
41 { INDEX_DrvStretchBlt, (PFN) DrvStretchBlt, }, // 20
42 { INDEX_DrvSetPalette, (PFN) DrvSetPalette }, // 22
43 { INDEX_DrvTextOut, (PFN) DrvTextOut }, // 23
44 { INDEX_DrvEscape, (PFN) DrvEscape }, // 24
45 { INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape }, // 29
46 { INDEX_DrvMovePointer, (PFN) DrvMovePointer }, // 30
47 { INDEX_DrvLineTo, (PFN) DrvLineTo }, // 31
48 { INDEX_DrvSynchronize, (PFN) DrvSynchronize }, // 38
49 { INDEX_DrvSaveScreenBits, (PFN) DrvSaveScreenBits }, // 40
50 { INDEX_DrvGetModes, (PFN) DrvGetModes }, // 41
51#ifdef VBOX_WITH_DDRAW
52 { INDEX_DrvGetDirectDrawInfo, (PFN) DrvGetDirectDrawInfo }, // 59 0x3b
53 { INDEX_DrvEnableDirectDraw, (PFN) DrvEnableDirectDraw }, // 60 0x3c
54 { INDEX_DrvDisableDirectDraw, (PFN) DrvDisableDirectDraw }, // 61 0x3d
55#endif
56};
57/* Experimental begin */
58BOOL APIENTRY DrvResetPDEV(DHPDEV dhpdevOld, DHPDEV dhpdevNew)
59{
60 DISPDBG((0, "Experimental %s: %p, %p\n", __FUNCTION__, dhpdevOld, dhpdevNew));
61 return TRUE;
62}
63
64BOOL DrvNineGrid (PVOID x1, PVOID x2, PVOID x3, PVOID x4, PVOID x5, PVOID x6, PVOID x7, PVOID x8, PVOID x9)
65{
66 DISPDBG((0, "Experimental %s: %p, %p, %p, %p, %p, %p, %p, %p, %p\n", __FUNCTION__, x1, x2, x3, x4, x5, x6, x7, x8, x9));
67 return FALSE;
68}
69
70VOID APIENTRY DrvDestroyFont(FONTOBJ *pfo)
71{
72 DISPDBG((0, "Experimental %s: %p\n", __FUNCTION__, pfo));
73}
74
75ULONG APIENTRY DrvEscape(SURFOBJ *pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
76{
77 PDEV* ppdev = (PDEV*) pso->dhpdev;
78
79 DISPDBG((0, "%s: %p, %p, %p, %p, %p, %p\n", __FUNCTION__, pso, iEsc, cjIn, pvIn, cjOut, pvOut));
80
81 switch(iEsc)
82 {
83#ifdef VBOX_WITH_OPENGL
84 case OPENGL_GETINFO:
85 {
86 if ( cjOut >= sizeof(OPENGL_INFO)
87 && pvOut)
88 {
89 POPENGL_INFO pInfo = (POPENGL_INFO)pvOut;
90
91 pInfo->dwVersion = 2;
92 pInfo->dwDriverVersion = 1;
93 pInfo->szDriverName[0] = 'V';
94 pInfo->szDriverName[1] = 'B';
95 pInfo->szDriverName[2] = 'o';
96 pInfo->szDriverName[3] = 'x';
97 pInfo->szDriverName[4] = 'O';
98 pInfo->szDriverName[5] = 'G';
99 pInfo->szDriverName[6] = 'L';
100 pInfo->szDriverName[7] = 0;
101
102 DISPDBG((0, "OPENGL_GETINFO\n"));
103 return cjOut;
104 }
105 else
106 DISPDBG((0, "OPENGL_GETINFO invalid size %d\n", cjOut)); /* It doesn't matter that we fail here. Opengl32 will fall back to software rendering when this escape is not supported. */
107 break;
108 }
109#endif
110
111 case VBOXESC_ISVRDPACTIVE:
112 {
113 ULONG ret = 0;
114
115 if (ppdev && ppdev->pInfo && vboxHwBufferBeginUpdate (ppdev))
116 {
117 if (ppdev->vbva.pVbvaMemory->fu32ModeFlags
118 & VBVA_F_MODE_VRDP)
119 {
120 ret = 1;
121 }
122 DISPDBG((0, "VBOXESC_ISVRDPACTIVE -> %d (%x)\n", ret, ppdev->vbva.pVbvaMemory->fu32ModeFlags));
123 vboxHwBufferEndUpdate (ppdev);
124 }
125 else
126 DISPDBG((0, "VBOXESC_ISVRDPACTIVE -> 0\n"));
127 return ret;
128 }
129
130 case VBOXESC_SETVISIBLEREGION:
131 {
132 LPRGNDATA lpRgnData = (LPRGNDATA)pvIn;
133
134 DISPDBG((0, "VBOXESC_SETVISIBLEREGION\n"));
135
136 if ( cjIn >= sizeof(RGNDATAHEADER)
137 && pvIn
138 && lpRgnData->rdh.dwSize == sizeof(RGNDATAHEADER)
139 && lpRgnData->rdh.iType == RDH_RECTANGLES
140 && cjIn == lpRgnData->rdh.nCount * sizeof(RECT) + sizeof(RGNDATAHEADER))
141 {
142 DWORD ulReturn, i;
143 PRTRECT pRTRect;
144 RECT *pRect = (RECT *)&lpRgnData->Buffer;
145
146 pRTRect = (PRTRECT) EngAllocMem(0, lpRgnData->rdh.nCount*sizeof(RTRECT), ALLOC_TAG);
147 for (i=0;i<lpRgnData->rdh.nCount;i++)
148 {
149 DISPDBG((0, "New visible rectangle (%d,%d) (%d,%d)\n", pRect[i].left, pRect[i].bottom, pRect[i].right, pRect[i].top));
150 pRTRect[i].xLeft = pRect[i].left;
151 pRTRect[i].yBottom = pRect[i].bottom;
152 pRTRect[i].xRight = pRect[i].right;
153 pRTRect[i].yTop = pRect[i].top;
154 }
155
156 if (EngDeviceIoControl(ppdev->hDriver,
157 IOCTL_VIDEO_VBOX_SETVISIBLEREGION,
158 pRTRect,
159 lpRgnData->rdh.nCount*sizeof(RTRECT),
160 NULL,
161 0,
162 &ulReturn))
163 {
164 DISPDBG((0, "DISP DrvAssertMode failed IOCTL_VIDEO_VBOX_SETVISIBLEREGION\n"));
165 return 0;
166 }
167 else
168 {
169 DISPDBG((0, "DISP IOCTL_VIDEO_VBOX_SETVISIBLEREGION successful\n"));
170 return 1;
171 }
172
173 }
174 else
175 {
176 if (pvIn)
177 DISPDBG((0, "check failed rdh.dwSize=%x iType=%d size=%d expected size=%d\n", lpRgnData->rdh.dwSize, lpRgnData->rdh.iType, cjIn, lpRgnData->rdh.nCount * sizeof(RECT) + sizeof(RGNDATAHEADER)));
178 }
179
180 break;
181 }
182
183 case QUERYESCSUPPORT:
184 if ( cjIn == sizeof(DWORD)
185 && pvIn)
186 {
187 DWORD nEscapeQuery = *(DWORD *)pvIn;
188
189 switch(nEscapeQuery)
190 {
191#ifdef VBOX_WITH_OPENGL
192 case OPENGL_GETINFO:
193 return 1;
194#endif
195 default:
196 DISPDBG((0, "QUERYESCSUPPORT %d unsupported\n", nEscapeQuery));
197 break;
198 }
199 }
200 else
201 DISPDBG((0, "QUERYESCSUPPORT invalid size %d\n", cjOut));
202 break;
203
204 default:
205 DISPDBG((0, "Unsupported Escape %d\n", iEsc));
206 break;
207 }
208 return 0;
209}
210
211BOOL DrvConnect (PVOID x1, PVOID x2, PVOID x3, PVOID x4)
212{
213 DISPDBG((0, "Experimental %s: %p, %p, %p, %p\n", __FUNCTION__, x1, x2, x3, x4));
214 return TRUE;
215}
216
217BOOL DrvDisconnect (PVOID x1, PVOID x2)
218{
219 DISPDBG((0, "Experimental %s: %p, %p\n", __FUNCTION__, x1, x2));
220 return FALSE;
221}
222
223BOOL DrvReconnect (PVOID x1, PVOID x2)
224{
225 DISPDBG((0, "Experimental %s: %p, %p\n", __FUNCTION__, x1, x2));
226 return FALSE;
227}
228
229BOOL DrvShadowConnect (PVOID x1, PVOID x2)
230{
231 DISPDBG((0, "Experimental %s: %p, %p\n", __FUNCTION__, x1, x2));
232 return FALSE;
233}
234
235BOOL DrvShadowDisconnect (PVOID x1, PVOID x2)
236{
237 DISPDBG((0, "Experimental %s: %p, %p\n", __FUNCTION__, x1, x2));
238 return FALSE;
239}
240
241
242/* Experimental end */
243
244// W2K,XP functions
245DRVFN gadrvfn_nt5[] = {
246 { INDEX_DrvEnablePDEV, (PFN) DrvEnablePDEV }, // 0 0x0
247 { INDEX_DrvCompletePDEV, (PFN) DrvCompletePDEV }, // 1 0x1
248 { INDEX_DrvDisablePDEV, (PFN) DrvDisablePDEV }, // 2 0x2
249 { INDEX_DrvEnableSurface, (PFN) DrvEnableSurface }, // 3 0x3
250 { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface }, // 4 0x4
251 { INDEX_DrvAssertMode, (PFN) DrvAssertMode }, // 5 0x5
252 { INDEX_DrvDisableDriver, (PFN) DrvDisableDriver }, // 8 0x8
253// { INDEX_DrvCreateDeviceBitmap, (PFN) DrvCreateDeviceBitmap }, // 10
254// { INDEX_DrvDeleteDeviceBitmap, (PFN) DrvDeleteDeviceBitmap }, // 11
255 { INDEX_DrvRealizeBrush, (PFN) DrvRealizeBrush }, // 12 0xc
256 { INDEX_DrvDitherColor, (PFN) DrvDitherColor }, // 13 0xd
257 { INDEX_DrvStrokePath, (PFN) DrvStrokePath }, // 14 0xe
258 { INDEX_DrvFillPath, (PFN) DrvFillPath }, // 15 0xf
259 { INDEX_DrvPaint, (PFN) DrvPaint }, // 17 0x11
260 { INDEX_DrvBitBlt, (PFN) DrvBitBlt }, // 18 0x12
261 { INDEX_DrvCopyBits, (PFN) DrvCopyBits }, // 19 0x13
262 { INDEX_DrvStretchBlt, (PFN) DrvStretchBlt, }, // 20 0x14
263 { INDEX_DrvSetPalette, (PFN) DrvSetPalette }, // 22 0x16
264 { INDEX_DrvTextOut, (PFN) DrvTextOut }, // 23 0x17
265 { INDEX_DrvEscape, (PFN) DrvEscape }, // 24 0x18
266 { INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape }, // 29 0x1d
267 { INDEX_DrvMovePointer, (PFN) DrvMovePointer }, // 30 0x1e
268 { INDEX_DrvLineTo, (PFN) DrvLineTo }, // 31 0x1f
269 { INDEX_DrvSynchronize, (PFN) DrvSynchronize }, // 38 0x26
270 { INDEX_DrvSaveScreenBits, (PFN) DrvSaveScreenBits }, // 40 0x28
271 { INDEX_DrvGetModes, (PFN) DrvGetModes }, // 41 0x29
272#ifdef VBOX_WITH_DDRAW
273 { INDEX_DrvGetDirectDrawInfo, (PFN) DrvGetDirectDrawInfo }, // 59 0x3b
274 { INDEX_DrvEnableDirectDraw, (PFN) DrvEnableDirectDraw }, // 60 0x3c
275 { INDEX_DrvDisableDirectDraw, (PFN) DrvDisableDirectDraw }, // 61 0x3d
276 { INDEX_DrvDeriveSurface, (PFN) DrvDeriveSurface }, // 85 0x55
277#endif
278 { INDEX_DrvNotify, (PFN) DrvNotify }, // 87 0x57
279// /* Experimental. */
280// { 0x7, (PFN) DrvResetPDEV }, // 0x7
281// { 0x5b, (PFN) DrvNineGrid }, // 0x5b
282// { 0x2b, (PFN) DrvDestroyFont }, // 0x2b
283// { 0x18, (PFN) DrvEscape }, // 0x18
284// { 0x4d, (PFN) DrvConnect }, // 0x4d
285// { 0x4e, (PFN) DrvDisconnect }, // 0x4e
286// { 0x4f, (PFN) DrvReconnect }, // 0x4f
287// { 0x50, (PFN) DrvShadowConnect }, // 0x50
288// { 0x51, (PFN) DrvShadowDisconnect }, // 0x51
289
290};
291
292// Required hook bits will be set up according to DDI version
293static ULONG gflHooks = 0;
294 BOOL g_bOnNT40 = TRUE; /* assume NT4 guest by default */
295
296#define HOOKS_BMF8BPP gflHooks
297#define HOOKS_BMF16BPP gflHooks
298#define HOOKS_BMF24BPP gflHooks
299#define HOOKS_BMF32BPP gflHooks
300
301HSEMAPHORE ghsemHwBuffer = 0;
302
303/******************************Public*Routine******************************\
304* DrvEnableDriver
305*
306* Enables the driver by retrieving the drivers function table and version.
307*
308\**************************************************************************/
309
310BOOL DrvEnableDriver(ULONG iEngineVersion, ULONG cj, PDRVENABLEDATA pded)
311{
312// Engine Version is passed down so future drivers can support previous
313// engine versions. A next generation driver can support both the old
314// and new engine conventions if told what version of engine it is
315// working with. For the first version the driver does nothing with it.
316
317 DISPDBG((0, "VBoxDisp::DrvEnableDriver called. iEngine version = %08X\n", iEngineVersion));
318
319 // Set up hook flags to intercept all functions which can generate VRDP orders
320 gflHooks = HOOK_BITBLT | HOOK_TEXTOUT | HOOK_FILLPATH |
321 HOOK_COPYBITS | HOOK_STROKEPATH | HOOK_LINETO |
322#ifdef VBOX_NEW_SURFACE_CODE
323 HOOK_PAINT | HOOK_STRETCHBLT | HOOK_SYNCHRONIZE;
324#else
325 HOOK_PAINT | HOOK_STRETCHBLT | HOOK_SYNCHRONIZEACCESS;
326#endif
327 // Set up g_bOnNT40 based on the value in iEngineVersion
328 if(iEngineVersion >= DDI_DRIVER_VERSION_NT5)
329 g_bOnNT40 = FALSE;
330
331// Fill in as much as we can.
332
333 if (cj >= sizeof(DRVENABLEDATA))
334 pded->pdrvfn = (iEngineVersion >= DDI_DRIVER_VERSION_NT5)?
335 gadrvfn_nt5:
336 gadrvfn_nt4;
337
338
339 if (cj >= (sizeof(ULONG) * 2))
340 pded->c = (iEngineVersion >= DDI_DRIVER_VERSION_NT5)?
341 sizeof(gadrvfn_nt5) / sizeof(DRVFN):
342 sizeof(gadrvfn_nt4) / sizeof(DRVFN);
343
344// DDI version this driver was targeted for is passed back to engine.
345// Future graphic's engine may break calls down to old driver format.
346
347 if (cj >= sizeof(ULONG))
348 pded->iDriverVersion = (iEngineVersion >= DDI_DRIVER_VERSION_NT5)?
349 DDI_DRIVER_VERSION_NT5:
350 DDI_DRIVER_VERSION_NT4;
351
352 if (!ghsemHwBuffer)
353 {
354 ghsemHwBuffer = EngCreateSemaphore ();
355 }
356
357 return(TRUE);
358}
359
360/******************************Public*Routine******************************\
361* DrvDisableDriver
362*
363* Tells the driver it is being disabled. Release any resources allocated in
364* DrvEnableDriver.
365*
366\**************************************************************************/
367
368VOID DrvDisableDriver(VOID)
369{
370 DISPDBG((0, "VBoxDisp::DrvDisableDriver called.\n"));
371
372 if (ghsemHwBuffer)
373 {
374 EngDeleteSemaphore (ghsemHwBuffer);
375 ghsemHwBuffer = NULL;
376 }
377
378 return;
379}
380
381/******************************Public*Routine******************************\
382* DrvEnablePDEV
383*
384* DDI function, Enables the Physical Device.
385*
386* Return Value: device handle to pdev.
387*
388\**************************************************************************/
389
390DHPDEV DrvEnablePDEV(
391DEVMODEW *pDevmode, // Pointer to DEVMODE
392PWSTR pwszLogAddress, // Logical address
393ULONG cPatterns, // number of patterns
394HSURF *ahsurfPatterns, // return standard patterns
395ULONG cjGdiInfo, // Length of memory pointed to by pGdiInfo
396ULONG *pGdiInfo, // Pointer to GdiInfo structure
397ULONG cjDevInfo, // Length of following PDEVINFO structure
398DEVINFO *pDevInfo, // physical device information structure
399HDEV hdev, // HDEV, used for callbacks
400PWSTR pwszDeviceName, // DeviceName - not used
401HANDLE hDriver) // Handle to base driver
402{
403 GDIINFO GdiInfo;
404 DEVINFO DevInfo;
405 PPDEV ppdev = (PPDEV) NULL;
406
407 DISPDBG((0, "VBoxDisp::DrvEnablePDEV called\n"));
408
409 UNREFERENCED_PARAMETER(pwszLogAddress);
410 UNREFERENCED_PARAMETER(pwszDeviceName);
411
412 RtlZeroMemory(&DevInfo, sizeof (DEVINFO));
413 RtlZeroMemory(&GdiInfo, sizeof (GDIINFO));
414
415 // Allocate a physical device structure.
416
417 ppdev = (PPDEV) EngAllocMem(0, sizeof(PDEV), ALLOC_TAG);
418
419 if (ppdev == (PPDEV) NULL)
420 {
421 DISPDBG((0, "DISP DrvEnablePDEV failed EngAllocMem\n"));
422 return((DHPDEV) 0);
423 }
424
425 memset(ppdev, 0, sizeof(PDEV));
426
427 // Save the screen handle in the PDEV.
428
429 ppdev->hDriver = hDriver;
430
431 // Get the current screen mode information. Set up device caps and devinfo.
432
433 if (!bInitPDEV(ppdev, pDevmode, &GdiInfo, &DevInfo))
434 {
435 DISPDBG((0,"DISP DrvEnablePDEV failed\n"));
436 goto error_free;
437 }
438
439 // Initialize the cursor information.
440
441 if (!bInitPointer(ppdev, &DevInfo))
442 {
443 // Not a fatal error...
444 DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n"));
445 }
446
447 // Initialize palette information.
448
449 if (!bInitPaletteInfo(ppdev, &DevInfo))
450 {
451 DISPDBG((0, "DrvEnablePDEV failed bInitPalette\n"));
452 goto error_free;
453 }
454
455// // Start a thread that will process notifications from VMMDev
456// if (!bInitNotificationThread(ppdev))
457// {
458// DISPDBG((0, "DrvEnablePDEV failed bInitNotificationThread\n"));
459// goto error_free;
460// }
461
462 // Copy the devinfo into the engine buffer.
463
464 DISPDBG((0, "VBoxDisp::DrvEnablePDEV: sizeof(DEVINFO) = %d, cjDevInfo = %d, alpha = %d\n", sizeof(DEVINFO), cjDevInfo, DevInfo.flGraphicsCaps2 & GCAPS2_ALPHACURSOR));
465
466// @todo seems to be not necessary. these bits are initialized in screen.c DevInfo.flGraphicsCaps |= GCAPS_OPAQUERECT |
467// GCAPS_DITHERONREALIZE |
468// GCAPS_PALMANAGED |
469// GCAPS_ALTERNATEFILL |
470// GCAPS_WINDINGFILL |
471// GCAPS_MONO_DITHER |
472// GCAPS_COLOR_DITHER |
473// GCAPS_ASYNCMOVE;
474//
475// DevInfo.flGraphicsCaps |= GCAPS_DITHERONREALIZE;
476
477 DevInfo.flGraphicsCaps2 |= GCAPS2_RESERVED1; /* @todo figure out what is this. */
478
479 memcpy(pDevInfo, &DevInfo, min(sizeof(DEVINFO), cjDevInfo));
480
481 // Set the pdevCaps with GdiInfo we have prepared to the list of caps for this
482 // pdev.
483
484 memcpy(pGdiInfo, &GdiInfo, min(cjGdiInfo, sizeof(GDIINFO)));
485
486 DISPDBG((0, "VBoxDisp::DrvEnablePDEV completed %x\n", ppdev));
487
488 return((DHPDEV) ppdev);
489
490 // Error case for failure.
491error_free:
492 EngFreeMem(ppdev);
493 return((DHPDEV) 0);
494}
495
496/******************************Public*Routine******************************\
497* DrvCompletePDEV
498*
499* Store the HPDEV, the engines handle for this PDEV, in the DHPDEV.
500*
501\**************************************************************************/
502
503VOID DrvCompletePDEV(DHPDEV dhpdev, HDEV hdev)
504{
505 DISPDBG((0, "VBoxDisp::DrvCompletePDEV called %x\n", dhpdev));
506 ((PPDEV) dhpdev)->hdevEng = hdev;
507}
508
509/******************************Public*Routine******************************\
510* DrvDisablePDEV
511*
512* Release the resources allocated in DrvEnablePDEV. If a surface has been
513* enabled DrvDisableSurface will have already been called.
514*
515\**************************************************************************/
516
517VOID DrvDisablePDEV(DHPDEV dhpdev)
518{
519 DISPDBG((0, "VBoxDisp::DrvDisablePDEV called %x\n", dhpdev));
520// vStopNotificationThread ((PPDEV) dhpdev);
521 vDisablePalette((PPDEV) dhpdev);
522
523 /* Free the driver's VBVA resources. */
524 vboxVbvaDisable ((PPDEV) dhpdev);
525
526 EngFreeMem(dhpdev);
527}
528
529/******************************Public*Routine******************************\
530* VOID DrvOffset
531*
532* DescriptionText
533*
534\**************************************************************************/
535
536BOOL DrvOffset(SURFOBJ *pso, LONG x, LONG y, FLONG flReserved)
537{
538 PDEV* ppdev = (PDEV*) pso->dhpdev;
539
540 DISPDBG((0, "VBoxDisp::DrvOffset %x %x %x\n", x, y, flReserved));
541
542 // Add back last offset that we subtracted. I could combine the next
543 // two statements, but I thought this was more clear. It's not
544 // performance critical anyway.
545
546 ppdev->pjScreen += ((ppdev->ptlOrg.y * ppdev->lDeltaScreen) +
547 (ppdev->ptlOrg.x * ((ppdev->ulBitCount+1) >> 3)));
548
549 // Subtract out new offset
550
551 ppdev->pjScreen -= ((y * ppdev->lDeltaScreen) +
552 (x * ((ppdev->ulBitCount+1) >> 3)));
553
554 ppdev->ptlOrg.x = x;
555 ppdev->ptlOrg.y = y;
556
557 return(TRUE);
558}
559
560/******************************Public*Routine******************************\
561* DrvEnableSurface
562*
563* Enable the surface for the device. Hook the calls this driver supports.
564*
565* Return: Handle to the surface if successful, 0 for failure.
566*
567\**************************************************************************/
568
569HSURF DrvEnableSurface(DHPDEV dhpdev)
570{
571 PPDEV ppdev;
572 HSURF hsurf;
573 SIZEL sizl;
574 ULONG ulBitmapType;
575 FLONG flHooks;
576#ifdef VBOX_NEW_SURFACE_CODE
577 PVBOXSURF psurf;
578#endif
579 DISPDBG((0, "DISP DrvEnableSurface called\n"));
580
581 // Create engine bitmap around frame buffer.
582
583 ppdev = (PPDEV) dhpdev;
584
585 ppdev->ptlOrg.x = 0;
586 ppdev->ptlOrg.y = 0;
587
588 if (!bInitSURF(ppdev, TRUE))
589 {
590 DISPDBG((0, "DISP DrvEnableSurface failed bInitSURF\n"));
591 return(FALSE);
592 }
593
594 DISPDBG((0, "DISP DrvEnableSurface bInitSURF success\n"));
595
596 sizl.cx = ppdev->cxScreen;
597 sizl.cy = ppdev->cyScreen;
598
599 if (ppdev->ulBitCount == 8)
600 {
601 if (!bInit256ColorPalette(ppdev)) {
602 DISPDBG((0, "DISP DrvEnableSurface failed to init the 8bpp palette\n"));
603 return(FALSE);
604 }
605 ulBitmapType = BMF_8BPP;
606 flHooks = HOOKS_BMF8BPP;
607 }
608 else if (ppdev->ulBitCount == 16)
609 {
610 ulBitmapType = BMF_16BPP;
611 flHooks = HOOKS_BMF16BPP;
612 }
613 else if (ppdev->ulBitCount == 24)
614 {
615 ulBitmapType = BMF_24BPP;
616 flHooks = HOOKS_BMF24BPP;
617 }
618 else
619 {
620 ulBitmapType = BMF_32BPP;
621 flHooks = HOOKS_BMF32BPP;
622 }
623
624#ifdef VBOX_NEW_SURFACE_CODE
625 psurf = (PVBOXSURF)EngAllocMem(0, sizeof(VBOXSURF), ALLOC_TAG);
626 if (psurf == NULL)
627 {
628 DISPDBG((0, "DrvEnableSurface: failed pdsurf memory allocation\n"));
629 goto l_Failure;
630 }
631 ppdev->pdsurfScreen = psurf;
632 psurf->ppdev = ppdev;
633
634 //
635 // On NT4.0 we create a GDI managed bitmap as the primay surface. But
636 // on NT5.0 we create a device managed primary.
637 //
638 // On NT4.0 we still use our driver's accleration capabilities by
639 // doing a trick with EngLockSurface on the GDI managed primary.
640 //
641
642 if(g_bOnNT40)
643 {
644 hsurf = (HSURF) EngCreateBitmap(sizl,
645 ppdev->lDeltaScreen,
646 ulBitmapType,
647 (ppdev->lDeltaScreen > 0) ? BMF_TOPDOWN : 0,
648 (PVOID)(ppdev->pjScreen));
649 }
650 else
651 {
652 hsurf = (HSURF)EngCreateDeviceSurface((DHSURF)psurf, sizl,
653 ulBitmapType);
654 }
655
656 if ( hsurf == 0 )
657 {
658 DISPDBG((0, "DrvEnableSurface: failed EngCreateDeviceBitmap\n"));
659 goto l_Failure;
660 }
661
662 //
663 // On NT5.0 we call EngModifSurface to expose our device surface to
664 // GDI. We cant do this on NT4.0 hence we call EngAssociateSurface.
665 //
666
667 if(g_bOnNT40)
668 {
669 //
670 // We have to associate the surface we just created with our physical
671 // device so that GDI can get information related to the PDEV when
672 // it's drawing to the surface (such as, for example, the length of
673 // styles on the device when simulating styled lines).
674 //
675
676 //
677 // On NT4.0 we dont want to be called to Synchronize Access
678 //
679 LONG myflHooks = flHooks;
680 myflHooks &= ~HOOK_SYNCHRONIZE;
681
682 if (!EngAssociateSurface(hsurf, ppdev->hdevEng, myflHooks))
683 {
684 DISPDBG((0, "DrvEnableSurface: failed EngAssociateSurface\n"));
685 goto l_Failure;
686 }
687
688 //
689 // Jam in the value of dhsurf into screen SURFOBJ. We do this to
690 // make sure the driver acclerates Drv calls we hook and not
691 // punt them back to GDI as the SURFOBJ's dhsurf = 0.
692 //
693 ppdev->psoScreenBitmap = EngLockSurface(hsurf);
694 if(ppdev->psoScreenBitmap == 0)
695 {
696 DISPDBG((0, "DrvEnableSurface: failed EngLockSurface\n"));
697 goto l_Failure;
698 }
699
700 ppdev->psoScreenBitmap->dhsurf = (DHSURF)hsurf;
701
702 }
703 else
704 {
705 //
706 // Tell GDI about the screen surface. This will enable GDI to render
707 // directly to the screen.
708 //
709
710 if ( !EngModifySurface(hsurf,
711 ppdev->hdevEng,
712 flHooks,
713 MS_NOTSYSTEMMEMORY,
714 (DHSURF)psurf,
715 ppdev->pjScreen,
716 ppdev->lDeltaScreen,
717 NULL))
718 {
719 DISPDBG((0, "DrvEnableSurface: failed EngModifySurface"));
720 goto l_Failure;
721 }
722 }
723 ppdev->hsurfScreen = hsurf;
724 ppdev->flHooks = flHooks;
725 ppdev->ulBitmapType = ulBitmapType;
726#else
727 hsurf = (HSURF) EngCreateBitmap(sizl,
728 ppdev->lDeltaScreen,
729 ulBitmapType,
730 (ppdev->lDeltaScreen > 0) ? BMF_TOPDOWN : 0,
731 (PVOID) (ppdev->pjScreen));
732
733 if (hsurf == (HSURF) 0)
734 {
735 DISPDBG((0, "DISP DrvEnableSurface failed EngCreateBitmap\n"));
736 goto l_Failure;
737 }
738 else
739 {
740 ppdev->hsurfScreenBitmap = hsurf;
741
742 if (!EngAssociateSurface(hsurf, ppdev->hdevEng, 0))
743 {
744 DISPDBG((0, "DISP DrvEnableSurface failed EngAssociateSurface for ScreenBitmap.\n"));
745 goto l_Failure;
746 }
747 else
748 {
749 SURFOBJ *pso = EngLockSurface(hsurf);
750
751 ppdev->psoScreenBitmap = pso;
752
753 hsurf = (HSURF) EngCreateDeviceSurface((DHSURF)pso,
754 sizl,
755 ulBitmapType);
756
757 if (hsurf == (HSURF) 0)
758 {
759 DISPDBG((0, "DISP DrvEnableSurface failed EngCreateDeviceSurface\n"));
760 goto l_Failure;
761 }
762 else
763 {
764 ppdev->hsurfScreen = hsurf;
765 /* Must set dhsurf to make sure GDI doesn't ignore our hooks */
766 ppdev->psoScreenBitmap->dhsurf = (DHSURF)hsurf;
767
768 if (!EngAssociateSurface(hsurf, ppdev->hdevEng, flHooks))
769 {
770 DISPDBG((0, "DISP DrvEnableSurface failed EngAssociateSurface for Screen.\n"));
771 goto l_Failure;
772 }
773 else
774 {
775 ppdev->flHooks = flHooks;
776 ppdev->ulBitmapType = ulBitmapType;
777 }
778 }
779 }
780 }
781#endif /* VBOX_NEW_SURFACE_CODE */
782 return ppdev->hsurfScreen;
783
784l_Failure:
785
786 DrvDisableSurface(dhpdev);
787
788 return((HSURF)0);
789}
790
791/******************************Public*Routine******************************\
792* DrvDisableSurface
793*
794* Free resources allocated by DrvEnableSurface. Release the surface.
795*
796\**************************************************************************/
797
798VOID DrvDisableSurface(DHPDEV dhpdev)
799{
800 PPDEV ppdev = (PPDEV)dhpdev;
801
802 DISPDBG((0, "VBoxDisp::DrvDisableSurface called\n"));
803 if (ppdev->psoScreenBitmap)
804 {
805 EngUnlockSurface (ppdev->psoScreenBitmap);
806 ppdev->psoScreenBitmap = NULL;
807 }
808
809 if (ppdev->hsurfScreen)
810 {
811 EngDeleteSurface(ppdev->hsurfScreen);
812 ppdev->hsurfScreen = (HSURF)0;
813 }
814#ifdef VBOX_NEW_SURFACE_CODE
815 if (ppdev->pdsurfScreen)
816 {
817 EngFreeMem(ppdev->pdsurfScreen);
818 ppdev->pdsurfScreen = NULL;
819 }
820#else
821 if (ppdev->hsurfScreenBitmap)
822 {
823 EngDeleteSurface(ppdev->hsurfScreenBitmap);
824 ppdev->hsurfScreenBitmap = (HSURF)0;
825 }
826#endif
827 vDisableSURF(ppdev);
828}
829
830/******************************Public*Routine******************************\
831* DrvAssertMode
832*
833* This asks the device to reset itself to the mode of the pdev passed in.
834*
835\**************************************************************************/
836
837BOOL DrvAssertMode(DHPDEV dhpdev, BOOL bEnable)
838{
839 PPDEV ppdev = (PPDEV) dhpdev;
840 ULONG ulReturn;
841 PBYTE pjScreen;
842
843 DISPDBG((0, "DISP DrvAssertMode called bEnable = %d\n", bEnable));
844
845 if (bEnable)
846 {
847 pjScreen = ppdev->pjScreen;
848
849 if (!bInitSURF(ppdev, FALSE))
850 {
851 DISPDBG((0, "DISP DrvAssertMode failed bInitSURF\n"));
852 return (FALSE);
853 }
854
855#ifdef VBOX_NEW_SURFACE_CODE
856 todo
857#endif
858 if (pjScreen != ppdev->pjScreen)
859 {
860 HSURF hsurf;
861 SIZEL sizl;
862 SURFOBJ *pso;
863
864 DISPDBG((0, "DISP DrvAssertMode Screen pointer has changed!!!\n"));
865
866 sizl.cx = ppdev->cxScreen;
867 sizl.cy = ppdev->cyScreen;
868
869 hsurf = (HSURF) EngCreateBitmap(sizl,
870 ppdev->lDeltaScreen,
871 ppdev->ulBitmapType,
872 (ppdev->lDeltaScreen > 0) ? BMF_TOPDOWN : 0,
873 (PVOID) (ppdev->pjScreen));
874
875 if (hsurf == (HSURF) 0)
876 {
877 DISPDBG((0, "DISP DrvAssertMode failed EngCreateBitmap\n"));
878 return FALSE;
879 }
880
881 pso = EngLockSurface(hsurf);
882
883 if (ppdev->psoScreenBitmap)
884 {
885 EngUnlockSurface (ppdev->psoScreenBitmap);
886 ppdev->psoScreenBitmap = NULL;
887 }
888
889 if (ppdev->hsurfScreenBitmap)
890 {
891 EngDeleteSurface(ppdev->hsurfScreenBitmap);
892 ppdev->hsurfScreenBitmap = (HSURF)0;
893 }
894
895 ppdev->hsurfScreenBitmap = hsurf;
896 ppdev->psoScreenBitmap = pso;
897 }
898
899 if (!EngAssociateSurface(ppdev->hsurfScreenBitmap, ppdev->hdevEng, 0))
900 {
901 DISPDBG((0, "DISP DrvAssertMode failed EngAssociateSurface for ScreenBitmap.\n"));
902 return FALSE;
903 }
904
905 if (!EngAssociateSurface(ppdev->hsurfScreen, ppdev->hdevEng, ppdev->flHooks))
906 {
907 DISPDBG((0, "DISP DrvAssertMode failed EngAssociateSurface for Screen.\n"));
908 return FALSE;
909 }
910
911 return TRUE;
912 }
913 else
914 {
915 //
916 // We must give up the display.
917 // Call the kernel driver to reset the device to a known state.
918 //
919
920 if (EngDeviceIoControl(ppdev->hDriver,
921 IOCTL_VIDEO_RESET_DEVICE,
922 NULL,
923 0,
924 NULL,
925 0,
926 &ulReturn))
927 {
928 DISPDBG((0, "DISP DrvAssertMode failed IOCTL\n"));
929 return FALSE;
930 }
931 else
932 {
933 return TRUE;
934 }
935 }
936}
937
938#if 0
939/******************************Public*Routine**********************************\
940 * HBITMAP DrvCreateDeviceBitmap
941 *
942 * Function called by GDI to create a device-format-bitmap (DFB). We will
943 * always try to allocate the bitmap in off-screen; if we can't, we simply
944 * fail the call and GDI will create and manage the bitmap itself.
945 *
946 * Note: We do not have to zero the bitmap bits. GDI will automatically
947 * call us via DrvBitBlt to zero the bits (which is a security
948 * consideration).
949 *
950\******************************************************************************/
951
952HBITMAP
953DrvCreateDeviceBitmap(
954 DHPDEV dhpdev,
955 SIZEL sizl,
956 ULONG iFormat)
957{
958 DISPDBG((0, "DISP DrvCreateDeviceBitmap %x (%d,%d) %x\n", dhpdev, sizl.cx, sizl.cy, iFormat));
959 /* Let GDI manage the bitmap */
960 return (HBITMAP)0;
961}
962
963/******************************Public*Routine**********************************\
964 * VOID DrvDeleteDeviceBitmap
965 *
966 * Deletes a DFB.
967 *
968\******************************************************************************/
969
970VOID
971DrvDeleteDeviceBitmap(
972 DHSURF dhsurf)
973{
974 DISPDBG((0, "DISP DrvDeleteDeviceBitmap %x", dhsurf));
975}
976#endif /* 0 */
977
978/******************************Public*Routine******************************\
979* DrvGetModes
980*
981* Returns the list of available modes for the device.
982*
983\**************************************************************************/
984
985ULONG DrvGetModes(HANDLE hDriver, ULONG cjSize, DEVMODEW *pdm)
986{
987
988 DWORD cModes;
989 DWORD cbOutputSize;
990 PVIDEO_MODE_INFORMATION pVideoModeInformation, pVideoTemp;
991 DWORD cOutputModes = cjSize / (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
992 DWORD cbModeSize;
993
994 DISPDBG((3, "DrvGetModes\n"));
995
996 cModes = getAvailableModes(hDriver,
997 (PVIDEO_MODE_INFORMATION *) &pVideoModeInformation,
998 &cbModeSize);
999
1000 if (cModes == 0)
1001 {
1002 DISPDBG((0, "DrvGetModes failed to get mode information"));
1003 return 0;
1004 }
1005
1006 if (pdm == NULL)
1007 {
1008 cbOutputSize = cModes * (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
1009 }
1010 else
1011 {
1012 //
1013 // Now copy the information for the supported modes back into the output
1014 // buffer
1015 //
1016
1017 cbOutputSize = 0;
1018
1019 pVideoTemp = pVideoModeInformation;
1020
1021 do
1022 {
1023 if (pVideoTemp->Length != 0)
1024 {
1025 if (cOutputModes == 0)
1026 {
1027 break;
1028 }
1029
1030 //
1031 // Zero the entire structure to start off with.
1032 //
1033
1034 memset(pdm, 0, sizeof(DEVMODEW));
1035
1036 //
1037 // Set the name of the device to the name of the DLL.
1038 //
1039
1040 memcpy(pdm->dmDeviceName, DLL_NAME, sizeof(DLL_NAME));
1041
1042 pdm->dmSpecVersion = DM_SPECVERSION;
1043 pdm->dmDriverVersion = DM_SPECVERSION;
1044 pdm->dmSize = sizeof(DEVMODEW);
1045 pdm->dmDriverExtra = DRIVER_EXTRA_SIZE;
1046
1047 pdm->dmBitsPerPel = pVideoTemp->NumberOfPlanes *
1048 pVideoTemp->BitsPerPlane;
1049 pdm->dmPelsWidth = pVideoTemp->VisScreenWidth;
1050 pdm->dmPelsHeight = pVideoTemp->VisScreenHeight;
1051 pdm->dmDisplayFrequency = pVideoTemp->Frequency;
1052 pdm->dmDisplayFlags = 0;
1053
1054 pdm->dmFields = DM_BITSPERPEL |
1055 DM_PELSWIDTH |
1056 DM_PELSHEIGHT |
1057 DM_DISPLAYFREQUENCY |
1058 DM_DISPLAYFLAGS ;
1059
1060 //
1061 // Go to the next DEVMODE entry in the buffer.
1062 //
1063
1064 cOutputModes--;
1065
1066 pdm = (LPDEVMODEW) ( ((ULONG_PTR)pdm) + sizeof(DEVMODEW)
1067 + DRIVER_EXTRA_SIZE);
1068
1069 cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
1070
1071 }
1072
1073 pVideoTemp = (PVIDEO_MODE_INFORMATION)
1074 (((PUCHAR)pVideoTemp) + cbModeSize);
1075
1076 } while (--cModes);
1077 }
1078
1079 EngFreeMem(pVideoModeInformation);
1080
1081 return cbOutputSize;
1082
1083}
1084
1085VOID DrvSynchronize(IN DHPDEV dhpdev,IN RECTL *prcl)
1086{
1087 DISPDBG((0, "VBoxDisp::DrvSynchronize\n"));
1088}
1089
1090/******************************Public*Routine******************************\
1091* DrvNotify
1092*
1093* Called by GDI to notify us of certain "interesting" events
1094*
1095* DN_DEVICE_ORIGIN is used to communicate the X/Y offsets of individual monitors
1096* when DualView is in effect.
1097*
1098\**************************************************************************/
1099
1100VOID DrvNotify(
1101SURFOBJ *pso,
1102ULONG iType,
1103PVOID pvData)
1104{
1105 PDEV* ppdev = (PDEV*) pso->dhpdev;
1106
1107 DISPDBG((0, "VBoxDisp::DrvNotify called.\n"));
1108
1109 switch(iType)
1110 {
1111 case DN_DEVICE_ORIGIN:
1112 ppdev->ptlDevOrg = *(PPOINTL)pvData;
1113 DISPDBG((3, "DN_DEVICE_ORIGIN: %d, %d (PSO = %p, pInfo = %p)\n", ppdev->ptlDevOrg.x,
1114 ppdev->ptlDevOrg.y, pso, ppdev->pInfo));
1115 if (ppdev->pInfo)
1116 {
1117 ppdev->pInfo->screen.xOrigin = ppdev->ptlDevOrg.x;
1118 ppdev->pInfo->screen.yOrigin = ppdev->ptlDevOrg.y;
1119 VBoxProcessDisplayInfo(ppdev);
1120 }
1121 break;
1122 case DN_DRAWING_BEGIN:
1123 DISPDBG((3, "DN_DRAWING_BEGIN (PSO = %p)\n", pso));
1124 break;
1125 }
1126}
1127
1128#ifdef VBOX_WITH_DDRAW
1129//--------------------------Public Routine-------------------------------------
1130//
1131// HBITMAP DrvDeriveSurface
1132//
1133// This function derives and creates a GDI surface from the specified
1134// DirectDraw surface.
1135//
1136// Parameters
1137// pDirectDraw-----Points to a DD_DIRECTDRAW_GLOBAL structure that describes
1138// the DirectDraw object.
1139// pSurface--------Points to a DD_SURFACE_LOCAL structure that describes the
1140// DirectDraw surface around which to wrap a GDI surface.
1141//
1142// Return Value
1143// DrvDeriveSurface returns a handle to the created GDI surface upon success.
1144// It returns NULL if the call fails or if the driver cannot accelerate GDI
1145// drawing to the specified DirectDraw surface.
1146//
1147// Comments
1148// DrvDeriveSurface allows the driver to create a GDI surface around a
1149// DirectDraw video memory or AGP surface object in order to allow accelerated
1150// GDI drawing to the surface. If the driver does not hook this call, all GDI
1151// drawing to DirectDraw surfaces is done in software using the DIB engine.
1152//
1153// GDI calls DrvDeriveSurface with RGB surfaces only.
1154//
1155// The driver should call DrvCreateDeviceBitmap to create a GDI surface of the
1156// same size and format as that of the DirectDraw surface. Space for the
1157// actual pixels need not be allocated since it already exists.
1158//
1159//-----------------------------------------------------------------------------
1160HBITMAP DrvDeriveSurface(DD_DIRECTDRAW_GLOBAL* pDirectDraw, DD_SURFACE_LOCAL* pSurface)
1161{
1162 PPDEV pDev = (PPDEV)pDirectDraw->dhpdev;
1163 HBITMAP hbmDevice;
1164 DD_SURFACE_GLOBAL* pSurfaceGlobal;
1165
1166 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
1167
1168 pSurfaceGlobal = pSurface->lpGbl;
1169
1170 //
1171 // GDI should never call us for a non-RGB surface, but let's assert just
1172 // to make sure they're doing their job properly.
1173 //
1174 AssertMsg(!(pSurfaceGlobal->ddpfSurface.dwFlags & DDPF_FOURCC), ("GDI called us with a non-RGB surface!"));
1175
1176 // The GDI driver does not accelerate surfaces in AGP memory,
1177 // thus we fail the call
1178
1179 if (pSurface->ddsCaps.dwCaps & DDSCAPS_NONLOCALVIDMEM)
1180 {
1181 DISPDBG((0, "DrvDeriveSurface return NULL, surface in AGP memory\n"));
1182 return 0;
1183 }
1184
1185 // The GDI driver does not accelerate managed surface,
1186 // thus we fail the call
1187 if (pSurface->lpSurfMore->ddsCapsEx.dwCaps2 & DDSCAPS2_TEXTUREMANAGE)
1188 {
1189 DISPDBG((0, "DrvDeriveSurface return NULL, surface is managed\n"));
1190 return 0;
1191 }
1192
1193 //
1194 // The rest of our driver expects GDI calls to come in with the same
1195 // format as the primary surface. So we'd better not wrap a device
1196 // bitmap around an RGB format that the rest of our driver doesn't
1197 // understand. Also, we must check to see that it is not a surface
1198 // whose pitch does not match the primary surface.
1199 //
1200 // NOTE: Most surfaces created by this driver are allocated as 2D surfaces
1201 // whose lPitch's are equal to the screen pitch. However, overlay surfaces
1202 // are allocated such that there lPitch's are usually different then the
1203 // screen pitch. The hardware can not accelerate drawing operations to
1204 // these surfaces and thus we fail to derive these surfaces.
1205 //
1206 if ( (pSurfaceGlobal->ddpfSurface.dwRGBBitCount == pDev->ulBitCount) )
1207 {
1208 SIZEL sizel;
1209 DWORD ulBitmapType, flHooks;
1210
1211 sizel.cx = pSurfaceGlobal->wWidth;
1212 sizel.cy = pSurfaceGlobal->wHeight;
1213
1214 if (pDev->ulBitCount == 8)
1215 {
1216 ulBitmapType = BMF_8BPP;
1217 flHooks = HOOKS_BMF8BPP;
1218 }
1219 else if (pDev->ulBitCount == 16)
1220 {
1221 ulBitmapType = BMF_16BPP;
1222 flHooks = HOOKS_BMF16BPP;
1223 }
1224 else if (pDev->ulBitCount == 24)
1225 {
1226 ulBitmapType = BMF_24BPP;
1227 flHooks = HOOKS_BMF24BPP;
1228 }
1229 else
1230 {
1231 ulBitmapType = BMF_32BPP;
1232 flHooks = HOOKS_BMF32BPP;
1233 }
1234
1235 /* Create a bitmap that represents the DDRAW bits.
1236 * Important is to calculate the address of the bitmap.
1237 */
1238 hbmDevice = EngCreateBitmap(sizel,
1239 pSurfaceGlobal->lPitch,
1240 ulBitmapType,
1241 (pDev->lDeltaScreen > 0) ? BMF_TOPDOWN : 0,
1242 (PVOID) (pDev->pjScreen + pSurfaceGlobal->fpVidMem));
1243 if (hbmDevice)
1244 {
1245 if (pSurfaceGlobal->fpVidMem == 0)
1246 {
1247 /* Screen surface, mark it so it will be recognized by the driver.
1248 * and so the driver will be called on any operations on the surface
1249 * (required for VBVA and VRDP).
1250 */
1251 if (EngAssociateSurface((HSURF)hbmDevice, pDev->hdevEng, flHooks))
1252 {
1253 SURFOBJ *surfobj = EngLockSurface ((HSURF)hbmDevice);
1254 DISPDBG((0, "DrvDeriveSurface surfobj %x, hsurf = %x\n", surfobj, surfobj->hsurf));
1255
1256 surfobj->dhpdev = (DHPDEV)pDev;
1257
1258 EngUnlockSurface(surfobj);
1259
1260 DISPDBG((0, "DrvDeriveSurface return succeed %x at %x\n", hbmDevice, pSurfaceGlobal->fpVidMem));
1261 return(hbmDevice);
1262 }
1263 }
1264 else
1265 {
1266 DISPDBG((0, "DrvDeriveSurface return succeed %x at %x\n", hbmDevice, pSurfaceGlobal->fpVidMem));
1267 return(hbmDevice);
1268 }
1269
1270 DISPDBG((0, "DrvDeriveSurface: EngAssociateSurface failed\n"));
1271 EngDeleteSurface((HSURF)hbmDevice);
1272 }
1273 }
1274
1275 DISPDBG((0, "DrvDeriveSurface return NULL\n"));
1276 DISPDBG((0, "pSurfaceGlobal->ddpfSurface.dwRGBBitCount = %d, lPitch =%ld\n", pSurfaceGlobal->ddpfSurface.dwRGBBitCount,pSurfaceGlobal->lPitch));
1277
1278 return(0);
1279}
1280#endif /* VBOX_WITH_DDRAW */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette