VirtualBox

Changeset 77151 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 4, 2019 4:06:24 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128625
Message:

Devices/DevVGA-SVGA: add cursor position reporting to the front-end.
bugref:9376: Complete hardware cursor implementation in VMSVGA.
Add code to the FIFO processing loop to notice cursor position changes and
report them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp

    r76985 r77151  
    31853185}
    31863186
     3187/** Send cursor position and visibility information from the FIFO to the
     3188 * front-end.  We handle global, not per-screen visibility information by
     3189 * sending pfnVBVAMousePointerShape without shape data. */
     3190static void vmsvgaFIFOUpdateCursor(PVGASTATE pVGAState, uint32_t RT_UNTRUSTED_VOLATILE_GUEST *pFIFO, uint32_t *pcLastX, uint32_t *pcLastY, uint32_t *pfLastVisible)
     3191{
     3192    uint32_t uScreenId = pFIFO[SVGA_FIFO_CURSOR_SCREEN_ID];
     3193    uint32_t fFlags = VBVA_CURSOR_VALID_DATA;
     3194    uint32_t fVisible;
     3195
     3196    /* Potentially race-prone, but not our design and Linux ignores it anyway.
     3197     */
     3198    pFIFO[SVGA_FIFO_CURSOR_LAST_UPDATED] = pFIFO[SVGA_FIFO_CURSOR_COUNT];
     3199    fVisible = pFIFO[SVGA_FIFO_CURSOR_ON];
     3200    /* Check if anything has changed, as calling into pDrv is not light-weight. */
     3201    if (   *pcLastX == pFIFO[SVGA_FIFO_CURSOR_X]
     3202        && *pcLastY == pFIFO[SVGA_FIFO_CURSOR_Y]
     3203        && (uScreenId != SVGA_ID_INVALID || *pfLastVisible == fVisible))
     3204        return;
     3205    *pcLastX = pFIFO[SVGA_FIFO_CURSOR_X];
     3206    *pcLastY = pFIFO[SVGA_FIFO_CURSOR_Y];
     3207    if (uScreenId != SVGA_ID_INVALID)
     3208        fFlags |= VBVA_CURSOR_SCREEN_RELATIVE;
     3209    if (uScreenId == SVGA_ID_INVALID && *pfLastVisible != fVisible) {
     3210        *pfLastVisible = fVisible;
     3211        pVGAState->pDrv->pfnVBVAMousePointerShape(pVGAState->pDrv, RT_BOOL(fVisible), false, 0, 0, 0, 0, NULL);
     3212    }
     3213    pVGAState->pDrv->pfnVBVAReportCursorPosition(pVGAState->pDrv, fFlags, uScreenId, *pcLastX, *pcLastY);
     3214}
     3215
    31873216/* The async FIFO handling thread. */
    31883217static DECLCALLBACK(int) vmsvgaFIFOLoop(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
     
    32453274    bool fBadOrDisabledFifo = false;
    32463275    uint32_t RT_UNTRUSTED_VOLATILE_GUEST * const pFIFO = pThis->svga.pFIFOR3;
     3276    uint32_t cCursorCount = pFIFO[SVGA_FIFO_CURSOR_COUNT];
     3277    uint32_t cLastCursorX       = 0;
     3278    uint32_t cLastCursorY       = 0;
     3279    uint32_t fLastCursorVisible = 0;
     3280    /* Update cursor information before entering the loop to avoid having to
     3281     * think about the initial value of COUNT or to put it in the saved state.
     3282     */
     3283    vmsvgaFIFOUpdateCursor(pThis, pFIFO, &cLastCursorX, &cLastCursorY, &fLastCursorVisible);
    32473284    while (pThread->enmState == PDMTHREADSTATE_RUNNING)
    32483285    {
     
    32753312        if (rc == VERR_TIMEOUT)
    32763313        {
    3277             if (pFIFO[SVGA_FIFO_NEXT_CMD] == pFIFO[SVGA_FIFO_STOP])
     3314            if (   pFIFO[SVGA_FIFO_NEXT_CMD] == pFIFO[SVGA_FIFO_STOP]
     3315                && cCursorCount == pFIFO[SVGA_FIFO_CURSOR_COUNT])
    32783316            {
    32793317                cMsSleep = RT_MIN(cMsSleep + cMsIncSleep, cMsMaxSleep);
     
    33003338            continue;
    33013339        }
     3340
     3341        /* Update the cursor position. */
     3342        cCursorCount = pFIFO[SVGA_FIFO_CURSOR_COUNT];
     3343        vmsvgaFIFOUpdateCursor(pThis, pFIFO, &cLastCursorX, &cLastCursorY, &fLastCursorVisible);
    33023344
    33033345        /*
Note: See TracChangeset for help on using the changeset viewer.

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