VirtualBox

Ignore:
Timestamp:
Nov 4, 2010 12:45:28 PM (14 years ago)
Author:
vboxsync
Message:

Additions/WINNT/Graphics: more refactoring

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Miniport
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp

    r33711 r33761  
    18571857       * with old guest additions.
    18581858       */
    1859       VBoxSetupDisplaysHGSMI((PDEVICE_EXTENSION)HwDeviceExtension, AdapterMemorySize, 0);
     1859      VBoxSetupDisplaysHGSMI(commonFromDeviceExt((PDEVICE_EXTENSION)HwDeviceExtension),
     1860                             AdapterMemorySize, 0);
    18601861
    18611862      if (commonFromDeviceExt((PDEVICE_EXTENSION)HwDeviceExtension)->bHGSMI)
     
    19701971        PointerAttributes.Enable = VBOX_MOUSE_POINTER_VISIBLE;
    19711972
    1972         Result = vboxUpdatePointerShape(PrimaryExtension, &PointerAttributes, sizeof (PointerAttributes));
     1973        Result = vboxUpdatePointerShape(commonFromDeviceExt(PrimaryExtension), &PointerAttributes, sizeof (PointerAttributes));
    19731974
    19741975        if (Result)
     
    22182219                PointerAttributes.Enable = 0;
    22192220
    2220                 Result = vboxUpdatePointerShape((PDEVICE_EXTENSION)HwDeviceExtension, &PointerAttributes, sizeof (PointerAttributes));
     2221                Result = vboxUpdatePointerShape(commonFromDeviceExt((PDEVICE_EXTENSION)HwDeviceExtension), &PointerAttributes, sizeof (PointerAttributes));
    22212222
    22222223                if (Result)
     
    22632264                dprintf(("\tBytes attached: %d\n", RequestPacket->InputBufferLength - sizeof(VIDEO_POINTER_ATTRIBUTES)));
    22642265#endif
    2265                 Result = vboxUpdatePointerShape((PDEVICE_EXTENSION)HwDeviceExtension, pPointerAttributes, RequestPacket->InputBufferLength);
     2266                Result = vboxUpdatePointerShape(commonFromDeviceExt((PDEVICE_EXTENSION)HwDeviceExtension), pPointerAttributes, RequestPacket->InputBufferLength);
    22662267                if (!Result)
    22672268                    dprintf(("VBoxVideo::VBoxVideoStartIO: Could not set hardware pointer -> fallback\n"));
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r33711 r33761  
    846846int VBoxHGSMISendViewInfo(PVBOXVIDEO_COMMON pCommon, uint32_t u32Count, PFNHGSMIFILLVIEWINFO pfnFill, void *pvData);
    847847
    848 VOID VBoxSetupDisplaysHGSMI (PDEVICE_EXTENSION PrimaryExtension,
     848VOID VBoxSetupDisplaysHGSMI (PVBOXVIDEO_COMMON pCommon,
    849849                             ULONG AdapterMemorySize, uint32_t fCaps);
    850 BOOLEAN vboxUpdatePointerShape (PDEVICE_EXTENSION DeviceExtension,
     850BOOLEAN vboxUpdatePointerShape (PVBOXVIDEO_COMMON pCommon,
    851851                                PVIDEO_POINTER_ATTRIBUTES pointerAttr,
    852852                                uint32_t cbLength);
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp

    r33713 r33761  
    381381 * to talk to the host.
    382382 */
    383 VOID VBoxSetupDisplaysHGSMI(PDEVICE_EXTENSION PrimaryExtension,
     383VOID VBoxSetupDisplaysHGSMI(PVBOXVIDEO_COMMON pCommon,
    384384                            ULONG AdapterMemorySize, uint32_t fCaps)
    385385{
    386386    VP_STATUS rc = NO_ERROR;
    387387
    388     dprintf(("VBoxVideo::VBoxSetupDisplays: PrimaryExtension = %p\n",
    389              PrimaryExtension));
    390 
    391     memset(commonFromDeviceExt(PrimaryExtension), 0,
    392            sizeof(*commonFromDeviceExt(PrimaryExtension)));
    393     commonFromDeviceExt(PrimaryExtension)->cbVRAM    = AdapterMemorySize;
    394     commonFromDeviceExt(PrimaryExtension)->fCaps     = fCaps;
    395     commonFromDeviceExt(PrimaryExtension)->cDisplays = 1;
    396     commonFromDeviceExt(PrimaryExtension)->bHGSMI    = VBoxHGSMIIsSupported ();
     388    dprintf(("VBoxVideo::VBoxSetupDisplays: pCommon = %p\n", pCommon));
     389
     390    memset(pCommon, 0, sizeof(*pCommon));
     391    pCommon->cbVRAM    = AdapterMemorySize;
     392    pCommon->fCaps     = fCaps;
     393    pCommon->cDisplays = 1;
     394    pCommon->bHGSMI    = VBoxHGSMIIsSupported ();
    397395    /* Why does this use VBoxVideoCmnMemZero?  The MSDN docs say that it should
    398396     * only be used on mapped display adapter memory.  Done with memset above. */
    399     // VBoxVideoCmnMemZero(&commonFromDeviceExt(PrimaryExtension)->areaHostHeap, sizeof(HGSMIAREA));
    400     if (commonFromDeviceExt(PrimaryExtension)->bHGSMI)
     397    // VBoxVideoCmnMemZero(&pCommon->areaHostHeap, sizeof(HGSMIAREA));
     398    if (pCommon->bHGSMI)
    401399    {
    402400        /** @note (michael) moved this here as it is done unconditionally in both
    403401         * driver branches.  Feel free to fix if that is ever changed. */
    404         commonFromDeviceExt(PrimaryExtension)->IOPortHost = (RTIOPORT)VGA_PORT_HGSMI_HOST;
    405         commonFromDeviceExt(PrimaryExtension)->IOPortGuest = (RTIOPORT)VGA_PORT_HGSMI_GUEST;
     402        pCommon->IOPortHost = (RTIOPORT)VGA_PORT_HGSMI_HOST;
     403        pCommon->IOPortGuest = (RTIOPORT)VGA_PORT_HGSMI_GUEST;
    406404
    407405        /* Map the adapter information. It will be needed for HGSMI IO. */
    408         rc = VBoxMapAdapterMemory (commonFromDeviceExt(PrimaryExtension),
    409                                    &commonFromDeviceExt(PrimaryExtension)->pvAdapterInformation,
     406        rc = VBoxMapAdapterMemory (pCommon, &pCommon->pvAdapterInformation,
    410407                                   AdapterMemorySize - VBVA_ADAPTER_INFORMATION_SIZE,
    411408                                   VBVA_ADAPTER_INFORMATION_SIZE
     
    416413                     rc));
    417414
    418             commonFromDeviceExt(PrimaryExtension)->bHGSMI = FALSE;
     415            pCommon->bHGSMI = FALSE;
    419416        }
    420417        else
    421418        {
    422419            /* Setup a HGSMI heap within the adapter information area. */
    423             rc = HGSMIHeapSetup (&commonFromDeviceExt(PrimaryExtension)->hgsmiAdapterHeap,
    424                                  commonFromDeviceExt(PrimaryExtension)->pvAdapterInformation,
     420            rc = HGSMIHeapSetup (&pCommon->hgsmiAdapterHeap,
     421                                 pCommon->pvAdapterInformation,
    425422                                 VBVA_ADAPTER_INFORMATION_SIZE - sizeof(HGSMIHOSTFLAGS),
    426                                  commonFromDeviceExt(PrimaryExtension)->cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE,
     423                                 pCommon->cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE,
    427424                                 false /*fOffsetBased*/);
    428425
     
    432429                         rc));
    433430
    434                 commonFromDeviceExt(PrimaryExtension)->bHGSMI = FALSE;
     431                pCommon->bHGSMI = FALSE;
    435432            }
    436433            else
    437434            {
    438                     commonFromDeviceExt(PrimaryExtension)->pHostFlags = (HGSMIHOSTFLAGS*)(((uint8_t*)commonFromDeviceExt(PrimaryExtension)->pvAdapterInformation)
     435                pCommon->pHostFlags = (HGSMIHOSTFLAGS*)(((uint8_t*)pCommon->pvAdapterInformation)
    439436                                                            + VBVA_ADAPTER_INFORMATION_SIZE - sizeof(HGSMIHOSTFLAGS));
    440437            }
     
    443440
    444441    /* Setup the host heap and the adapter memory. */
    445     if (commonFromDeviceExt(PrimaryExtension)->bHGSMI)
     442    if (pCommon->bHGSMI)
    446443    {
    447444        /* The miniport heap is used for the host buffers. */
    448445        ULONG cbMiniportHeap = 0;
    449         vboxQueryConfHGSMI (commonFromDeviceExt(PrimaryExtension), VBOX_VBVA_CONF32_HOST_HEAP_SIZE, &cbMiniportHeap);
     446        vboxQueryConfHGSMI (pCommon, VBOX_VBVA_CONF32_HOST_HEAP_SIZE, &cbMiniportHeap);
    450447
    451448        if (cbMiniportHeap != 0)
     
    465462
    466463            /* Round up to 4096 bytes. */
    467             commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap = (cbMiniportHeap + 0xFFF) & ~0xFFF;
    468 
    469             dprintf(("VBoxVideo::VBoxSetupDisplays: cbMiniportHeap = 0x%08X, PrimaryExtension->u.primary.cbMiniportHeap = 0x%08X, cbMiniportHeapMaxSize = 0x%08X\n",
    470                      cbMiniportHeap, commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap, cbMiniportHeapMaxSize));
     464            pCommon->cbMiniportHeap = (cbMiniportHeap + 0xFFF) & ~0xFFF;
     465
     466            dprintf(("VBoxVideo::VBoxSetupDisplays: cbMiniportHeap = 0x%08X, pCommon->cbMiniportHeap = 0x%08X, cbMiniportHeapMaxSize = 0x%08X\n",
     467                     cbMiniportHeap, pCommon->cbMiniportHeap, cbMiniportHeapMaxSize));
    471468
    472469            /* Map the heap region.
     
    476473             *       display drivers.
    477474             */
    478             rc = VBoxMapAdapterMemory (commonFromDeviceExt(PrimaryExtension),
    479                                        &commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap,
    480                                        commonFromDeviceExt(PrimaryExtension)->cbVRAM
     475            rc = VBoxMapAdapterMemory (pCommon, &pCommon->pvMiniportHeap,
     476                                       pCommon->cbVRAM
    481477                                       - VBVA_ADAPTER_INFORMATION_SIZE
    482                                        - commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap,
    483                                        commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap
     478                                       - pCommon->cbMiniportHeap,
     479                                       pCommon->cbMiniportHeap
    484480                                      );
    485481            if (rc != NO_ERROR)
    486482            {
    487                 commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap = NULL;
    488                 commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap = 0;
    489                 commonFromDeviceExt(PrimaryExtension)->bHGSMI = FALSE;
     483                pCommon->pvMiniportHeap = NULL;
     484                pCommon->cbMiniportHeap = 0;
     485                pCommon->bHGSMI = FALSE;
    490486            }
    491487            else
    492488            {
    493                 HGSMIOFFSET offBase = commonFromDeviceExt(PrimaryExtension)->cbVRAM
     489                HGSMIOFFSET offBase = pCommon->cbVRAM
    494490                                      - VBVA_ADAPTER_INFORMATION_SIZE
    495                                       - commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap;
     491                                      - pCommon->cbMiniportHeap;
    496492
    497493                /* Init the host hap area. Buffers from the host will be placed there. */
    498                 HGSMIAreaInitialize (&commonFromDeviceExt(PrimaryExtension)->areaHostHeap,
    499                                      commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap,
    500                                      commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap,
     494                HGSMIAreaInitialize (&pCommon->areaHostHeap,
     495                                     pCommon->pvMiniportHeap,
     496                                     pCommon->cbMiniportHeap,
    501497                                     offBase);
    502498            }
     
    505501        {
    506502            /* Host has not requested a heap. */
    507             commonFromDeviceExt(PrimaryExtension)->pvMiniportHeap = NULL;
    508             commonFromDeviceExt(PrimaryExtension)->cbMiniportHeap = 0;
     503            pCommon->pvMiniportHeap = NULL;
     504            pCommon->cbMiniportHeap = 0;
    509505        }
    510506    }
    511507
    512508    /* Check whether the guest supports multimonitors. */
    513     if (commonFromDeviceExt(PrimaryExtension)->bHGSMI)
     509    if (pCommon->bHGSMI)
    514510    {
    515511        /* Query the configured number of displays. */
    516512        ULONG cDisplays = 0;
    517         vboxQueryConfHGSMI (commonFromDeviceExt(PrimaryExtension), VBOX_VBVA_CONF32_MONITOR_COUNT, &cDisplays);
     513        vboxQueryConfHGSMI (pCommon, VBOX_VBVA_CONF32_MONITOR_COUNT, &cDisplays);
    518514
    519515        dprintf(("VBoxVideo::VBoxSetupDisplays: cDisplays = %d\n",
     
    525521            cDisplays = 1;
    526522        }
    527         commonFromDeviceExt(PrimaryExtension)->cDisplays = cDisplays;
    528     }
    529 
    530     if (commonFromDeviceExt(PrimaryExtension)->bHGSMI)
     523        pCommon->cDisplays = cDisplays;
     524    }
     525
     526    if (pCommon->bHGSMI)
    531527    {
    532528        /* Setup the information for the host. */
    533         rc = vboxSetupAdapterInfoHGSMI (commonFromDeviceExt(PrimaryExtension));
     529        rc = vboxSetupAdapterInfoHGSMI (pCommon);
    534530
    535531        if (RT_FAILURE (rc))
    536532        {
    537             commonFromDeviceExt(PrimaryExtension)->bHGSMI = FALSE;
    538         }
    539     }
    540 
    541     if (!commonFromDeviceExt(PrimaryExtension)->bHGSMI)
    542         VBoxFreeDisplaysHGSMI(commonFromDeviceExt(PrimaryExtension));
     533            pCommon->bHGSMI = FALSE;
     534        }
     535    }
     536
     537    if (!pCommon->bHGSMI)
     538        VBoxFreeDisplaysHGSMI(pCommon);
    543539
    544540    dprintf(("VBoxVideo::VBoxSetupDisplays: finished\n"));
     
    613609}
    614610
    615 BOOLEAN vboxUpdatePointerShape (PDEVICE_EXTENSION DeviceExtension,
     611BOOLEAN vboxUpdatePointerShape (PVBOXVIDEO_COMMON pCommon,
    616612                                PVIDEO_POINTER_ATTRIBUTES pointerAttr,
    617613                                uint32_t cbLength)
    618614{
    619 #ifndef VBOX_WITH_WDDM
    620     PDEVICE_EXTENSION PrimaryExtension = DeviceExtension->pPrimary;
    621 
    622     /* In multimonitor case the HW mouse pointer is the same on all screens,
    623      * and Windows calls each display driver with the same pointer data: visible for
    624      * the screen where the pointer is and invisible for other screens.
    625      *
    626      * This driver passes the shape to the host only from primary screen and makes
    627      * the pointer always visible (in vbvaInitMousePointerShape).
    628      *
    629      * The simple solution makes it impossible to create the shape and keep the mouse
    630      * pointer invisible. New shapes will be created visible.
    631      * But:
    632      * 1) VBox frontends actually ignore the visibility flag if VBOX_MOUSE_POINTER_SHAPE
    633      *    is set and always create new pointers visible.
    634      * 2) Windows uses DrvMovePointer to hide the pointer, which will still work.
    635      */
    636 
    637     if (DeviceExtension->iDevice != PrimaryExtension->iDevice)
    638     {
    639         dprintf(("vboxUpdatePointerShape: ignore non primary device %d(%d)\n",
    640                  DeviceExtension->iDevice, PrimaryExtension->iDevice));
    641         /* Success. */
    642         return TRUE;
    643     }
    644 #else
    645     PDEVICE_EXTENSION PrimaryExtension = DeviceExtension;
    646 #endif
    647 
    648615    uint32_t cbData = 0;
    649616
     
    673640    ctx.i32Result = VERR_NOT_SUPPORTED;
    674641
    675     int rc = vboxCallVBVA (commonFromDeviceExt(PrimaryExtension),
    676                            VBVA_MOUSE_POINTER_SHAPE,
     642    int rc = vboxCallVBVA (pCommon, VBVA_MOUSE_POINTER_SHAPE,
    677643                           sizeof (VBVAMOUSEPOINTERSHAPE) + cbData,
    678644                           vbvaInitMousePointerShape,
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp

    r33715 r33761  
    733733                 * with old guest additions.
    734734                 */
    735                 VBoxSetupDisplaysHGSMI(pContext, AdapterMemorySize,
     735                VBoxSetupDisplaysHGSMI(commonFromDeviceExt(pContext),
     736                                       AdapterMemorySize,
    736737                                       VBVACAPS_COMPLETEGCMD_BY_IOREAD | VBVACAPS_IRQ);
    737738                if (commonFromDeviceExt(pContext)->bHGSMI)
     
    32813282        PointerAttributes.Enable = pSetPointerPosition->Flags.Visible ? VBOX_MOUSE_POINTER_VISIBLE : 0;
    32823283
    3283         BOOLEAN bResult = vboxUpdatePointerShape(pDevExt, &PointerAttributes, sizeof (PointerAttributes));
     3284        BOOLEAN bResult = vboxUpdatePointerShape(commonFromDeviceExt(pDevExt), &PointerAttributes, sizeof (PointerAttributes));
    32843285        Assert(bResult);
    32853286    }
     
    33113312        if (vboxVddmPointerShapeToAttributes(pSetPointerShape, pPointerInfo))
    33123313        {
    3313             if (vboxUpdatePointerShape (pDevExt, &pPointerInfo->Attributes.data, VBOXWDDM_POINTER_ATTRIBUTES_SIZE))
     3314            if (vboxUpdatePointerShape (commonFromDeviceExt(pDevExt), &pPointerInfo->Attributes.data, VBOXWDDM_POINTER_ATTRIBUTES_SIZE))
    33143315                Status = STATUS_SUCCESS;
    33153316            else
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette