VirtualBox

Changeset 56378 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Jun 12, 2015 6:10:56 AM (10 years ago)
Author:
vboxsync
Message:

Windows guest additions, VBVA: host mouse cursor capability.

Location:
trunk/src/VBox/Additions
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPCommon.cpp

    r44529 r56378  
    1919#include "VBoxMPCommon.h"
    2020#include <VBox/Hardware/VBoxVideoVBE.h>
     21#include <iprt/asm.h>
    2122
    2223int VBoxMPCmnMapAdapterMemory(PVBOXMP_COMMON pCommon, void **ppv, uint32_t ulOffset, uint32_t ulSize)
     
    106107#endif
    107108}
     109
     110static bool vboxMPCmnIsXorPointer(uint32_t fFlags,
     111                                  uint32_t cWidth,
     112                                  uint32_t cHeight,
     113                                  const uint8_t *pu8Pixels,
     114                                  uint32_t cbLength)
     115{
     116    if (   (fFlags & VBOX_MOUSE_POINTER_SHAPE) == 0
     117        || (fFlags & VBOX_MOUSE_POINTER_ALPHA) != 0)
     118   
     119    {
     120        return false;
     121    }
     122
     123    if (cWidth > 8192 || cHeight > 8192)
     124    {
     125        /* Not supported cursor size. */
     126        return false;
     127    }
     128
     129    /* Pointer data consists of AND mask and XOR_MASK */
     130    const uint32_t cbAndLine = (cWidth + 7) / 8;
     131    const uint32_t cbAndMask = ((cbAndLine * cHeight + 3) & ~3);
     132    const uint32_t cbXorMask = cWidth * 4 * cHeight;
     133
     134    if (cbAndMask + cbXorMask > cbLength)
     135    {
     136        return false;
     137    }
     138
     139    /* If AND mask contains only 1, then it is a XOR only cursor. */
     140    bool fXorOnly = true;
     141    const uint8_t *pu8AndLine = &pu8Pixels[0];
     142    uint32_t i;
     143    for (i = 0; i < cHeight; ++i)
     144    {
     145        if (ASMBitFirstClear(pu8AndLine, cWidth) != -1)
     146        {
     147            fXorOnly = false;
     148            break;
     149        }
     150        pu8AndLine += cbAndLine;
     151    }
     152
     153    return fXorOnly;
     154}
     155
     156bool VBoxMPCmnUpdatePointerShape(PVBOXMP_COMMON pCommon, PVIDEO_POINTER_ATTRIBUTES pAttrs, uint32_t cbLength)
     157{
     158    const uint32_t fFlags = pAttrs->Enable & 0x0000FFFF;
     159    const uint32_t cHotX = (pAttrs->Enable >> 16) & 0xFF;
     160    const uint32_t cHotY = (pAttrs->Enable >> 24) & 0xFF;
     161    const uint32_t cWidth = pAttrs->Width;
     162    const uint32_t cHeight = pAttrs->Height;
     163    uint8_t *pPixels = &pAttrs->Pixels[0];
     164
     165    if (pCommon->u32MouseCursorFlags & VBVA_MOUSE_CURSOR_NO_XOR)
     166    {
     167        if (vboxMPCmnIsXorPointer(fFlags,
     168                                  cWidth, cHeight, pPixels,
     169                                  cbLength - sizeof(VIDEO_POINTER_ATTRIBUTES)))
     170        {
     171            return false;
     172        }
     173    }
     174
     175    int rc = VBoxHGSMIUpdatePointerShape(&pCommon->guestCtx,
     176                                         fFlags, cHotX, cHotY,
     177                                         cWidth, cHeight, pPixels,
     178                                         cbLength - sizeof(VIDEO_POINTER_ATTRIBUTES));
     179    return RT_SUCCESS(rc);
     180}
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPCommon.h

    r52136 r56378  
    5252
    5353/* Pointer related */
    54 inline bool VBoxMPCmnUpdatePointerShape(PVBOXMP_COMMON pCommon, PVIDEO_POINTER_ATTRIBUTES pAttrs, uint32_t cbLength)
    55 {
    56     int rc;
    57     rc =   VBoxHGSMIUpdatePointerShape(&pCommon->guestCtx,
    58                                        pAttrs->Enable & 0x0000FFFF,
    59                                        (pAttrs->Enable >> 16) & 0xFF,
    60                                        (pAttrs->Enable >> 24) & 0xFF,
    61                                        pAttrs->Width, pAttrs->Height, pAttrs->Pixels,
    62                                        cbLength - sizeof(VIDEO_POINTER_ATTRIBUTES));
    63     return RT_SUCCESS(rc);
    64 }
     54bool VBoxMPCmnUpdatePointerShape(PVBOXMP_COMMON pCommon, PVIDEO_POINTER_ATTRIBUTES pAttrs, uint32_t cbLength);
    6555
    6656RT_C_DECLS_END
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPDevExt.h

    r52136 r56378  
    6767
    6868    BOOLEAN fAnyX;                      /* Unrestricted horizontal resolution flag. */
     69
     70    uint32_t u32MouseCursorFlags;       /* VBVA_MOUSE_CURSOR_* */
    6971} VBOXMP_COMMON, *PVBOXMP_COMMON;
    7072
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp

    r55999 r56378  
    11351135                if (VBoxCommonFromDeviceExt(pDevExt)->bHGSMI)
    11361136                {
     1137                    PVBOXMP_COMMON pCommon = VBoxCommonFromDeviceExt(pDevExt);
     1138                    pCommon->u32MouseCursorFlags = VBoxHGSMIGetMouseCursorFlags(&pCommon->guestCtx);
     1139
    11371140                    vboxWddmSetupDisplays(pDevExt);
    11381141                    if (!VBoxCommonFromDeviceExt(pDevExt)->bHGSMI)
     
    41934196}
    41944197
     4198static void vboxWddmHostPointerEnable(PVBOXMP_DEVEXT pDevExt, BOOLEAN fEnable)
     4199{
     4200    VIDEO_POINTER_ATTRIBUTES PointerAttributes;
     4201    RT_ZERO(PointerAttributes);
     4202    if (fEnable)
     4203    {
     4204        PointerAttributes.Enable = VBOX_MOUSE_POINTER_VISIBLE;
     4205    }
     4206    VBoxMPCmnUpdatePointerShape(VBoxCommonFromDeviceExt(pDevExt), &PointerAttributes, sizeof(PointerAttributes));
     4207}
     4208
    41954209NTSTATUS
    41964210APIENTRY
     
    42384252        {
    42394253            BOOLEAN bResult = VBoxMPCmnUpdatePointerShape(VBoxCommonFromDeviceExt(pDevExt), &pPointerInfo->Attributes.data, VBOXWDDM_POINTER_ATTRIBUTES_SIZE);
    4240             Assert(bResult);
     4254            if (!bResult)
     4255            {
     4256                vboxWddmHostPointerEnable(pDevExt, FALSE);
     4257            }
    42414258        }
    42424259        else
    42434260        {
    42444261            // tell the host to use the guest's pointer
    4245             VIDEO_POINTER_ATTRIBUTES PointerAttributes;
    4246 
    4247             /* Visible and No Shape means Show the pointer.
    4248              * It is enough to init only this field.
    4249              */
    4250             PointerAttributes.Enable = pSetPointerPosition->Flags.Visible ? VBOX_MOUSE_POINTER_VISIBLE : 0;
    4251 
    4252             BOOLEAN bResult = VBoxMPCmnUpdatePointerShape(VBoxCommonFromDeviceExt(pDevExt), &PointerAttributes, sizeof (PointerAttributes));
    4253             Assert(bResult);
     4262            vboxWddmHostPointerEnable(pDevExt, pSetPointerPosition->Flags.Visible);
    42544263        }
    42554264    }
     
    42864295            else
    42874296            {
    4288                 AssertBreakpoint();
    4289                 LOGREL(("vboxUpdatePointerShape failed"));
     4297                // tell the host to use the guest's pointer
     4298                vboxWddmHostPointerEnable(pDevExt, FALSE);
    42904299            }
    42914300        }
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/xpdm/VBoxMPDriver.cpp

    r55210 r56378  
    149149    VBoxSetupDisplaysHGSMI(&pExt->u.primary.commonInfo, phVRAM, ulApertureSize, cbVRAM, 0);
    150150
     151    PVBOXMP_COMMON pCommon = &pExt->u.primary.commonInfo;
     152    if (pCommon->bHGSMI)
     153    {
     154        pCommon->u32MouseCursorFlags = VBoxHGSMIGetMouseCursorFlags(&pCommon->guestCtx);
     155    }
     156
    151157    /* Check if the chip restricts horizontal resolution or not.
    152158     * Must be done after VBoxSetupDisplaysHGSMI, because it initializes the common structure.
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/xpdm/VBoxMPIOCTL.cpp

    r49450 r56378  
    316316    {
    317317        LOG(("Fallback to sw pointer."));
    318         pStatus->Status = ERROR_INVALID_FUNCTION;
    319318        bRC = FALSE;
     319    }
     320
     321    if (!bRC)
     322    {
     323        pStatus->Status = ERROR_INVALID_FUNCTION;
    320324    }
    321325
     
    359363    else
    360364    {
    361         pStatus->Status = ERROR_INVALID_FUNCTION;
    362365        bRC = FALSE;
     366    }
     367
     368    if (!bRC)
     369    {
     370        pStatus->Status = ERROR_INVALID_FUNCTION;
    363371    }
    364372
  • trunk/src/VBox/Additions/common/VBoxVideo/HGSMIBase.cpp

    r56322 r56378  
    492492 * @param  u32Index  the index of the parameter to query,
    493493 *                   @see VBVACONF32::u32Index
     494 * @param  u32DefValue defaut value
    494495 * @param  pulValue  where to store the value of the parameter on success
    495496 */
    496 RTDECL(int) VBoxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pCtx,
    497                                uint32_t u32Index, uint32_t *pulValue)
     497RTDECL(int) VBoxQueryConfHGSMIDef(PHGSMIGUESTCOMMANDCONTEXT pCtx,
     498                                  uint32_t u32Index, uint32_t u32DefValue, uint32_t *pulValue)
    498499{
    499500    int rc = VINF_SUCCESS;
     
    512513        /* Prepare data to be sent to the host. */
    513514        p->u32Index = u32Index;
    514         p->u32Value = UINT32_MAX;
     515        p->u32Value = u32DefValue;
    515516        rc = VBoxHGSMIBufferSubmit(pCtx, p);
    516517        if (RT_SUCCESS(rc))
     
    528529}
    529530
     531RTDECL(int) VBoxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pCtx,
     532                               uint32_t u32Index, uint32_t *pulValue)
     533{
     534    return VBoxQueryConfHGSMIDef(pCtx, u32Index, UINT32_MAX, pulValue);
     535}
    530536
    531537/**
  • trunk/src/VBox/Additions/common/VBoxVideo/Modesetting.cpp

    r56354 r56378  
    373373{
    374374    uint32_t u32Flags = 0;
    375     int rc = VBoxQueryConfHGSMI(pCtx, VBOX_VBVA_CONF32_SCREEN_FLAGS, &u32Flags);
     375    int rc = VBoxQueryConfHGSMIDef(pCtx, VBOX_VBVA_CONF32_SCREEN_FLAGS, 0, &u32Flags);
    376376    LogFunc(("u32Flags = 0x%x rc %Rrc\n", u32Flags, rc));
    377377    if (RT_FAILURE(rc))
     
    379379    return (uint16_t)u32Flags;
    380380}
     381
     382
     383/**
     384 * Query the mouse cursor flags VBVA_MOUSE_CURSOR_*.
     385 *
     386 * @returns The mask of VBVA_MOUSE_CURSOR_* flags or 0 if host does not support the request.
     387 * @param  pCtx  the context containing the heap to use
     388 */
     389RTDECL(uint32_t) VBoxHGSMIGetMouseCursorFlags(PHGSMIGUESTCOMMANDCONTEXT pCtx)
     390{
     391    uint32_t u32Flags = 0;
     392    int rc = VBoxQueryConfHGSMIDef(pCtx, VBOX_VBVA_CONF32_MOUSE_CURSOR, 0, &u32Flags);
     393    LogFunc(("u32Flags = 0x%x rc %Rrc\n", u32Flags, rc));
     394    if (RT_FAILURE(rc))
     395        u32Flags = 0;
     396    return u32Flags;
     397}
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