VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.c@ 3395

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

compile fix

File size: 23.5 KB
Line 
1#ifdef VBOX_WITH_DDRAW
2
3/******************************Module*Header**********************************\
4*
5* **************************
6* * DirectDraw SAMPLE CODE *
7* **************************
8*
9* Module Name: ddenable.c
10*
11* Content:
12*
13* Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
14* Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved.
15\*****************************************************************************/
16
17#ifdef DEBUG
18#define LOG_ENABLED
19#endif
20
21#include "driver.h"
22#include "dd.h"
23#undef CO_E_NOTINITIALIZED
24#include <winerror.h>
25
26
27#if 0
28static DWORD APIENTRY DdCreateSurface(PDD_CREATESURFACEDATA lpCreateSurface);
29#endif
30
31
32/**
33 * DrvGetDirectDrawInfo
34 *
35 * The DrvGetDirectDrawInfo function returns the capabilities of the graphics hardware.
36 *
37 * Parameters:
38 *
39 * dhpdev
40 * Handle to the PDEV returned by the driver’s DrvEnablePDEV routine.
41 * pHalInfo
42 * Points to a DD_HALINFO structure in which the driver should return the hardware capabilities that it supports.
43 * pdwNumHeaps
44 * Points to the location in which the driver should return the number of VIDEOMEMORY structures pointed to by pvmList.
45 * pvmList
46 * Points to an array of VIDEOMEMORY structures in which the driver should return information about each display memory chunk that it controls. The driver should ignore this parameter when it is NULL.
47 * pdwNumFourCCCodes
48 * Points to the location in which the driver should return the number of DWORDs pointed to by pdwFourCC.
49 * pdwFourCC
50 * Points to an array of DWORDs in which the driver should return information about each FOURCC that it supports. The driver should ignore this parameter when it is NULL.
51 *
52 * Return Value:
53 *
54 * DrvGetDirectDrawInfo returns TRUE if it succeeds; otherwise, it returns FALSE.
55 *
56 */
57BOOL APIENTRY DrvGetDirectDrawInfo(
58 DHPDEV dhpdev,
59 DD_HALINFO *pHalInfo,
60 DWORD *pdwNumHeaps,
61 VIDEOMEMORY *pvmList,
62 DWORD *pdwNumFourCCCodes,
63 DWORD *pdwFourCC
64 )
65{
66 PPDEV pDev = (PPDEV)dhpdev;
67
68 DISPDBG((0, "%s: %p, %p, %p, %p, %p. %p\n", __FUNCTION__, dhpdev, pHalInfo, pdwNumHeaps, pvmList, pdwNumFourCCCodes, pdwFourCC));
69
70 *pdwNumFourCCCodes = 0;
71 *pdwNumHeaps = 0;
72
73 /* Setup the HAL driver caps. */
74 pHalInfo->dwSize = sizeof(DD_HALINFO);
75 pHalInfo->dwFlags = 0;
76
77 if (!(pvmList && pdwFourCC))
78 {
79 /* Create primary surface attributes */
80 pHalInfo->vmiData.pvPrimary = pDev->pjScreen;
81 pHalInfo->vmiData.fpPrimary = 0;
82 pHalInfo->vmiData.dwDisplayWidth = pDev->cxScreen;
83 pHalInfo->vmiData.dwDisplayHeight = pDev->cyScreen;
84 pHalInfo->vmiData.lDisplayPitch = pDev->lDeltaScreen;
85
86 pHalInfo->vmiData.ddpfDisplay.dwSize = sizeof(DDPIXELFORMAT);
87 pHalInfo->vmiData.ddpfDisplay.dwFlags = DDPF_RGB;
88 pHalInfo->vmiData.ddpfDisplay.dwRGBBitCount = pDev->ulBitCount;
89 DISPDBG((0, "pvPrimary %x\n", pHalInfo->vmiData.pvPrimary));
90 DISPDBG((0, "fpPrimary %x\n", pHalInfo->vmiData.fpPrimary));
91 DISPDBG((0, "dwDisplayWidth %d\n", pHalInfo->vmiData.dwDisplayWidth));
92 DISPDBG((0, "dwDisplayHeight %d\n", pHalInfo->vmiData.dwDisplayHeight));
93 DISPDBG((0, "lDisplayPitch %d\n", pHalInfo->vmiData.lDisplayPitch));
94 DISPDBG((0, "dwRGBBitCount %d\n", pHalInfo->vmiData.ddpfDisplay.dwRGBBitCount));
95
96 if (pDev->ulBitmapType == BMF_8BPP)
97 {
98 pHalInfo->vmiData.ddpfDisplay.dwFlags |= DDPF_PALETTEINDEXED8;
99 DISPDBG((0, "DDPF_PALETTEINDEXED8\n"));
100 }
101
102 pHalInfo->vmiData.ddpfDisplay.dwRBitMask = pDev->flRed;
103 pHalInfo->vmiData.ddpfDisplay.dwGBitMask = pDev->flGreen;
104 pHalInfo->vmiData.ddpfDisplay.dwBBitMask = pDev->flBlue;
105
106 pHalInfo->vmiData.dwOffscreenAlign = 4;
107 pHalInfo->vmiData.dwZBufferAlign = 4;
108 pHalInfo->vmiData.dwTextureAlign = 4;
109 }
110 memset(&pHalInfo->ddCaps, 0, sizeof(DDNTCORECAPS));
111 pHalInfo->ddCaps.dwSize = sizeof(DDNTCORECAPS);
112 pHalInfo->ddCaps.dwVidMemTotal = pDev->cScreenSize;
113 pHalInfo->ddCaps.dwVidMemFree = pDev->cScreenSize;
114
115 pHalInfo->ddCaps.dwCaps = 0;
116 pHalInfo->ddCaps.dwCaps2 = 0;
117
118 /* Declare we can handle textures wider than the primary */
119 pHalInfo->ddCaps.dwCaps2 |= DDCAPS2_WIDESURFACES;
120
121 pHalInfo->ddCaps.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
122
123 /* DX5 and up */
124 pHalInfo->GetDriverInfo = DdGetDriverInfo;
125 pHalInfo->dwFlags |= DDHALINFO_GETDRIVERINFOSET;
126
127#if 0
128 /* No 3D capabilities */
129 if (pHalInfo->lpD3DGlobalDriverData)
130 {
131 LPD3DHAL_GLOBALDRIVERDATA lpD3DGlobalDriverData = (LPD3DHAL_GLOBALDRIVERDATA)pHalInfo->lpD3DGlobalDriverData;
132 lpD3DGlobalDriverData->dwSize = sizeof(D3DHAL_GLOBALDRIVERDATA);
133 }
134#endif
135 return TRUE;
136}
137
138/**
139 * DrvEnableDirectDraw
140 *
141 * The DrvEnableDirectDraw function enables hardware for DirectDraw use.
142 *
143 * Parameters
144 *
145 * dhpdev
146 * Handle to the PDEV returned by the driver’s DrvEnablePDEV routine.
147 * pCallBacks
148 * Points to the DD_CALLBACKS structure to be initialized by the driver.
149 * pSurfaceCallBacks
150 * Points to the DD_SURFACECALLBACKS structure to be initialized by the driver.
151 * pPaletteCallBacks
152 * Points to the DD_PALETTECALLBACKS structure to be initialized by the driver.
153 *
154 * Return Value
155 *
156 * DrvEnableDirectDraw returns TRUE if it succeeds; otherwise, it returns FALSE.
157 *
158 */
159BOOL APIENTRY DrvEnableDirectDraw(
160 DHPDEV dhpdev,
161 DD_CALLBACKS *pCallBacks,
162 DD_SURFACECALLBACKS *pSurfaceCallBacks,
163 DD_PALETTECALLBACKS *pPaletteCallBacks
164 )
165{
166 DISPDBG((0, "%s: %p, %p, %p, %p\n", __FUNCTION__, dhpdev, pCallBacks, pSurfaceCallBacks, pPaletteCallBacks));
167
168 /* Fill in the HAL Callback pointers */
169 pCallBacks->dwSize = sizeof(DD_CALLBACKS);
170 pCallBacks->dwFlags = DDHAL_CB32_CREATESURFACE | DDHAL_CB32_CANCREATESURFACE;
171 pCallBacks->CreateSurface = DdCreateSurface;
172 pCallBacks->CanCreateSurface = DdCanCreateSurface;
173
174 /*
175 pCallBacks->WaitForVerticalBlank = DdWaitForVerticalBlank;
176 pCallBacks->GetScanLine = DdGetScanLine;
177 pCallBacks->MapMemory = DdMapMemory;
178 DDHAL_CB32_WAITFORVERTICALBLANK | DDHAL_CB32_MAPMEMORY | DDHAL_CB32_GETSCANLINE
179 */
180 /* Note: pCallBacks->SetMode & pCallBacks->DestroyDriver are unused in Windows 2000 and up */
181
182 /* Fill in the Surface Callback pointers */
183 pSurfaceCallBacks->dwSize = sizeof(DD_SURFACECALLBACKS);
184 pSurfaceCallBacks->dwFlags = DDHAL_SURFCB32_DESTROYSURFACE | DDHAL_SURFCB32_LOCK; // DDHAL_SURFCB32_UNLOCK;
185 pSurfaceCallBacks->DestroySurface = DdDestroySurface;
186// pSurfaceCallBacks->Lock = DdLock;
187 pSurfaceCallBacks->Unlock = DdUnlock;
188
189 /*
190 pSurfaceCallBacks->Flip = DdFlip;
191 pSurfaceCallBacks->GetBltStatus = DdGetBltStatus;
192 pSurfaceCallBacks->GetFlipStatus = DdGetFlipStatus;
193 pSurfaceCallBacks->Blt = DdBlt;
194 DDHAL_SURFCB32_FLIP | DDHAL_SURFCB32_BLT | DDHAL_SURFCB32_GETBLTSTATUS | DDHAL_SURFCB32_GETFLIPSTATUS;
195 */
196
197// pSurfaceCallBacks.SetColorKey = DdSetColorKey;
198// pSurfaceCallBacks.dwFlags |= DDHAL_SURFCB32_SETCOLORKEY;
199
200 /* Fill in the Palette Callback pointers */
201 pPaletteCallBacks->dwSize = sizeof(DD_PALETTECALLBACKS);
202 pPaletteCallBacks->dwFlags = 0;
203
204 return TRUE;
205}
206
207/**
208 * DrvDisableDirectDraw
209 *
210 * The DrvDisableDirectDraw function disables hardware for DirectDraw use.
211 *
212 * Parameters
213 *
214 * dhpdev
215 * Handle to the PDEV returned by the driver’s DrvEnablePDEV routine.
216 *
217 */
218VOID APIENTRY DrvDisableDirectDraw( DHPDEV dhpdev)
219{
220 DISPDBG((0, "%s: %p\n", __FUNCTION__, dhpdev));
221}
222
223/**
224 * DdGetDriverInfo
225 *
226 * The DdGetDriverInfo function queries the driver for additional DirectDraw and Direct3D functionality that the driver supports.
227 *
228 * Parameters
229 * lpGetDriverInfo
230 * Points to a DD_GETDRIVERINFODATA structure that contains the information required to perform the query.
231 *
232 * Return Value
233 *
234 * DdGetDriverInfo must return DDHAL_DRIVER_HANDLED.
235 *
236 */
237DWORD CALLBACK DdGetDriverInfo(DD_GETDRIVERINFODATA *lpData)
238{
239 PPDEV pDev = (PPDEV)lpData->dhpdev;
240 DWORD dwSize;
241
242 DISPDBG((0, "%s: %p\n", __FUNCTION__, lpData->dhpdev));
243
244 /* Default to 'not supported' */
245 lpData->ddRVal = DDERR_CURRENTLYNOTAVAIL;
246
247 /* Fill in supported stuff */
248 if (IsEqualIID(&lpData->guidInfo, &GUID_D3DCallbacks3))
249 {
250 DISPDBG((0, " -> GUID_D3DCallbacks3\n"));
251 }
252 else
253 if (IsEqualIID(&lpData->guidInfo, &GUID_D3DExtendedCaps))
254 {
255 DISPDBG((0, " -> GUID_D3DExtendedCaps\n"));
256 }
257 else
258 if (IsEqualIID(&lpData->guidInfo, &GUID_ZPixelFormats))
259 {
260 DISPDBG((0, " -> GUID_ZPixelFormats\n"));
261 }
262 else
263 if (IsEqualIID(&(lpData->guidInfo), &GUID_D3DParseUnknownCommandCallback))
264 {
265 DISPDBG((0, " -> GUID_D3DParseUnknownCommandCallback\n"));
266 }
267 else
268 if (IsEqualIID(&(lpData->guidInfo), &GUID_Miscellaneous2Callbacks))
269 {
270 DISPDBG((0, " -> GUID_Miscellaneous2Callbacks\n"));
271 }
272 else
273 if (IsEqualIID(&(lpData->guidInfo), &GUID_UpdateNonLocalHeap))
274 {
275 DISPDBG((0, " -> GUID_UpdateNonLocalHeap\n"));
276 }
277 else
278 if (IsEqualIID(&(lpData->guidInfo), &GUID_GetHeapAlignment))
279 {
280 DISPDBG((0, " -> GUID_GetHeapAlignment\n"));
281 }
282 else
283 if (IsEqualIID(&(lpData->guidInfo), &GUID_NTPrivateDriverCaps))
284 {
285 DD_NTPRIVATEDRIVERCAPS DDPrivateDriverCaps;
286
287 DISPDBG((0, " -> GUID_NTPrivateDriverCaps\n"));
288
289 memset(&DDPrivateDriverCaps, 0, sizeof(DDPrivateDriverCaps));
290 DDPrivateDriverCaps.dwSize=sizeof(DDPrivateDriverCaps);
291
292 DDPrivateDriverCaps.dwPrivateCaps = 0; /* DDHAL_PRIVATECAP_NOTIFYPRIMARYCREATION -> call CreateSurface for the primary surface */
293
294 lpData->dwActualSize =sizeof(DDPrivateDriverCaps);
295
296 dwSize = min(sizeof(DDPrivateDriverCaps),lpData->dwExpectedSize);
297 memcpy(lpData->lpvData, &DDPrivateDriverCaps, dwSize);
298 lpData->ddRVal = DD_OK;
299 }
300 else
301 if (IsEqualIID(&(lpData->guidInfo), &GUID_DDMoreSurfaceCaps))
302 {
303 DD_MORESURFACECAPS DDMoreSurfaceCaps;
304 DDSCAPSEX ddsCapsEx, ddsCapsExAlt;
305
306 DISPDBG((0, " -> GUID_DDMoreSurfaceCaps\n"));
307
308 // fill in everything until expectedsize...
309 memset(&DDMoreSurfaceCaps, 0, sizeof(DDMoreSurfaceCaps));
310
311 // Caps for heaps 2..n
312 memset(&ddsCapsEx, 0, sizeof(ddsCapsEx));
313 memset(&ddsCapsExAlt, 0, sizeof(ddsCapsEx));
314
315 DDMoreSurfaceCaps.dwSize=lpData->dwExpectedSize;
316
317 lpData->dwActualSize = lpData->dwExpectedSize;
318
319 dwSize = min(sizeof(DDMoreSurfaceCaps),lpData->dwExpectedSize);
320 memcpy(lpData->lpvData, &DDMoreSurfaceCaps, dwSize);
321
322 // now fill in other heaps...
323 while (dwSize < lpData->dwExpectedSize)
324 {
325 memcpy( (PBYTE)lpData->lpvData+dwSize,
326 &ddsCapsEx,
327 sizeof(DDSCAPSEX));
328 dwSize += sizeof(DDSCAPSEX);
329 memcpy( (PBYTE)lpData->lpvData+dwSize,
330 &ddsCapsExAlt,
331 sizeof(DDSCAPSEX));
332 dwSize += sizeof(DDSCAPSEX);
333 }
334
335 lpData->ddRVal = DD_OK;
336 }
337 else
338 if (IsEqualIID(&(lpData->guidInfo), &GUID_DDStereoMode))
339 {
340 DISPDBG((0, " -> GUID_DDStereoMode\n"));
341 }
342 else
343 if (IsEqualIID(&(lpData->guidInfo), &GUID_NonLocalVidMemCaps))
344 {
345 DISPDBG((0, " -> GUID_NonLocalVidMemCaps\n"));
346 }
347 else
348 if (IsEqualIID(&lpData->guidInfo, &GUID_NTCallbacks))
349 {
350 DD_NTCALLBACKS NtCallbacks;
351
352 DISPDBG((0, " -> GUID_NTCallbacks\n"));
353 memset(&NtCallbacks, 0, sizeof(NtCallbacks));
354
355 dwSize = min(lpData->dwExpectedSize, sizeof(DD_NTCALLBACKS));
356
357 NtCallbacks.dwSize = dwSize;
358 NtCallbacks.dwFlags = DDHAL_NTCB32_FREEDRIVERMEMORY
359 | DDHAL_NTCB32_SETEXCLUSIVEMODE
360 | DDHAL_NTCB32_FLIPTOGDISURFACE
361 ;
362 NtCallbacks.FreeDriverMemory = DdFreeDriverMemory;
363 NtCallbacks.SetExclusiveMode = DdSetExclusiveMode;
364 NtCallbacks.FlipToGDISurface = DdFlipToGDISurface;
365
366 memcpy(lpData->lpvData, &NtCallbacks, dwSize);
367
368 lpData->ddRVal = DD_OK;
369 }
370 else
371 if (IsEqualIID(&lpData->guidInfo, &GUID_KernelCaps))
372 {
373 DISPDBG((0, " -> GUID_KernelCaps\n"));
374 }
375 else
376 if (IsEqualIID(&lpData->guidInfo, &GUID_KernelCallbacks))
377 {
378 DISPDBG((0, " -> GUID_KernelCallbacks\n"));
379 }
380 else
381 if (IsEqualIID(&lpData->guidInfo, &GUID_MotionCompCallbacks))
382 {
383 DISPDBG((0, " -> GUID_MotionCompCallbacks\n"));
384 }
385 else
386 if (IsEqualIID(&lpData->guidInfo, &GUID_VideoPortCallbacks))
387 {
388 DISPDBG((0, " -> GUID_VideoPortCallbacks\n"));
389 }
390 else
391 if (IsEqualIID(&lpData->guidInfo, &GUID_ColorControlCallbacks))
392 {
393 DISPDBG((0, " -> GUID_ColorControlCallbacks\n"));
394 }
395 else
396 if (IsEqualIID(&lpData->guidInfo, &GUID_VideoPortCaps))
397 {
398 DISPDBG((0, " -> GUID_VideoPortCaps\n"));
399 }
400 else
401 if (IsEqualIID(&lpData->guidInfo, &GUID_D3DCallbacks2))
402 {
403 DISPDBG((0, " -> GUID_D3DCallbacks2\n"));
404 }
405 else
406 if (IsEqualIID(&lpData->guidInfo, &GUID_D3DCallbacks3))
407 {
408 DISPDBG((0, " -> GUID_D3DCallbacks3\n"));
409 }
410
411 /* Always return this */
412 return DDHAL_DRIVER_HANDLED;
413}
414
415/**
416 * DdCreateSurface
417 *
418 * The DdCreateSurface callback function creates a DirectDraw surface.
419 *
420 * lpCreateSurface
421 * Points to a DD_CREATESURFACEDATA structure that contains the information required to create a surface.
422 *
423 * Return Value
424 *
425 * DdCreateSurface returns one of the following callback codes:
426 * DDHAL_DRIVER_HANDLED
427 * DDHAL_DRIVER_NOTHANDLED
428 *
429 */
430DWORD APIENTRY DdCreateSurface(PDD_CREATESURFACEDATA lpCreateSurface)
431{
432 PPDEV pDev = (PPDEV)lpCreateSurface->lpDD->dhpdev;
433 DD_SURFACE_LOCAL* lpSurfaceLocal;
434 DD_SURFACE_GLOBAL* lpSurfaceGlobal;
435 LPDDSURFACEDESC lpSurfaceDesc;
436 LONG lPitch, lBpp;
437
438 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
439
440 lpSurfaceLocal = lpCreateSurface->lplpSList[0];
441 lpSurfaceGlobal = lpSurfaceLocal->lpGbl;
442 lpSurfaceDesc = lpCreateSurface->lpDDSurfaceDesc;
443
444 lpSurfaceGlobal->dwReserved1 = 0;
445
446 if (lpSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED4)
447 {
448 lBpp = 4;
449 lPitch = lpSurfaceGlobal->wWidth/2;
450 lPitch = (lPitch + 31) & ~31;
451 }
452 else
453 if (lpSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
454 {
455 lBpp = 8;
456 lPitch = lpSurfaceGlobal->wWidth;
457 lPitch = (lPitch + 31) & ~31;
458 }
459 else
460 {
461 lBpp = lpSurfaceDesc->ddpfPixelFormat.dwRGBBitCount;
462 lPitch = lpSurfaceGlobal->wWidth*(lBpp/8);
463 }
464 DISPDBG((0, "New surface (%d,%d)\n", lpSurfaceGlobal->wWidth, lpSurfaceGlobal->wHeight));
465 DISPDBG((0, "BPP %d lPitch=%d\n", lBpp, lPitch));
466
467 lpSurfaceGlobal->dwBlockSizeX = lPitch * lpSurfaceGlobal->wHeight;
468 lpSurfaceGlobal->dwBlockSizeY = 1;
469 lpSurfaceGlobal->lPitch = lPitch;
470
471 //
472 // Modify surface descriptions as appropriate and let Direct
473 // Draw perform the allocation if the surface was not the primary
474 //
475 if (lpSurfaceLocal->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
476 {
477 DISPDBG((0, "-> primary surface\n"));
478 lpSurfaceGlobal->fpVidMem = 0;
479 }
480 else
481 {
482 DISPDBG((0, "-> secondary surface\n"));
483 lpSurfaceGlobal->dwUserMemSize = lPitch * (DWORD)(lpSurfaceGlobal->wHeight);
484 lpSurfaceGlobal->fpVidMem = DDHAL_PLEASEALLOC_BLOCKSIZE;
485 }
486
487 lpSurfaceDesc->lPitch = lpSurfaceGlobal->lPitch;
488 lpSurfaceDesc->dwFlags |= DDSD_PITCH;
489
490
491 return DDHAL_DRIVER_NOTHANDLED;
492}
493
494/**
495 * DdCanCreateSurface
496 *
497 * The DdCanCreateSurface callback function indicates whether the driver can create a surface of the specified surface description.
498 *
499 *
500 * Parameters
501 * lpCanCreateSurface
502 * Points to the DD_CANCREATESURFACEDATA structure containing the information required for the driver to determine whether a surface can be created.
503 *
504 * Return Value
505 *
506 * DdCanCreateSurface returns one of the following callback codes:
507 *
508 * DDHAL_DRIVER_HANDLED
509 * DDHAL_DRIVER_NOTHANDLED
510 *
511 */
512DWORD APIENTRY DdCanCreateSurface(PDD_CANCREATESURFACEDATA lpCanCreateSurface)
513{
514 PPDEV pDev = (PPDEV)lpCanCreateSurface->lpDD->dhpdev;
515
516 PDD_SURFACEDESC lpDDS = lpCanCreateSurface->lpDDSurfaceDesc;
517
518 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
519
520 if (lpDDS->ddsCaps.dwCaps & DDSCAPS_ZBUFFER)
521 {
522 DISPDBG((0, "No Z-Bufer support\n"));
523 lpCanCreateSurface->ddRVal = DDERR_INVALIDPIXELFORMAT;
524 return DDHAL_DRIVER_HANDLED;
525 }
526 if (lpDDS->ddsCaps.dwCaps & DDSCAPS_TEXTURE)
527 {
528 DISPDBG((0, "No texture support\n"));
529 lpCanCreateSurface->ddRVal = DDERR_INVALIDPIXELFORMAT;
530 return DDHAL_DRIVER_HANDLED;
531 }
532
533 if (lpCanCreateSurface->bIsDifferentPixelFormat && (lpDDS->ddpfPixelFormat.dwFlags & DDPF_FOURCC))
534 {
535 DISPDBG((0, "FOURCC not supported\n"));
536 lpCanCreateSurface->ddRVal = DDERR_INVALIDPIXELFORMAT;
537 return DDHAL_DRIVER_HANDLED;
538 }
539
540 lpCanCreateSurface->ddRVal = DD_OK;
541 return DDHAL_DRIVER_HANDLED;
542}
543
544/**
545 * DdLock
546 *
547 * The DdLock callback function locks a specified area of surface memory and provides a valid pointer to a block of memory associated with a surface.
548 *
549 * Parameters
550 * lpLock
551 * Points to a DD_LOCKDATA structure that contains the information required to perform the lockdown.
552 *
553 * Return Value
554 *
555 * DdLock returns one of the following callback codes:
556 *
557 * DDHAL_DRIVER_HANDLED
558 * DDHAL_DRIVER_NOTHANDLED
559 *
560 */
561DWORD APIENTRY DdLock(PDD_LOCKDATA lpLock)
562{
563 PPDEV pDev = (PPDEV)lpLock->lpDD->dhpdev;
564
565 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
566
567 // Because we correctly set 'fpVidMem' to be the offset into our frame
568 // buffer when we created the surface, DirectDraw will automatically take
569 // care of adding in the user-mode frame buffer address if we return
570 // DDHAL_DRIVER_NOTHANDLED:
571 return DDHAL_DRIVER_NOTHANDLED;
572}
573
574/**
575 * DdUnlock
576 *
577 * The DdUnLock callback function releases the lock held on the specified surface.
578 *
579 * Parameters
580 * lpUnlock
581 * Points to a DD_UNLOCKDATA structure that contains the information required to perform the lock release. *
582 *
583 * Return Value
584 *
585 * DdLock returns one of the following callback codes:
586 *
587 * DDHAL_DRIVER_HANDLED
588 * DDHAL_DRIVER_NOTHANDLED
589 *
590 */
591DWORD APIENTRY DdUnlock(PDD_UNLOCKDATA lpUnlock)
592{
593 PPDEV pDev = (PPDEV)lpUnlock->lpDD->dhpdev;
594 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
595
596 return DDHAL_DRIVER_NOTHANDLED;
597}
598
599/**
600 * DdDestroySurface
601 *
602 * The DdDestroySurface callback function destroys a DirectDraw surface.
603 *
604 * Parameters
605 * lpDestroySurface
606 * Points to a DD_DESTROYSURFACEDATA structure that contains the information needed to destroy a surface.
607 *
608 * Return Value
609 *
610 * DdDestroySurface returns one of the following callback codes:
611 *
612 * DDHAL_DRIVER_HANDLED
613 * DDHAL_DRIVER_NOTHANDLED
614 *
615 */
616DWORD APIENTRY DdDestroySurface(PDD_DESTROYSURFACEDATA lpDestroySurface)
617{
618 PPDEV pDev = (PPDEV)lpDestroySurface->lpDD->dhpdev;
619 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
620
621 lpDestroySurface->ddRVal = DD_OK;
622 return DDHAL_DRIVER_HANDLED;
623}
624
625
626//-----------------------------------------------------------------------------
627//
628// DdSetExclusiveMode
629//
630// This function is called by DirectDraw when we switch from the GDI surface,
631// to DirectDraw exclusive mode, e.g. to run a game in fullcreen mode.
632// You only need to implement this function when you are using the
633// 'HeapVidMemAllocAligned' function and allocate memory for Device Bitmaps
634// and DirectDraw surfaces from the same heap.
635//
636// We use this call to disable GDI DeviceBitMaps when we are running in
637// DirectDraw exclusive mode. Otherwise a DD app gets confused if both GDI and
638// DirectDraw allocate memory from the same heap.
639//
640// See also DdFlipToGDISurface.
641//
642//-----------------------------------------------------------------------------
643
644
645DWORD APIENTRY DdSetExclusiveMode(PDD_SETEXCLUSIVEMODEDATA lpSetExclusiveMode)
646{
647 PPDEV pDev = (PPDEV)lpSetExclusiveMode->lpDD->dhpdev;
648 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
649
650 // remember setting of exclusive mode in ppdev,
651 // so GDI can stop to promote DeviceBitmaps into
652 // video memory
653
654 pDev->bDdExclusiveMode = lpSetExclusiveMode->dwEnterExcl;
655
656 lpSetExclusiveMode->ddRVal = DD_OK;
657
658 return DDHAL_DRIVER_HANDLED;
659}
660
661//-----------------------------------------------------------------------------
662//
663// DWORD DdFlipToGDISurface
664//
665// This function is called by DirectDraw when it flips to the surface on which
666// GDI can write to.
667//
668//-----------------------------------------------------------------------------
669
670DWORD APIENTRY DdFlipToGDISurface(PDD_FLIPTOGDISURFACEDATA lpFlipToGDISurface)
671{
672 PPDEV pDev = (PPDEV)lpFlipToGDISurface->lpDD->dhpdev;
673 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
674
675 pDev->dwNewDDSurfaceOffset = 0xffffffff;
676
677 lpFlipToGDISurface->ddRVal = DD_OK;
678
679 //
680 // we return NOTHANDLED, then the ddraw runtime takes
681 // care that we flip back to the primary...
682 //
683 return DDHAL_DRIVER_NOTHANDLED;
684}
685//-----------------------------------------------------------------------------
686//
687// DWORD DdFreeDriverMemory
688//
689// This function called by DirectDraw when it's running low on memory in
690// our heap. You only need to implement this function if you use the
691// DirectDraw 'HeapVidMemAllocAligned' function in your driver, and you
692// can boot those allocations out of memory to make room for DirectDraw.
693//
694// We implement this function in the P2 driver because we have DirectDraw
695// entirely manage our off-screen heap, and we use HeapVidMemAllocAligned
696// to put GDI device-bitmaps in off-screen memory. DirectDraw applications
697// have a higher priority for getting stuff into video memory, though, and
698// so this function is used to boot those GDI surfaces out of memory in
699// order to make room for DirectDraw.
700//
701//-----------------------------------------------------------------------------
702
703DWORD APIENTRY DdFreeDriverMemory(PDD_FREEDRIVERMEMORYDATA lpFreeDriverMemory)
704{
705 PPDEV pDev = (PPDEV)lpFreeDriverMemory->lpDD->dhpdev;
706 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
707
708 lpFreeDriverMemory->ddRVal = DDERR_OUTOFMEMORY;
709 return (DDHAL_DRIVER_HANDLED);
710}
711
712
713#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