Changeset 3394 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Jul 3, 2007 4:24:33 PM (18 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Display
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.c
r3389 r3394 19 19 #include "driver.h" 20 20 #include "dd.h" 21 #undef CO_E_NOTINITIALIZED 22 #include <winerror.h> 23 21 24 22 25 #if 0 23 26 static DWORD APIENTRY DdCreateSurface(PDD_CREATESURFACEDATA lpCreateSurface); 24 27 #endif 28 25 29 26 30 /** … … 77 81 pHalInfo->vmiData.dwDisplayHeight = pDev->cyScreen; 78 82 pHalInfo->vmiData.lDisplayPitch = pDev->lDeltaScreen; 83 79 84 pHalInfo->vmiData.ddpfDisplay.dwSize = sizeof(DDPIXELFORMAT); 80 85 pHalInfo->vmiData.ddpfDisplay.dwFlags = DDPF_RGB; … … 107 112 108 113 pHalInfo->ddCaps.dwCaps = 0; 109 pHalInfo->ddCaps.dwCaps2 = DDCAPS2_CERTIFIED; 114 pHalInfo->ddCaps.dwCaps2 = 0; 115 116 /* Declare we can handle textures wider than the primary */ 117 pHalInfo->ddCaps.dwCaps2 |= DDCAPS2_WIDESURFACES; 110 118 111 119 pHalInfo->ddCaps.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; 112 120 113 #if 0114 121 /* DX5 and up */ 115 122 pHalInfo->GetDriverInfo = DdGetDriverInfo; 116 123 pHalInfo->dwFlags |= DDHALINFO_GETDRIVERINFOSET; 117 #endif 118 124 125 #if 0 119 126 /* No 3D capabilities */ 120 #if 0121 127 if (pHalInfo->lpD3DGlobalDriverData) 122 128 { … … 125 131 } 126 132 #endif 127 128 133 return TRUE; 129 134 } … … 161 166 /* Fill in the HAL Callback pointers */ 162 167 pCallBacks->dwSize = sizeof(DD_CALLBACKS); 163 pCallBacks->dwFlags = 0; 164 165 /* 166 pCallBacks->dwFlags = DDHAL_CB32_CREATESURFACE; 168 pCallBacks->dwFlags = DDHAL_CB32_CREATESURFACE | DDHAL_CB32_CANCREATESURFACE; 167 169 pCallBacks->CreateSurface = DdCreateSurface; 168 170 pCallBacks->CanCreateSurface = DdCanCreateSurface; 171 172 /* 169 173 pCallBacks->WaitForVerticalBlank = DdWaitForVerticalBlank; 170 174 pCallBacks->GetScanLine = DdGetScanLine; 171 175 pCallBacks->MapMemory = DdMapMemory; 172 DDHAL_CB32_ CANCREATESURFACE | DDHAL_CB32_WAITFORVERTICALBLANK | DDHAL_CB32_MAPMEMORY | DDHAL_CB32_GETSCANLINE176 DDHAL_CB32_WAITFORVERTICALBLANK | DDHAL_CB32_MAPMEMORY | DDHAL_CB32_GETSCANLINE 173 177 */ 174 178 /* Note: pCallBacks->SetMode & pCallBacks->DestroyDriver are unused in Windows 2000 and up */ … … 176 180 /* Fill in the Surface Callback pointers */ 177 181 pSurfaceCallBacks->dwSize = sizeof(DD_SURFACECALLBACKS); 178 pSurfaceCallBacks->dwFlags = 0; 182 pSurfaceCallBacks->dwFlags = DDHAL_SURFCB32_DESTROYSURFACE | DDHAL_SURFCB32_LOCK; // DDHAL_SURFCB32_UNLOCK; 183 pSurfaceCallBacks->DestroySurface = DdDestroySurface; 184 // pSurfaceCallBacks->Lock = DdLock; 185 pSurfaceCallBacks->Unlock = DdUnlock; 179 186 180 187 /* 181 pSurfaceCallBacks->dwFlags = DDHAL_SURFCB32_DESTROYSURFACE | DDHAL_SURFCB32_LOCK;182 pSurfaceCallBacks->DestroySurface = DdDestroySurface;183 pSurfaceCallBacks->Lock = DdLock;184 188 pSurfaceCallBacks->Flip = DdFlip; 185 189 pSurfaceCallBacks->GetBltStatus = DdGetBltStatus; … … 215 219 } 216 220 217 218 #if 0 221 /** 222 * DdGetDriverInfo 223 * 224 * The DdGetDriverInfo function queries the driver for additional DirectDraw and Direct3D functionality that the driver supports. 225 * 226 * Parameters 227 * lpGetDriverInfo 228 * Points to a DD_GETDRIVERINFODATA structure that contains the information required to perform the query. 229 * 230 * Return Value 231 * 232 * DdGetDriverInfo must return DDHAL_DRIVER_HANDLED. 233 * 234 */ 235 DWORD CALLBACK DdGetDriverInfo(DD_GETDRIVERINFODATA *lpData) 236 { 237 PPDEV pDev = (PPDEV)lpData->dhpdev; 238 DWORD dwSize; 239 240 DISPDBG((0, "%s: %p\n", __FUNCTION__, lpData->dhpdev)); 241 242 /* Default to 'not supported' */ 243 lpData->ddRVal = DDERR_CURRENTLYNOTAVAIL; 244 245 /* Fill in supported stuff */ 246 if (IsEqualIID(&lpData->guidInfo, &GUID_D3DCallbacks3)) 247 { 248 DISPDBG((0, " -> GUID_D3DCallbacks3\n")); 249 } 250 else 251 if (IsEqualIID(&lpData->guidInfo, &GUID_D3DExtendedCaps)) 252 { 253 DISPDBG((0, " -> GUID_D3DExtendedCaps\n")); 254 } 255 else 256 if (IsEqualIID(&lpData->guidInfo, &GUID_ZPixelFormats)) 257 { 258 DISPDBG((0, " -> GUID_ZPixelFormats\n")); 259 } 260 else 261 if (IsEqualIID(&(lpData->guidInfo), &GUID_D3DParseUnknownCommandCallback)) 262 { 263 DISPDBG((0, " -> GUID_D3DParseUnknownCommandCallback\n")); 264 } 265 else 266 if (IsEqualIID(&(lpData->guidInfo), &GUID_Miscellaneous2Callbacks)) 267 { 268 DISPDBG((0, " -> GUID_Miscellaneous2Callbacks\n")); 269 } 270 else 271 if (IsEqualIID(&(lpData->guidInfo), &GUID_UpdateNonLocalHeap)) 272 { 273 DISPDBG((0, " -> GUID_UpdateNonLocalHeap\n")); 274 } 275 else 276 if (IsEqualIID(&(lpData->guidInfo), &GUID_GetHeapAlignment)) 277 { 278 DISPDBG((0, " -> GUID_GetHeapAlignment\n")); 279 } 280 else 281 if (IsEqualIID(&(lpData->guidInfo), &GUID_NTPrivateDriverCaps)) 282 { 283 DD_NTPRIVATEDRIVERCAPS DDPrivateDriverCaps; 284 285 DISPDBG((0, " -> GUID_NTPrivateDriverCaps\n")); 286 287 memset(&DDPrivateDriverCaps, 0, sizeof(DDPrivateDriverCaps)); 288 DDPrivateDriverCaps.dwSize=sizeof(DDPrivateDriverCaps); 289 290 DDPrivateDriverCaps.dwPrivateCaps = 0; /* DDHAL_PRIVATECAP_NOTIFYPRIMARYCREATION -> call CreateSurface for the primary surface */ 291 292 lpData->dwActualSize =sizeof(DDPrivateDriverCaps); 293 294 dwSize = min(sizeof(DDPrivateDriverCaps),lpData->dwExpectedSize); 295 memcpy(lpData->lpvData, &DDPrivateDriverCaps, dwSize); 296 lpData->ddRVal = DD_OK; 297 } 298 else 299 if (IsEqualIID(&(lpData->guidInfo), &GUID_DDMoreSurfaceCaps)) 300 { 301 DD_MORESURFACECAPS DDMoreSurfaceCaps; 302 DDSCAPSEX ddsCapsEx, ddsCapsExAlt; 303 304 DISPDBG((0, " -> GUID_DDMoreSurfaceCaps\n")); 305 306 // fill in everything until expectedsize... 307 memset(&DDMoreSurfaceCaps, 0, sizeof(DDMoreSurfaceCaps)); 308 309 // Caps for heaps 2..n 310 memset(&ddsCapsEx, 0, sizeof(ddsCapsEx)); 311 memset(&ddsCapsExAlt, 0, sizeof(ddsCapsEx)); 312 313 DDMoreSurfaceCaps.dwSize=lpData->dwExpectedSize; 314 315 lpData->dwActualSize = lpData->dwExpectedSize; 316 317 dwSize = min(sizeof(DDMoreSurfaceCaps),lpData->dwExpectedSize); 318 memcpy(lpData->lpvData, &DDMoreSurfaceCaps, dwSize); 319 320 // now fill in other heaps... 321 while (dwSize < lpData->dwExpectedSize) 322 { 323 memcpy( (PBYTE)lpData->lpvData+dwSize, 324 &ddsCapsEx, 325 sizeof(DDSCAPSEX)); 326 dwSize += sizeof(DDSCAPSEX); 327 memcpy( (PBYTE)lpData->lpvData+dwSize, 328 &ddsCapsExAlt, 329 sizeof(DDSCAPSEX)); 330 dwSize += sizeof(DDSCAPSEX); 331 } 332 333 lpData->ddRVal = DD_OK; 334 } 335 else 336 if (IsEqualIID(&(lpData->guidInfo), &GUID_DDStereoMode)) 337 { 338 DISPDBG((0, " -> GUID_DDStereoMode\n")); 339 } 340 else 341 if (IsEqualIID(&(lpData->guidInfo), &GUID_NonLocalVidMemCaps)) 342 { 343 DISPDBG((0, " -> GUID_NonLocalVidMemCaps\n")); 344 } 345 else 346 if (IsEqualIID(&lpData->guidInfo, &GUID_NTCallbacks)) 347 { 348 DD_NTCALLBACKS NtCallbacks; 349 350 DISPDBG((0, " -> GUID_NTCallbacks\n")); 351 memset(&NtCallbacks, 0, sizeof(NtCallbacks)); 352 353 dwSize = min(lpData->dwExpectedSize, sizeof(DD_NTCALLBACKS)); 354 355 NtCallbacks.dwSize = dwSize; 356 NtCallbacks.dwFlags = DDHAL_NTCB32_FREEDRIVERMEMORY 357 | DDHAL_NTCB32_SETEXCLUSIVEMODE 358 | DDHAL_NTCB32_FLIPTOGDISURFACE 359 ; 360 NtCallbacks.FreeDriverMemory = DdFreeDriverMemory; 361 NtCallbacks.SetExclusiveMode = DdSetExclusiveMode; 362 NtCallbacks.FlipToGDISurface = DdFlipToGDISurface; 363 364 memcpy(lpData->lpvData, &NtCallbacks, dwSize); 365 366 lpData->ddRVal = DD_OK; 367 } 368 else 369 if (IsEqualIID(&lpData->guidInfo, &GUID_KernelCaps)) 370 { 371 DISPDBG((0, " -> GUID_KernelCaps\n")); 372 } 373 else 374 if (IsEqualIID(&lpData->guidInfo, &GUID_KernelCallbacks)) 375 { 376 DISPDBG((0, " -> GUID_KernelCallbacks\n")); 377 } 378 else 379 if (IsEqualIID(&lpData->guidInfo, &GUID_MotionCompCallbacks)) 380 { 381 DISPDBG((0, " -> GUID_MotionCompCallbacks\n")); 382 } 383 else 384 if (IsEqualIID(&lpData->guidInfo, &GUID_VideoPortCallbacks)) 385 { 386 DISPDBG((0, " -> GUID_VideoPortCallbacks\n")); 387 } 388 else 389 if (IsEqualIID(&lpData->guidInfo, &GUID_ColorControlCallbacks)) 390 { 391 DISPDBG((0, " -> GUID_ColorControlCallbacks\n")); 392 } 393 else 394 if (IsEqualIID(&lpData->guidInfo, &GUID_VideoPortCaps)) 395 { 396 DISPDBG((0, " -> GUID_VideoPortCaps\n")); 397 } 398 else 399 if (IsEqualIID(&lpData->guidInfo, &GUID_D3DCallbacks2)) 400 { 401 DISPDBG((0, " -> GUID_D3DCallbacks2\n")); 402 } 403 else 404 if (IsEqualIID(&lpData->guidInfo, &GUID_D3DCallbacks3)) 405 { 406 DISPDBG((0, " -> GUID_D3DCallbacks3\n")); 407 } 408 409 /* Always return this */ 410 return DDHAL_DRIVER_HANDLED; 411 } 412 219 413 /** 220 414 * DdCreateSurface … … 232 426 * 233 427 */ 234 static DWORD APIENTRY DdCreateSurface(PDD_CREATESURFACEDATA lpCreateSurface) 235 { 236 lpCreateSurface->lpDD->fpVidMem = DDHAL_PLEASEALLOC_USERMEM; 428 DWORD APIENTRY DdCreateSurface(PDD_CREATESURFACEDATA lpCreateSurface) 429 { 430 PPDEV pDev = (PPDEV)lpCreateSurface->lpDD->dhpdev; 431 DD_SURFACE_LOCAL* lpSurfaceLocal; 432 DD_SURFACE_GLOBAL* lpSurfaceGlobal; 433 LPDDSURFACEDESC lpSurfaceDesc; 434 LONG lPitch, lBpp; 435 436 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev)); 437 438 lpSurfaceLocal = lpCreateSurface->lplpSList[0]; 439 lpSurfaceGlobal = lpSurfaceLocal->lpGbl; 440 lpSurfaceDesc = lpCreateSurface->lpDDSurfaceDesc; 441 442 lpSurfaceGlobal->dwReserved1 = 0; 443 444 if (lpSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED4) 445 { 446 lBpp = 4; 447 lPitch = lpSurfaceGlobal->wWidth/2; 448 lPitch = (lPitch + 31) & ~31; 449 } 450 else 451 if (lpSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) 452 { 453 lBpp = 8; 454 lPitch = lpSurfaceGlobal->wWidth; 455 lPitch = (lPitch + 31) & ~31; 456 } 457 else 458 { 459 lBpp = lpSurfaceDesc->ddpfPixelFormat.dwRGBBitCount; 460 lPitch = lpSurfaceGlobal->wWidth*(lBpp/8); 461 } 462 DISPDBG((0, "New surface (%d,%d)\n", lpSurfaceGlobal->wWidth, lpSurfaceGlobal->wHeight)); 463 DISPDBG((0, "BPP %d lPitch=%d\n", lBpp, lPitch)); 464 465 lpSurfaceGlobal->dwBlockSizeX = lPitch * lpSurfaceGlobal->wHeight; 466 lpSurfaceGlobal->dwBlockSizeY = 1; 467 lpSurfaceGlobal->lPitch = lPitch; 468 469 // 470 // Modify surface descriptions as appropriate and let Direct 471 // Draw perform the allocation if the surface was not the primary 472 // 473 if (lpSurfaceLocal->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) 474 { 475 DISPDBG((0, "-> primary surface\n")); 476 lpSurfaceGlobal->fpVidMem = 0; 477 } 478 else 479 { 480 DISPDBG((0, "-> secondary surface\n")); 481 lpSurfaceGlobal->dwUserMemSize = lPitch * (DWORD)(lpSurfaceGlobal->wHeight); 482 lpSurfaceGlobal->fpVidMem = DDHAL_PLEASEALLOC_BLOCKSIZE; 483 } 484 485 lpSurfaceDesc->lPitch = lpSurfaceGlobal->lPitch; 486 lpSurfaceDesc->dwFlags |= DDSD_PITCH; 487 237 488 238 489 return DDHAL_DRIVER_NOTHANDLED; 239 490 } 240 #endif 491 492 /** 493 * DdCanCreateSurface 494 * 495 * The DdCanCreateSurface callback function indicates whether the driver can create a surface of the specified surface description. 496 * 497 * 498 * Parameters 499 * lpCanCreateSurface 500 * Points to the DD_CANCREATESURFACEDATA structure containing the information required for the driver to determine whether a surface can be created. 501 * 502 * Return Value 503 * 504 * DdCanCreateSurface returns one of the following callback codes: 505 * 506 * DDHAL_DRIVER_HANDLED 507 * DDHAL_DRIVER_NOTHANDLED 508 * 509 */ 510 DWORD APIENTRY DdCanCreateSurface(PDD_CANCREATESURFACEDATA lpCanCreateSurface) 511 { 512 PPDEV pDev = (PPDEV)lpCanCreateSurface->lpDD->dhpdev; 513 514 PDD_SURFACEDESC lpDDS = lpCanCreateSurface->lpDDSurfaceDesc; 515 516 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev)); 517 518 if (lpDDS->ddsCaps.dwCaps & DDSCAPS_ZBUFFER) 519 { 520 DISPDBG((0, "No Z-Bufer support\n")); 521 lpCanCreateSurface->ddRVal = DDERR_INVALIDPIXELFORMAT; 522 return DDHAL_DRIVER_HANDLED; 523 } 524 if (lpDDS->ddsCaps.dwCaps & DDSCAPS_TEXTURE) 525 { 526 DISPDBG((0, "No texture support\n")); 527 lpCanCreateSurface->ddRVal = DDERR_INVALIDPIXELFORMAT; 528 return DDHAL_DRIVER_HANDLED; 529 } 530 531 if (lpCanCreateSurface->bIsDifferentPixelFormat && (lpDDS->ddpfPixelFormat.dwFlags & DDPF_FOURCC)) 532 { 533 DISPDBG((0, "FOURCC not supported\n")); 534 lpCanCreateSurface->ddRVal = DDERR_INVALIDPIXELFORMAT; 535 return DDHAL_DRIVER_HANDLED; 536 } 537 538 lpCanCreateSurface->ddRVal = DD_OK; 539 return DDHAL_DRIVER_HANDLED; 540 } 541 542 /** 543 * DdLock 544 * 545 * 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. 546 * 547 * Parameters 548 * lpLock 549 * Points to a DD_LOCKDATA structure that contains the information required to perform the lockdown. 550 * 551 * Return Value 552 * 553 * DdLock returns one of the following callback codes: 554 * 555 * DDHAL_DRIVER_HANDLED 556 * DDHAL_DRIVER_NOTHANDLED 557 * 558 */ 559 DWORD APIENTRY DdLock(PDD_LOCKDATA lpLock) 560 { 561 PPDEV pDev = (PPDEV)lpLock->lpDD->dhpdev; 562 563 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev)); 564 565 // Because we correctly set 'fpVidMem' to be the offset into our frame 566 // buffer when we created the surface, DirectDraw will automatically take 567 // care of adding in the user-mode frame buffer address if we return 568 // DDHAL_DRIVER_NOTHANDLED: 569 return DDHAL_DRIVER_NOTHANDLED; 570 } 571 572 /** 573 * DdUnlock 574 * 575 * The DdUnLock callback function releases the lock held on the specified surface. 576 * 577 * Parameters 578 * lpUnlock 579 * Points to a DD_UNLOCKDATA structure that contains the information required to perform the lock release. * 580 * 581 * Return Value 582 * 583 * DdLock returns one of the following callback codes: 584 * 585 * DDHAL_DRIVER_HANDLED 586 * DDHAL_DRIVER_NOTHANDLED 587 * 588 */ 589 DWORD APIENTRY DdUnlock(PDD_UNLOCKDATA lpUnlock) 590 { 591 PPDEV pDev = (PPDEV)lpUnlock->lpDD->dhpdev; 592 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev)); 593 594 return DDHAL_DRIVER_NOTHANDLED; 595 } 596 597 /** 598 * DdDestroySurface 599 * 600 * The DdDestroySurface callback function destroys a DirectDraw surface. 601 * 602 * Parameters 603 * lpDestroySurface 604 * Points to a DD_DESTROYSURFACEDATA structure that contains the information needed to destroy a surface. 605 * 606 * Return Value 607 * 608 * DdDestroySurface returns one of the following callback codes: 609 * 610 * DDHAL_DRIVER_HANDLED 611 * DDHAL_DRIVER_NOTHANDLED 612 * 613 */ 614 DWORD APIENTRY DdDestroySurface(PDD_DESTROYSURFACEDATA lpDestroySurface) 615 { 616 PPDEV pDev = (PPDEV)lpDestroySurface->lpDD->dhpdev; 617 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev)); 618 619 lpDestroySurface->ddRVal = DD_OK; 620 return DDHAL_DRIVER_HANDLED; 621 } 622 623 624 //----------------------------------------------------------------------------- 625 // 626 // DdSetExclusiveMode 627 // 628 // This function is called by DirectDraw when we switch from the GDI surface, 629 // to DirectDraw exclusive mode, e.g. to run a game in fullcreen mode. 630 // You only need to implement this function when you are using the 631 // 'HeapVidMemAllocAligned' function and allocate memory for Device Bitmaps 632 // and DirectDraw surfaces from the same heap. 633 // 634 // We use this call to disable GDI DeviceBitMaps when we are running in 635 // DirectDraw exclusive mode. Otherwise a DD app gets confused if both GDI and 636 // DirectDraw allocate memory from the same heap. 637 // 638 // See also DdFlipToGDISurface. 639 // 640 //----------------------------------------------------------------------------- 641 642 643 DWORD APIENTRY DdSetExclusiveMode(PDD_SETEXCLUSIVEMODEDATA lpSetExclusiveMode) 644 { 645 PPDEV pDev = (PPDEV)lpSetExclusiveMode->lpDD->dhpdev; 646 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev)); 647 648 // remember setting of exclusive mode in ppdev, 649 // so GDI can stop to promote DeviceBitmaps into 650 // video memory 651 652 pDev->bDdExclusiveMode = lpSetExclusiveMode->dwEnterExcl; 653 654 lpSetExclusiveMode->ddRVal = DD_OK; 655 656 return DDHAL_DRIVER_HANDLED; 657 } 658 659 //----------------------------------------------------------------------------- 660 // 661 // DWORD DdFlipToGDISurface 662 // 663 // This function is called by DirectDraw when it flips to the surface on which 664 // GDI can write to. 665 // 666 //----------------------------------------------------------------------------- 667 668 DWORD APIENTRY DdFlipToGDISurface(PDD_FLIPTOGDISURFACEDATA lpFlipToGDISurface) 669 { 670 PPDEV pDev = (PPDEV)lpFlipToGDISurface->lpDD->dhpdev; 671 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev)); 672 673 pDev->dwNewDDSurfaceOffset = 0xffffffff; 674 675 lpFlipToGDISurface->ddRVal = DD_OK; 676 677 // 678 // we return NOTHANDLED, then the ddraw runtime takes 679 // care that we flip back to the primary... 680 // 681 return DDHAL_DRIVER_NOTHANDLED; 682 } 683 //----------------------------------------------------------------------------- 684 // 685 // DWORD DdFreeDriverMemory 686 // 687 // This function called by DirectDraw when it's running low on memory in 688 // our heap. You only need to implement this function if you use the 689 // DirectDraw 'HeapVidMemAllocAligned' function in your driver, and you 690 // can boot those allocations out of memory to make room for DirectDraw. 691 // 692 // We implement this function in the P2 driver because we have DirectDraw 693 // entirely manage our off-screen heap, and we use HeapVidMemAllocAligned 694 // to put GDI device-bitmaps in off-screen memory. DirectDraw applications 695 // have a higher priority for getting stuff into video memory, though, and 696 // so this function is used to boot those GDI surfaces out of memory in 697 // order to make room for DirectDraw. 698 // 699 //----------------------------------------------------------------------------- 700 701 DWORD APIENTRY DdFreeDriverMemory(PDD_FREEDRIVERMEMORYDATA lpFreeDriverMemory) 702 { 703 PPDEV pDev = (PPDEV)lpFreeDriverMemory->lpDD->dhpdev; 704 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev)); 705 706 lpFreeDriverMemory->ddRVal = DDERR_OUTOFMEMORY; 707 return (DDHAL_DRIVER_HANDLED); 708 } 709 -
trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.h
r3375 r3394 28 28 BOOL APIENTRY DrvEnableDirectDraw(DHPDEV dhpdev, DD_CALLBACKS *pCallBacks, DD_SURFACECALLBACKS *pSurfaceCallBacks, DD_PALETTECALLBACKS *pPaletteCallBacks); 29 29 VOID APIENTRY DrvDisableDirectDraw(DHPDEV dhpdev); 30 30 DWORD CALLBACK DdGetDriverInfo(DD_GETDRIVERINFODATA *lpData); 31 DWORD APIENTRY DdCreateSurface(PDD_CREATESURFACEDATA lpCreateSurface); 32 DWORD APIENTRY DdCanCreateSurface(PDD_CANCREATESURFACEDATA lpCanCreateSurface); 33 DWORD APIENTRY DdDestroySurface(PDD_DESTROYSURFACEDATA lpDestroySurface); 34 DWORD APIENTRY DdLock(PDD_LOCKDATA lpLock); 35 DWORD APIENTRY DdUnlock(PDD_UNLOCKDATA lpUnlock); 36 DWORD APIENTRY DdFreeDriverMemory(PDD_FREEDRIVERMEMORYDATA lpFreeDriverMemory); 37 DWORD APIENTRY DdSetExclusiveMode(PDD_SETEXCLUSIVEMODEDATA lpSetExclusiveMode); 38 DWORD APIENTRY DdFlipToGDISurface(PDD_FLIPTOGDISURFACEDATA lpFlipToGDISurface); 39 HBITMAP DrvDeriveSurface(DD_DIRECTDRAW_GLOBAL* pDirectDraw, DD_SURFACE_LOCAL* pSurface); 31 40 32 41 #endif /* __VBOX_DD_H__*/ -
trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h
r3356 r3394 20 20 #include "ntddvdeo.h" 21 21 #include "debug.h" 22 #include "dd.h"23 22 24 23 #include "../Miniport/vboxioctl.h" … … 99 98 VBOXDISPLAYINFO *pInfo; 100 99 ULONG iDevice; 100 #ifdef VBOX_WITH_DDRAW 101 BOOL bDdExclusiveMode; 102 DWORD dwNewDDSurfaceOffset; 103 #endif 101 104 }; 102 105 -
trunk/src/VBox/Additions/WINNT/Graphics/Display/enable.c
r3380 r3394 14 14 15 15 #include "driver.h" 16 #include "dd.h" 16 17 17 18 // The driver function table with all function index/address pairs … … 147 148 { INDEX_DrvEnableDirectDraw, (PFN) DrvEnableDirectDraw }, // 60 0x3c 148 149 { INDEX_DrvDisableDirectDraw, (PFN) DrvDisableDirectDraw }, // 61 0x3d 150 { INDEX_DrvDeriveSurface, (PFN) DrvDeriveSurface }, // 85 149 151 #endif 150 152 { INDEX_DrvNotify, (PFN) DrvNotify }, // 87 0x57 … … 852 854 } 853 855 } 856 857 #ifdef VBOX_WITH_DDRAW 858 //--------------------------Public Routine------------------------------------- 859 // 860 // HBITMAP DrvDeriveSurface 861 // 862 // This function derives and creates a GDI surface from the specified 863 // DirectDraw surface. 864 // 865 // Parameters 866 // pDirectDraw-----Points to a DD_DIRECTDRAW_GLOBAL structure that describes 867 // the DirectDraw object. 868 // pSurface--------Points to a DD_SURFACE_LOCAL structure that describes the 869 // DirectDraw surface around which to wrap a GDI surface. 870 // 871 // Return Value 872 // DrvDeriveSurface returns a handle to the created GDI surface upon success. 873 // It returns NULL if the call fails or if the driver cannot accelerate GDI 874 // drawing to the specified DirectDraw surface. 875 // 876 // Comments 877 // DrvDeriveSurface allows the driver to create a GDI surface around a 878 // DirectDraw video memory or AGP surface object in order to allow accelerated 879 // GDI drawing to the surface. If the driver does not hook this call, all GDI 880 // drawing to DirectDraw surfaces is done in software using the DIB engine. 881 // 882 // GDI calls DrvDeriveSurface with RGB surfaces only. 883 // 884 // The driver should call DrvCreateDeviceBitmap to create a GDI surface of the 885 // same size and format as that of the DirectDraw surface. Space for the 886 // actual pixels need not be allocated since it already exists. 887 // 888 //----------------------------------------------------------------------------- 889 HBITMAP DrvDeriveSurface(DD_DIRECTDRAW_GLOBAL* pDirectDraw, DD_SURFACE_LOCAL* pSurface) 890 { 891 PPDEV pDev = (PPDEV)pDirectDraw->dhpdev; 892 HBITMAP hbmDevice; 893 DD_SURFACE_GLOBAL* pSurfaceGlobal; 894 SIZEL sizl; 895 896 DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev)); 897 898 pSurfaceGlobal = pSurface->lpGbl; 899 900 // 901 // GDI should never call us for a non-RGB surface, but let's assert just 902 // to make sure they're doing their job properly. 903 // 904 AssertMsg(!(pSurfaceGlobal->ddpfSurface.dwFlags & DDPF_FOURCC), ("GDI called us with a non-RGB surface!")); 905 906 907 // The GDI driver does not accelerate surfaces in AGP memory, 908 // thus we fail the call 909 910 if (pSurface->ddsCaps.dwCaps & DDSCAPS_NONLOCALVIDMEM) 911 { 912 DISPDBG((0, "DrvDeriveSurface return NULL, surface in AGP memory")); 913 return 0; 914 } 915 916 // The GDI driver does not accelerate managed surface, 917 // thus we fail the call 918 if (pSurface->lpSurfMore->ddsCapsEx.dwCaps2 & DDSCAPS2_TEXTUREMANAGE) 919 { 920 DISPDBG((0, "DrvDeriveSurface return NULL, surface is managed")); 921 return 0; 922 } 923 924 // 925 // The rest of our driver expects GDI calls to come in with the same 926 // format as the primary surface. So we'd better not wrap a device 927 // bitmap around an RGB format that the rest of our driver doesn't 928 // understand. Also, we must check to see that it is not a surface 929 // whose pitch does not match the primary surface. 930 // 931 // NOTE: Most surfaces created by this driver are allocated as 2D surfaces 932 // whose lPitch's are equal to the screen pitch. However, overlay surfaces 933 // are allocated such that there lPitch's are usually different then the 934 // screen pitch. The hardware can not accelerate drawing operations to 935 // these surfaces and thus we fail to derive these surfaces. 936 // 937 if ( (pSurfaceGlobal->ddpfSurface.dwRGBBitCount == pDev->ulBitCount) ) 938 { 939 SIZEL sizel; 940 DWORD ulBitmapType, flHooks; 941 942 sizl.cx = pSurfaceGlobal->wWidth; 943 sizl.cy = pSurfaceGlobal->wHeight; 944 945 if (pDev->ulBitCount == 8) 946 { 947 if (!bInit256ColorPalette(pDev)) { 948 DISPDBG((0, "DISP DrvEnableSurface failed to init the 8bpp palette\n")); 949 return(FALSE); 950 } 951 ulBitmapType = BMF_8BPP; 952 flHooks = HOOKS_BMF8BPP; 953 } 954 else if (pDev->ulBitCount == 16) 955 { 956 ulBitmapType = BMF_16BPP; 957 flHooks = HOOKS_BMF16BPP; 958 } 959 else if (pDev->ulBitCount == 24) 960 { 961 ulBitmapType = BMF_24BPP; 962 flHooks = HOOKS_BMF24BPP; 963 } 964 else 965 { 966 ulBitmapType = BMF_32BPP; 967 flHooks = HOOKS_BMF32BPP; 968 } 969 970 hbmDevice = EngCreateBitmap(sizl, 971 pDev->lDeltaScreen, 972 ulBitmapType, 973 (pDev->lDeltaScreen > 0) ? BMF_TOPDOWN : 0, 974 (PVOID) (pDev->pjScreen)); 975 if (hbmDevice) 976 { 977 VOID* pvScan0 = pDev->pjScreen + pSurfaceGlobal->fpVidMem; 978 979 // 980 // Note that HOOK_SYNCHRONIZE must always be hooked when we 981 // give GDI a pointer to the bitmap bits. We don't need to 982 // do it here since HOOK_SYNCHRONIZE is always set in our 983 // pdev->flHooks 984 // 985 ULONG flags = MS_NOTSYSTEMMEMORY; 986 987 if ( EngModifySurface((HSURF)hbmDevice, 988 pDev->hdevEng, 989 pDev->flHooks, 990 flags, 991 (DHSURF)hbmDevice, 992 pvScan0, 993 pSurfaceGlobal->lPitch, 994 NULL) ) 995 { 996 SURFOBJ* surfobj = EngLockSurface((HSURF) hbmDevice); 997 AssertMsg(surfobj->iType == STYPE_BITMAP, ("expected STYPE_BITMAP")); 998 surfobj->iType = STYPE_DEVBITMAP; 999 EngUnlockSurface(surfobj); 1000 1001 DISPDBG((0, "DrvDeriveSurface return succeed")); 1002 return(hbmDevice); 1003 } 1004 1005 DISPDBG((0, "DrvDeriveSurface: EngModifySurface failed")); 1006 EngDeleteSurface((HSURF)hbmDevice); 1007 } 1008 } 1009 1010 DISPDBG((0, "DrvDeriveSurface return NULL")); 1011 DISPDBG((0, "pSurfaceGlobal->ddpfSurface.dwRGBBitCount = %d, lPitch =%ld", pSurfaceGlobal->ddpfSurface.dwRGBBitCount,pSurfaceGlobal->lPitch)); 1012 1013 return(0); 1014 } 1015 #endif /* VBOX_WITH_DDRAW */
Note:
See TracChangeset
for help on using the changeset viewer.