VirtualBox

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

Last change on this file since 4259 was 4259, checked in by vboxsync, 18 years ago

compile fix

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

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