VirtualBox

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

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

Paranoia

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