- Timestamp:
- Nov 17, 2009 10:45:20 AM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA.cpp
r24495 r24714 5453 5453 5454 5454 if ( uVersion != VGA_SAVEDSTATE_VERSION 5455 && uVersion != VGA_SAVEDSTATE_VERSION_WITH_CONFIG 5455 5456 && uVersion != VGA_SAVEDSTATE_VERSION_HGSMI 5456 5457 && uVersion != VGA_SAVEDSTATE_VERSION_PRE_HGSMI -
trunk/src/VBox/Devices/Graphics/DevVGA.h
r24495 r24714 49 49 #endif /* VBOX_WITH_HGSMI */ 50 50 51 #define VGA_SAVEDSTATE_VERSION 4 51 #define VGA_SAVEDSTATE_VERSION 5 52 #define VGA_SAVEDSTATE_VERSION_WITH_CONFIG 4 52 53 #define VGA_SAVEDSTATE_VERSION_HGSMI 3 53 54 #define VGA_SAVEDSTATE_VERSION_PRE_HGSMI 2 -
trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp
r24166 r24714 66 66 } VBVAVIEW; 67 67 68 typedef struct VBVAMOUSESHAPEINFO 69 { 70 bool fSet; 71 bool fVisible; 72 bool fAlpha; 73 uint32_t u32HotX; 74 uint32_t u32HotY; 75 uint32_t u32Width; 76 uint32_t u32Height; 77 uint32_t cbShape; 78 uint32_t cbAllocated; 79 uint8_t *pu8Shape; 80 } VBVAMOUSESHAPEINFO; 81 68 82 /* @todo saved state: save and restore VBVACONTEXT */ 69 83 typedef struct _VBVACONTEXT … … 71 85 uint32_t cViews; 72 86 VBVAVIEW aViews[64 /* @todo SchemaDefs::MaxGuestMonitors*/]; 87 VBVAMOUSESHAPEINFO mouseShapeInfo; 73 88 } VBVACONTEXT; 74 89 … … 519 534 } 520 535 521 static int vbvaMousePointerShape (PVGASTATE pVGAState, VBVACONTEXT *pCtx, const VBVAMOUSEPOINTERSHAPE *pShape, HGSMISIZE cbShape) 522 { 523 bool fVisible = (pShape->fu32Flags & VBOX_MOUSE_POINTER_VISIBLE) != 0; 524 bool fAlpha = (pShape->fu32Flags & VBOX_MOUSE_POINTER_ALPHA) != 0; 525 bool fShape = (pShape->fu32Flags & VBOX_MOUSE_POINTER_SHAPE) != 0; 526 527 HGSMISIZE cbPointerData = 0; 528 529 if (fShape) 530 { 531 cbPointerData = ((((pShape->u32Width + 7) / 8) * pShape->u32Height + 3) & ~3) 532 + pShape->u32Width * 4 * pShape->u32Height; 533 } 534 535 if (cbPointerData > cbShape - RT_OFFSETOF(VBVAMOUSEPOINTERSHAPE, au8Data)) 536 { 537 Log(("vbvaMousePointerShape: calculated pointer data size is too big (%d bytes, limit %d)\n", 538 cbPointerData, cbShape - RT_OFFSETOF(VBVAMOUSEPOINTERSHAPE, au8Data))); 539 return VERR_INVALID_PARAMETER; 540 } 541 542 if (pVGAState->pDrv->pfnVBVAMousePointerShape == NULL) 543 { 544 return VERR_NOT_SUPPORTED; 545 } 546 536 #ifdef DEBUG_sunlover 537 void dumpMouseShapeInfo(const VBVAMOUSESHAPEINFO *pMouseShapeInfo) 538 { 539 LogFlow(("fSet = %d, fVisible %d, fAlpha %d, @%d,%d %dx%d (%p, %d/%d)\n", 540 pMouseShapeInfo->fSet, 541 pMouseShapeInfo->fVisible, 542 pMouseShapeInfo->fAlpha, 543 pMouseShapeInfo->u32HotX, 544 pMouseShapeInfo->u32HotY, 545 pMouseShapeInfo->u32Width, 546 pMouseShapeInfo->u32Height, 547 pMouseShapeInfo->pu8Shape, 548 pMouseShapeInfo->cbShape, 549 pMouseShapeInfo->cbAllocated 550 )); 551 } 552 #endif 553 554 static int vbvaUpdateMousePointerShape(PVGASTATE pVGAState, VBVAMOUSESHAPEINFO *pMouseShapeInfo, bool fShape, const uint8_t *pu8Shape) 555 { 547 556 int rc; 548 549 if (fShape) 557 LogFlowFunc(("pVGAState %p, pMouseShapeInfo %p, fShape %d, pu8Shape %p\n", 558 pVGAState, pMouseShapeInfo, fShape, pu8Shape)); 559 #ifdef DEBUG_sunlover 560 dumpMouseShapeInfo(pMouseShapeInfo); 561 #endif 562 563 if (fShape && pu8Shape != NULL) 550 564 { 551 565 rc = pVGAState->pDrv->pfnVBVAMousePointerShape (pVGAState->pDrv, 552 fVisible, 553 fAlpha, 554 pShape->u32HotX, pShape->u32HotY, 555 pShape->u32Width, pShape->u32Height, 556 &pShape->au8Data[0]); 566 pMouseShapeInfo->fVisible, 567 pMouseShapeInfo->fAlpha, 568 pMouseShapeInfo->u32HotX, 569 pMouseShapeInfo->u32HotY, 570 pMouseShapeInfo->u32Width, 571 pMouseShapeInfo->u32Height, 572 pu8Shape); 557 573 } 558 574 else 559 575 { 560 576 rc = pVGAState->pDrv->pfnVBVAMousePointerShape (pVGAState->pDrv, 561 fVisible,577 pMouseShapeInfo->fVisible, 562 578 false, 563 579 0, 0, … … 565 581 NULL); 566 582 } 583 584 return rc; 585 } 586 587 static int vbvaMousePointerShape (PVGASTATE pVGAState, VBVACONTEXT *pCtx, const VBVAMOUSEPOINTERSHAPE *pShape, HGSMISIZE cbShape) 588 { 589 bool fVisible = (pShape->fu32Flags & VBOX_MOUSE_POINTER_VISIBLE) != 0; 590 bool fAlpha = (pShape->fu32Flags & VBOX_MOUSE_POINTER_ALPHA) != 0; 591 bool fShape = (pShape->fu32Flags & VBOX_MOUSE_POINTER_SHAPE) != 0; 592 593 HGSMISIZE cbPointerData = 0; 594 595 if (fShape) 596 { 597 cbPointerData = ((((pShape->u32Width + 7) / 8) * pShape->u32Height + 3) & ~3) 598 + pShape->u32Width * 4 * pShape->u32Height; 599 } 600 601 if (cbPointerData > cbShape - RT_OFFSETOF(VBVAMOUSEPOINTERSHAPE, au8Data)) 602 { 603 Log(("vbvaMousePointerShape: calculated pointer data size is too big (%d bytes, limit %d)\n", 604 cbPointerData, cbShape - RT_OFFSETOF(VBVAMOUSEPOINTERSHAPE, au8Data))); 605 return VERR_INVALID_PARAMETER; 606 } 607 608 /* Save mouse info it will be used to restore mouse pointer after restoring saved state. */ 609 pCtx->mouseShapeInfo.fSet = true; 610 pCtx->mouseShapeInfo.fVisible = fVisible; 611 pCtx->mouseShapeInfo.fAlpha = fAlpha; 612 pCtx->mouseShapeInfo.u32HotX = pShape->u32HotX; 613 pCtx->mouseShapeInfo.u32HotY = pShape->u32HotY; 614 pCtx->mouseShapeInfo.u32Width = pShape->u32Width; 615 pCtx->mouseShapeInfo.u32Height = pShape->u32Height; 616 if (fShape) 617 { 618 /* Reallocate memory buffer if necessary. */ 619 if (cbPointerData > pCtx->mouseShapeInfo.cbAllocated) 620 { 621 RTMemFree (pCtx->mouseShapeInfo.pu8Shape); 622 pCtx->mouseShapeInfo.pu8Shape = NULL; 623 pCtx->mouseShapeInfo.cbShape = 0; 624 625 uint8_t *pu8Shape = (uint8_t *)RTMemAlloc (cbPointerData); 626 if (pu8Shape) 627 { 628 pCtx->mouseShapeInfo.pu8Shape = pu8Shape; 629 pCtx->mouseShapeInfo.cbAllocated = cbPointerData; 630 } 631 } 632 633 /* Copy shape bitmaps. */ 634 if (pCtx->mouseShapeInfo.pu8Shape) 635 { 636 memcpy (pCtx->mouseShapeInfo.pu8Shape, &pShape->au8Data[0], cbPointerData); 637 pCtx->mouseShapeInfo.cbShape = cbPointerData; 638 } 639 } 640 641 if (pVGAState->pDrv->pfnVBVAMousePointerShape == NULL) 642 { 643 return VERR_NOT_SUPPORTED; 644 } 645 646 int rc = vbvaUpdateMousePointerShape(pVGAState, &pCtx->mouseShapeInfo, fShape, &pShape->au8Data[0]); 567 647 568 648 return rc; … … 629 709 pView->partialRecord.pu8)); 630 710 } 711 712 dumpMouseShapeInfo(&pCtx->mouseShapeInfo); 631 713 } 632 714 #endif /* DEBUG_sunlover */ … … 705 787 } 706 788 } 789 790 /* Save mouse pointer shape information. */ 791 rc = SSMR3PutBool (pSSM, pCtx->mouseShapeInfo.fSet); 792 AssertRCReturn(rc, rc); 793 rc = SSMR3PutBool (pSSM, pCtx->mouseShapeInfo.fVisible); 794 AssertRCReturn(rc, rc); 795 rc = SSMR3PutBool (pSSM, pCtx->mouseShapeInfo.fAlpha); 796 AssertRCReturn(rc, rc); 797 rc = SSMR3PutU32 (pSSM, pCtx->mouseShapeInfo.u32HotX); 798 AssertRCReturn(rc, rc); 799 rc = SSMR3PutU32 (pSSM, pCtx->mouseShapeInfo.u32HotY); 800 AssertRCReturn(rc, rc); 801 rc = SSMR3PutU32 (pSSM, pCtx->mouseShapeInfo.u32Width); 802 AssertRCReturn(rc, rc); 803 rc = SSMR3PutU32 (pSSM, pCtx->mouseShapeInfo.u32Height); 804 AssertRCReturn(rc, rc); 805 rc = SSMR3PutU32 (pSSM, pCtx->mouseShapeInfo.cbShape); 806 AssertRCReturn(rc, rc); 807 if (pCtx->mouseShapeInfo.cbShape) 808 { 809 rc = SSMR3PutMem (pSSM, pCtx->mouseShapeInfo.pu8Shape, pCtx->mouseShapeInfo.cbShape); 810 AssertRCReturn(rc, rc); 811 } 812 813 /* Size of some additional data. For future extensions. */ 814 rc = SSMR3PutU32 (pSSM, 0); 815 AssertRCReturn(rc, rc); 707 816 } 708 817 } … … 713 822 int vboxVBVALoadStateExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version) 714 823 { 715 if (u32Version < 3)824 if (u32Version < VGA_SAVEDSTATE_VERSION_HGSMI) 716 825 { 717 826 /* Nothing was saved. */ … … 810 919 } 811 920 921 if (u32Version > VGA_SAVEDSTATE_VERSION_WITH_CONFIG) 922 { 923 /* Read mouse pointer shape information. */ 924 rc = SSMR3GetBool (pSSM, &pCtx->mouseShapeInfo.fSet); 925 AssertRCReturn(rc, rc); 926 rc = SSMR3GetBool (pSSM, &pCtx->mouseShapeInfo.fVisible); 927 AssertRCReturn(rc, rc); 928 rc = SSMR3GetBool (pSSM, &pCtx->mouseShapeInfo.fAlpha); 929 AssertRCReturn(rc, rc); 930 rc = SSMR3GetU32 (pSSM, &pCtx->mouseShapeInfo.u32HotX); 931 AssertRCReturn(rc, rc); 932 rc = SSMR3GetU32 (pSSM, &pCtx->mouseShapeInfo.u32HotY); 933 AssertRCReturn(rc, rc); 934 rc = SSMR3GetU32 (pSSM, &pCtx->mouseShapeInfo.u32Width); 935 AssertRCReturn(rc, rc); 936 rc = SSMR3GetU32 (pSSM, &pCtx->mouseShapeInfo.u32Height); 937 AssertRCReturn(rc, rc); 938 rc = SSMR3GetU32 (pSSM, &pCtx->mouseShapeInfo.cbShape); 939 AssertRCReturn(rc, rc); 940 if (pCtx->mouseShapeInfo.cbShape) 941 { 942 pCtx->mouseShapeInfo.pu8Shape = (uint8_t *)RTMemAlloc(pCtx->mouseShapeInfo.cbShape); 943 if (pCtx->mouseShapeInfo.pu8Shape == NULL) 944 { 945 return VERR_NO_MEMORY; 946 } 947 pCtx->mouseShapeInfo.cbAllocated = pCtx->mouseShapeInfo.cbShape; 948 rc = SSMR3GetMem (pSSM, pCtx->mouseShapeInfo.pu8Shape, pCtx->mouseShapeInfo.cbShape); 949 AssertRCReturn(rc, rc); 950 } 951 else 952 { 953 pCtx->mouseShapeInfo.pu8Shape = NULL; 954 } 955 956 /* Size of some additional data. For future extensions. */ 957 uint32_t cbExtra = 0; 958 rc = SSMR3GetU32 (pSSM, &cbExtra); 959 AssertRCReturn(rc, rc); 960 if (cbExtra > 0) 961 { 962 rc = SSMR3Skip(pSSM, cbExtra); 963 AssertRCReturn(rc, rc); 964 } 965 } 966 812 967 pCtx->cViews = iView; 813 968 LogFlowFunc(("%d views loaded\n", pCtx->cViews)); … … 839 994 vbvaResize (pVGAState, pView, &pView->screen); 840 995 } 996 } 997 998 if (pCtx->mouseShapeInfo.fSet) 999 { 1000 vbvaUpdateMousePointerShape(pVGAState, &pCtx->mouseShapeInfo, true, pCtx->mouseShapeInfo.pu8Shape); 841 1001 } 842 1002 } … … 1402 1562 vbvaDisable (uScreenId, pVGAState, pCtx); 1403 1563 } 1564 1565 pCtx->mouseShapeInfo.fSet = false; 1566 RTMemFree(pCtx->mouseShapeInfo.pu8Shape); 1567 pCtx->mouseShapeInfo.pu8Shape = NULL; 1568 pCtx->mouseShapeInfo.cbAllocated = 0; 1569 pCtx->mouseShapeInfo.cbShape = 0; 1404 1570 } 1405 1571 … … 1467 1633 void VBVADestroy (PVGASTATE pVGAState) 1468 1634 { 1635 VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pVGAState->pHGSMI); 1636 1637 if (pCtx) 1638 { 1639 pCtx->mouseShapeInfo.fSet = false; 1640 RTMemFree(pCtx->mouseShapeInfo.pu8Shape); 1641 pCtx->mouseShapeInfo.pu8Shape = NULL; 1642 pCtx->mouseShapeInfo.cbAllocated = 0; 1643 pCtx->mouseShapeInfo.cbShape = 0; 1644 } 1645 1469 1646 HGSMIDestroy (pVGAState->pHGSMI); 1470 1647 pVGAState->pHGSMI = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.