VirtualBox

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

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

Completed DrvDeriveSurface

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