Changeset 21227 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Display/pointer.c
- Timestamp:
- Jul 5, 2009 7:50:18 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 49547
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/pointer.c
r18246 r21227 31 31 #include "driver.h" 32 32 33 #include <VBox/V BoxGuest.h> /* for VBOX_MOUSE_POINTER_* flags */33 #include <VBox/VMMDev.h> /* for VMMDEV_MOUSE_POINTER_* flags */ 34 34 35 35 #ifndef SPS_ALPHA … … 165 165 166 166 DISPDBG((0, "DISP bSetHardwarePointerShape SPS_ALPHA = %d\n", fl & SPS_ALPHA)); 167 167 168 168 // We don't use the exclusion rectangle because we only support 169 169 // hardware Pointers. If we were doing our own Pointer simulations … … 279 279 * High word will contain hot spot info and low word - flags. 280 280 */ 281 281 282 282 pPointerAttributes->Enable |= (ppdev->ptlHotSpot.y & 0xFF) << 24; 283 283 pPointerAttributes->Enable |= (ppdev->ptlHotSpot.x & 0xFF) << 16; 284 284 285 285 if (fl & SPS_ALPHA) 286 286 { 287 287 pPointerAttributes->Enable |= VBOX_MOUSE_POINTER_ALPHA; 288 288 } 289 289 290 290 // 291 291 // set animate flags … … 297 297 pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_UPDATE; 298 298 } 299 299 300 300 301 301 // … … 314 314 return(FALSE); 315 315 } 316 316 317 317 // 318 318 // Set new pointer position 319 319 // 320 320 321 321 if (x != -1) { 322 322 VIDEO_POINTER_POSITION vpp; 323 323 324 324 vpp.Column = pPointerAttributes->Column; 325 325 vpp.Row = pPointerAttributes->Row; 326 326 327 327 if (EngDeviceIoControl(ppdev->hDriver, 328 328 IOCTL_VIDEO_SET_POINTER_POSITION, … … 332 332 0, 333 333 &returnedDataLength)) { 334 334 335 335 // Should never fail, informational message. 336 336 DISPDBG((1, "DISP:Failed IOCTL_VIDEO_SET_POINTER_POSITION call\n")); 337 } 338 } 339 337 } 338 } 339 340 340 return(TRUE); 341 341 } … … 356 356 { 357 357 PBYTE pjSrc = NULL; 358 358 359 359 ULONG cy = 0; 360 360 361 361 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; 362 362 363 363 PBYTE pjDstAnd = pPointerAttributes->Pixels; 364 364 ULONG cjAnd = 0; … … 367 367 ULONG cxSrc = psoMask->sizlBitmap.cx; 368 368 ULONG cySrc = psoMask->sizlBitmap.cy / 2; /* /2 because both masks are in there */ 369 369 370 370 // Make sure the new pointer isn't too big to handle, 371 371 // strip the size to 64x64 if necessary … … 374 374 cxSrc = ppdev->PointerCapabilities.MaxWidth; 375 375 } 376 376 377 377 if (cySrc > ppdev->PointerCapabilities.MaxHeight) 378 378 { … … 382 382 /* Size of AND mask in bytes */ 383 383 cjAnd = ((cxSrc + 7) / 8) * cySrc; 384 384 385 385 /* Pointer to XOR mask is 4-bytes aligned */ 386 386 pjDstXor += (cjAnd + 3) & ~3; 387 387 388 388 pPointerAttributes->Width = cxSrc; 389 389 pPointerAttributes->Height = cySrc; 390 390 pPointerAttributes->WidthInBytes = cxSrc * 4; 391 391 392 392 /* Init AND mask to 1 */ 393 393 RtlFillMemory (pjDstAnd, cjAnd, 0xFF); 394 395 /* 394 395 /* 396 396 * Copy AND mask. 397 397 */ 398 398 399 399 DISPDBG((0, "DISP bCopyMonoPointer going to copy AND mask\n")); 400 400 401 401 pjSrc = (PBYTE)psoMask->pvScan0; 402 402 403 403 for (cy = 0; cy < cySrc; cy++) 404 404 { 405 405 RtlCopyMemory (pjDstAnd, pjSrc, (cxSrc + 7) / 8); 406 406 407 407 // Point to next source and dest scans 408 408 pjSrc += psoMask->lDelta; 409 409 pjDstAnd += (cxSrc + 7) / 8; 410 410 } 411 411 412 412 DISPDBG((0, "DISP bCopyMonoPointer AND mask copied\n")); 413 413 414 414 DISPDBG((0, "DISP bCopyMonoPointer going to create RGB0 XOR mask\n")); 415 415 416 416 for (cy = 0; cy < cySrc; ++cy) 417 417 { 418 418 ULONG cx; 419 419 420 420 UCHAR bitmask = 0x80; 421 421 422 422 for (cx = 0; cx < cxSrc; cx++, bitmask >>= 1) 423 423 { … … 426 426 bitmask = 0x80; 427 427 } 428 428 429 429 if (pjSrc[cx / 8] & bitmask) 430 430 { … … 441 441 pjDstXor += cxSrc * 4; 442 442 } 443 443 444 444 DISPDBG((0, "DISP bCopyMonoPointer created RGB0 XOR mask\n")); 445 445 … … 473 473 * 474 474 */ 475 475 476 476 /* To simplify this function we use the following method: 477 477 * for pointers with alpha channel … … 481 481 * copy AND mask and new BGR0 XOR mask to pPointerAttributes->Pixels 482 482 */ 483 483 484 484 HSURF hsurf32bpp = NULL; 485 485 SURFOBJ *pso32bpp = NULL; … … 487 487 PBYTE pjSrcAnd = NULL; 488 488 PBYTE pjSrcXor = NULL; 489 489 490 490 ULONG cy = 0; 491 491 492 492 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; 493 493 494 494 PBYTE pjDstAnd = pPointerAttributes->Pixels; 495 495 ULONG cjAnd = 0; … … 498 498 ULONG cxSrc = psoColor->sizlBitmap.cx; 499 499 ULONG cySrc = psoColor->sizlBitmap.cy; 500 500 501 501 // Make sure the new pointer isn't too big to handle, 502 502 // strip the size to 64x64 if necessary … … 505 505 cxSrc = ppdev->PointerCapabilities.MaxWidth; 506 506 } 507 507 508 508 if (cySrc > ppdev->PointerCapabilities.MaxHeight) 509 509 { … … 513 513 /* Size of AND mask in bytes */ 514 514 cjAnd = ((cxSrc + 7) / 8) * cySrc; 515 515 516 516 /* Pointer to XOR mask is 4-bytes aligned */ 517 517 pjDstXor += (cjAnd + 3) & ~3; 518 518 519 519 pPointerAttributes->Width = cxSrc; 520 520 pPointerAttributes->Height = cySrc; 521 521 pPointerAttributes->WidthInBytes = cxSrc * 4; 522 522 523 523 /* Init AND mask to 1 */ 524 524 RtlFillMemory (pjDstAnd, cjAnd, 0xFF); … … 527 527 { 528 528 PBYTE pjSrcAlpha = (PBYTE)psoColor->pvScan0; 529 529 530 530 DISPDBG((0, "DISP bCopyColorPointer SPS_ALPHA\n")); 531 531 532 532 pso32bpp = psoColor; 533 534 /* 535 * Emulate AND mask to provide viewable mouse pointer for 533 534 /* 535 * Emulate AND mask to provide viewable mouse pointer for 536 536 * hardware which does not support alpha channel. 537 537 */ 538 538 539 539 DISPDBG((0, "DISP bCopyColorPointer going to emulate AND mask\n")); 540 540 541 541 for (cy = 0; cy < cySrc; cy++) 542 542 { 543 543 ULONG cx; 544 544 545 545 UCHAR bitmask = 0x80; 546 546 547 547 for (cx = 0; cx < cxSrc; cx++, bitmask >>= 1) 548 548 { … … 551 551 bitmask = 0x80; 552 552 } 553 553 554 554 if (pjSrcAlpha[cx * 4 + 3] > 0x7f) 555 555 { … … 557 557 } 558 558 } 559 559 560 560 // Point to next source and dest scans 561 561 pjSrcAlpha += pso32bpp->lDelta; 562 562 pjDstAnd += (cxSrc + 7) / 8; 563 563 } 564 564 565 565 DISPDBG((0, "DISP bCopyColorPointer AND mask emulated\n")); 566 566 } … … 572 572 return (FALSE); 573 573 } 574 575 /* 574 575 /* 576 576 * Copy AND mask. 577 577 */ 578 578 579 579 DISPDBG((0, "DISP bCopyColorPointer going to copy AND mask\n")); 580 580 581 581 pjSrcAnd = (PBYTE)psoMask->pvScan0; 582 582 583 583 for (cy = 0; cy < cySrc; cy++) 584 584 { 585 585 RtlCopyMemory (pjDstAnd, pjSrcAnd, (cxSrc + 7) / 8); 586 586 587 587 // Point to next source and dest scans 588 588 pjSrcAnd += psoMask->lDelta; 589 589 pjDstAnd += (cxSrc + 7) / 8; 590 590 } 591 591 592 592 DISPDBG((0, "DISP bCopyColorPointer AND mask copied\n")); 593 594 /* 593 594 /* 595 595 * Convert given psoColor to 32 bit BGR0. 596 596 */ 597 597 598 598 DISPDBG((0, "DISP bCopyColorPointer psoScreen t = %d, f = %d, psoColor t = %d, f = %d, pxlo = %p, psoColor->lDelta = %d, ->cx = %d\n", 599 599 psoScreen->iType, psoScreen->iBitmapFormat, psoColor->iType, psoColor->iBitmapFormat, pxlo, psoColor->lDelta, psoColor->sizlBitmap.cx)); 600 600 601 601 if (psoColor->iType == STYPE_BITMAP 602 602 && psoColor->iBitmapFormat == BMF_32BPP) … … 610 610 HSURF hsurfBitmap = NULL; 611 611 SURFOBJ *psoBitmap = NULL; 612 612 613 613 SIZEL sizl = psoColor->sizlBitmap; 614 614 615 615 if ((pxlo != NULL && pxlo->flXlate != XO_TRIVIAL) 616 616 || (psoColor->iType != STYPE_BITMAP)) 617 617 { 618 618 /* Convert the unknown format to a screen format bitmap. */ 619 619 620 620 RECTL rclDst; 621 621 POINTL ptlSrc; 622 622 623 623 DISPDBG((0, "DISP bCopyColorPointer going to convert XOR mask to bitmap\n")); 624 624 625 625 hsurfBitmap = (HSURF)EngCreateBitmap (sizl, 0, psoScreen->iBitmapFormat, BMF_TOPDOWN, NULL); 626 626 627 627 if (hsurfBitmap == NULL) 628 628 { 629 629 return FALSE; 630 630 } 631 631 632 632 psoBitmap = EngLockSurface (hsurfBitmap); 633 633 634 634 if (psoBitmap == NULL) 635 635 { … … 637 637 return FALSE; 638 638 } 639 639 640 640 /* Now do the bitmap conversion using EngCopyBits(). */ 641 641 642 642 rclDst.left = 0; 643 643 rclDst.top = 0; 644 644 rclDst.right = sizl.cx; 645 645 rclDst.bottom = sizl.cy; 646 646 647 647 ptlSrc.x = 0; 648 648 ptlSrc.y = 0; 649 649 650 650 if (!EngCopyBits (psoBitmap, psoColor, NULL, pxlo, &rclDst, &ptlSrc)) 651 651 { … … 654 654 return FALSE; 655 655 } 656 656 657 657 DISPDBG((0, "DISP bCopyColorPointer XOR mask converted to bitmap\n")); 658 658 } … … 662 662 psoBitmap = psoColor; 663 663 } 664 664 665 665 /* Create 32 bpp surface for XOR mask */ 666 666 hsurf32bpp = (HSURF)EngCreateBitmap (sizl, 0, BMF_32BPP, BMF_TOPDOWN, NULL); 667 667 668 668 if (hsurf32bpp != NULL) 669 669 { 670 670 pso32bpp = EngLockSurface (hsurf32bpp); 671 671 672 672 if (pso32bpp == NULL) 673 673 { … … 676 676 } 677 677 } 678 678 679 679 if (pso32bpp) 680 680 { … … 684 684 PBYTE src = (PBYTE)psoBitmap->pvScan0; 685 685 PBYTE dst = (PBYTE)pso32bpp->pvScan0; 686 686 687 687 PPALETTEENTRY pPal = ppdev->pPal; 688 688 ULONG cPalette = 256; /* 256 is hardcoded in the driver in palette.c */ 689 689 690 690 DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 8 bpp to 32 bpp palette: %d entries\n", cPalette)); 691 691 692 692 for (cy = 0; cy < (ULONG)sizl.cy; cy++) 693 693 { 694 694 ULONG cx; 695 695 696 696 PBYTE d = dst; 697 697 698 698 for (cx = 0; cx < (ULONG)sizl.cx; cx++) 699 699 { 700 700 BYTE index = src[cx]; 701 701 702 702 *d++ = pPal[index].peBlue; /* B */ 703 703 *d++ = pPal[index].peGreen; /* G */ … … 710 710 dst += pso32bpp->lDelta; 711 711 } 712 712 713 713 DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 8 bpp to 32 bpp completed\n")); 714 714 } … … 717 717 PBYTE src = (PBYTE)psoBitmap->pvScan0; 718 718 PBYTE dst = (PBYTE)pso32bpp->pvScan0; 719 719 720 720 DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 16 bpp to 32 bpp\n")); 721 721 722 722 for (cy = 0; cy < (ULONG)sizl.cy; cy++) 723 723 { 724 724 ULONG cx; 725 725 726 726 PBYTE d = dst; 727 727 728 728 for (cx = 0; cx < (ULONG)sizl.cx; cx++) 729 729 { 730 730 USHORT usSrc = *(USHORT *)&src[cx * 2]; 731 731 732 732 *d++ = (BYTE)( usSrc << 3); /* B */ 733 733 *d++ = (BYTE)((usSrc >> 5) << 2); /* G */ … … 740 740 dst += pso32bpp->lDelta; 741 741 } 742 742 743 743 DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 16 bpp to 32 bpp completed\n")); 744 744 } … … 747 747 PBYTE src = (PBYTE)psoBitmap->pvScan0; 748 748 PBYTE dst = (PBYTE)pso32bpp->pvScan0; 749 749 750 750 DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 24 bpp to 32 bpp\n")); 751 751 752 752 for (cy = 0; cy < (ULONG)sizl.cy; cy++) 753 753 { 754 754 ULONG cx; 755 755 756 756 PBYTE s = src; 757 757 PBYTE d = dst; 758 758 759 759 for (cx = 0; cx < (ULONG)sizl.cx; cx++) 760 760 { … … 769 769 dst += pso32bpp->lDelta; 770 770 } 771 771 772 772 DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 24 bpp to 32 bpp completed\n")); 773 773 } … … 775 775 { 776 776 DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 32 bpp to 32 bpp, pso32bpp->cjBits = %d, psoBitmap->cjBits = %d\n", pso32bpp->cjBits, psoBitmap->cjBits)); 777 777 778 778 RtlCopyMemory (pso32bpp->pvBits, psoBitmap->pvBits, min(pso32bpp->cjBits, psoBitmap->cjBits)); 779 779 780 780 DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 32 bpp to 32 bpp completed\n")); 781 781 } … … 783 783 { 784 784 DISPDBG((0, "DISP bCopyColorPointer XOR mask unsupported bpp\n")); 785 785 786 786 EngUnlockSurface (pso32bpp); 787 787 pso32bpp = NULL; … … 790 790 } 791 791 } 792 792 793 793 if (hsurfBitmap) 794 794 { … … 800 800 } 801 801 } 802 802 803 803 if (!pso32bpp) 804 804 { 805 805 return (FALSE); 806 806 } 807 808 /* 809 * pso is 32 bit BGRX bitmap. Copy it to Pixels 807 808 /* 809 * pso is 32 bit BGRX bitmap. Copy it to Pixels 810 810 */ 811 811 812 812 pjSrcXor = (PBYTE)pso32bpp->pvScan0; 813 813 814 814 for (cy = 0; cy < cySrc; cy++) 815 815 { 816 816 /* 32 bit bitmap is being copied */ 817 RtlCopyMemory (pjDstXor, pjSrcXor, cxSrc * 4); 817 RtlCopyMemory (pjDstXor, pjSrcXor, cxSrc * 4); 818 818 819 819 /* Point to next source and dest scans */ … … 821 821 pjDstXor += pPointerAttributes->WidthInBytes; 822 822 } 823 823 824 824 if (pso32bpp != psoColor) 825 825 { … … 828 828 EngDeleteSurface (hsurf32bpp); 829 829 } 830 830 831 831 return (TRUE); 832 832 } … … 893 893 pdevinfo->flGraphicsCaps &= ~GCAPS_ASYNCMOVE; 894 894 } 895 895 896 896 /* VBOX supports pointers with alpha channel */ 897 897 pdevinfo->flGraphicsCaps2 |= GCAPS2_ALPHACURSOR;
Note:
See TracChangeset
for help on using the changeset viewer.