VirtualBox

Ignore:
Timestamp:
Jan 8, 2020 8:06:11 PM (5 years ago)
Author:
vboxsync
Message:

bugref:9637. Caching monitor information on the guest side to send DRM a more complete data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/display-svga.cpp

    r82674 r82680  
    8989AssertCompileSize(struct DRMVMWRECT, 16);
    9090
     91struct DISPLAYCACHE
     92{
     93    int fEnabled;
     94    struct DRMVMWRECT rect;
     95};
     96
    9197#define DRM_IOCTL_VERSION _IOWR('d', 0x00, struct DRMVERSION)
    9298
     
    95101    RTFILE hDevice;
    96102};
     103
     104struct DISPLAYCACHE aRects[VMW_MAX_HEADS];
    97105
    98106static void drmConnect(struct DRMCONTEXT *pContext)
     
    182190    (void)fDaemonised;
    183191    struct DRMCONTEXT drmContext = { NIL_RTFILE };
    184     unsigned i;
     192
    185193    int rc;
    186     struct DRMVMWRECT aRects[VMW_MAX_HEADS];
    187194    unsigned cHeads;
    188195    /* Do not acknowledge the first event we query for to pick up old events,
    189196     * e.g. from before a guest reboot. */
    190197    bool fAck = false;
    191 
    192198    drmConnect(&drmContext);
    193199    if (drmContext.hDevice == NIL_RTFILE)
     
    201207    if (RT_FAILURE(rc))
    202208        VBClLogFatalError("Failed to register resizing support, rc=%Rrc\n", rc);
     209
     210    /* For the time being we initialize all the monitors as disabled as per VMM device initialization. */
     211    for (int i = 0; i < VMW_MAX_HEADS; ++i)
     212        aRects[i].fEnabled = 0;
     213
    203214    for (;;)
    204215    {
     
    217228        if (cDisplaysOut > 0)
    218229        {
    219             cHeads = 0;
    220             for (i = 0; i < cDisplaysOut && i < VMW_MAX_HEADS; ++i)
     230            for (unsigned i = 0; i < cDisplaysOut && i < VMW_MAX_HEADS; ++i)
    221231            {
     232                uint32_t idDisplay = aDisplays[i].idDisplay;
     233                if (idDisplay >= VMW_MAX_HEADS)
     234                    continue;
    222235                if (!(aDisplays[i].fDisplayFlags & VMMDEV_DISPLAY_DISABLED))
    223236                {
    224                     if ((i == 0) || (aDisplays[i].fDisplayFlags & VMMDEV_DISPLAY_ORIGIN))
     237                    if ((idDisplay == 0) || (aDisplays[i].fDisplayFlags & VMMDEV_DISPLAY_ORIGIN))
    225238                    {
    226                         aRects[cHeads].x = aDisplays[i].xOrigin;
    227                         aRects[cHeads].y = aDisplays[i].yOrigin;
     239                        aRects[idDisplay].rect.x = aDisplays[i].xOrigin;
     240                        aRects[idDisplay].rect.y = aDisplays[i].yOrigin;
    228241                    } else {
    229                         aRects[cHeads].x = aRects[cHeads - 1].x + aRects[cHeads - 1].w;
    230                         aRects[cHeads].y = aRects[cHeads - 1].y;
     242                        aRects[idDisplay].rect.x = aRects[idDisplay - 1].rect.x + aRects[idDisplay - 1].rect.w;
     243                        aRects[idDisplay].rect.y = aRects[idDisplay - 1].rect.y;
    231244                    }
    232                     aRects[cHeads].w = aDisplays[i].cx;
    233                     aRects[cHeads].h = aDisplays[i].cy;
     245                    aRects[idDisplay].rect.w = aDisplays[i].cx;
     246                    aRects[idDisplay].rect.h = aDisplays[i].cy;
     247                    aRects[idDisplay].fEnabled = 1;
     248                }
     249                else
     250                    aRects[idDisplay].fEnabled = 0;
     251            }
     252            /* Create an dense (consisting of enable monitors only) array to pass to DRM. */
     253            cHeads = 0;
     254            struct DRMVMWRECT enabledMonitors[VMW_MAX_HEADS];
     255
     256            for (int j = 0; j < VMW_MAX_HEADS; ++j)
     257            {
     258                if (aRects[j].fEnabled)
     259                {
     260                    enabledMonitors[cHeads] = aRects[j].rect;
     261                    if (cHeads > 0)
     262                        enabledMonitors[cHeads].x = enabledMonitors[cHeads - 1].x + enabledMonitors[cHeads - 1].w;
    234263                    ++cHeads;
    235264                }
    236265            }
    237             for (i = 0; i < cHeads; ++i)
    238                 printf("Head %u: %dx%d, (%d, %d)\n", i, (int)aRects[i].w, (int)aRects[i].h,
    239                        (int)aRects[i].x, (int)aRects[i].y);
    240             drmSendHints(&drmContext, aRects, cHeads);
     266
     267            for (unsigned i = 0; i < cHeads; ++i)
     268                printf("Monitor %u: %dx%d, (%d, %d)\n", i, (int)enabledMonitors[i].w, (int)enabledMonitors[i].h,
     269                       (int)enabledMonitors[i].x, (int)enabledMonitors[i].y);
     270            drmSendHints(&drmContext, enabledMonitors, cHeads);
    241271        }
    242272        do
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