VirtualBox

Changeset 71073 in vbox


Ignore:
Timestamp:
Feb 20, 2018 5:14:17 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8694: Runtime UI: Make steps for Unscaled HiDPI Output mode by default; this way we are always in unscaled state initially and do arbitrary upscaling if necessary; that is a requirement for fractional device-pixel-ratio support.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r71057 r71073  
    13201320        m_transform = m_transform.scale(scaleFactor(), scaleFactor());
    13211321
    1322     /* Apply the device-pixel-ratio if necessary: */
    1323     if (useUnscaledHiDPIOutput() && devicePixelRatio() > 1.0)
    1324         m_transform = m_transform.scale(1.0 / devicePixelRatio(), 1.0 / devicePixelRatio());
     1322    /* Take the device-pixel-ratio into account: */
     1323    if (!useUnscaledHiDPIOutput())
     1324        m_transform = m_transform.scale(devicePixelRatio(), devicePixelRatio());
     1325    m_transform = m_transform.scale(1.0 / devicePixelRatio(), 1.0 / devicePixelRatio());
    13251326}
    13261327
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r71056 r71073  
    367367        QSize scaledSize = size();
    368368        const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    369         if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
    370             scaledSize *= dDevicePixelRatio;
     369        scaledSize *= dDevicePixelRatio;
     370        if (!frameBuffer()->useUnscaledHiDPIOutput())
     371            scaledSize /= dDevicePixelRatio;
    371372        frameBuffer()->setScaledSize(scaledSize);
    372373
     
    452453
    453454    /* Take the device-pixel-ratio into account: */
    454     if (frameBuffer()->useUnscaledHiDPIOutput())
    455     {
    456         const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    457         if (dDevicePixelRatio > 1.0)
    458         {
    459             rect.moveTo((int)floor((double)rect.x() / dDevicePixelRatio) - 1,
    460                         (int)floor((double)rect.y() / dDevicePixelRatio) - 1);
    461             rect.setSize(QSize((int)ceil((double)rect.width()  / dDevicePixelRatio) + 2,
    462                                (int)ceil((double)rect.height() / dDevicePixelRatio) + 2));
    463         }
     455    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     456    if (!frameBuffer()->useUnscaledHiDPIOutput() && dDevicePixelRatio != 1.0)
     457    {
     458        rect.moveTo((int)floor((double)rect.x() * dDevicePixelRatio) - 1,
     459                    (int)floor((double)rect.y() * dDevicePixelRatio) - 1);
     460        rect.setSize(QSize((int)ceil((double)rect.width()  * dDevicePixelRatio) + 2,
     461                           (int)ceil((double)rect.height() * dDevicePixelRatio) + 2));
     462    }
     463    if (dDevicePixelRatio != 1.0)
     464    {
     465        rect.moveTo((int)floor((double)rect.x() / dDevicePixelRatio) - 1,
     466                    (int)floor((double)rect.y() / dDevicePixelRatio) - 1);
     467        rect.setSize(QSize((int)ceil((double)rect.width()  / dDevicePixelRatio) + 2,
     468                           (int)ceil((double)rect.height() / dDevicePixelRatio) + 2));
    464469    }
    465470
     
    512517                                          (uint32_t)(dScaleFactorFor3D * VBOX_OGL_SCALE_FACTOR_MULTIPLIER),
    513518                                          (uint32_t)(dScaleFactorFor3D * VBOX_OGL_SCALE_FACTOR_MULTIPLIER));
     519        display().NotifyHiDPIOutputPolicyChange(fUseUnscaledHiDPIOutput);
    514520    }
    515521
     
    551557    /* Propagate the unscaled HiDPI output mode to 3D service if necessary: */
    552558    if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
    553     {
    554559        display().NotifyHiDPIOutputPolicyChange(fUseUnscaledHiDPIOutput);
    555     }
    556560
    557561    /* Handle scale attributes change: */
     
    794798
    795799#ifdef VBOX_WITH_DRAG_AND_DROP
    796     /* Enable drag & drop. */
     800    /* Enable drag & drop: */
    797801    setAcceptDrops(true);
    798802
    799     /* Create the drag and drop handler instance.
    800      * At the moment we only support one instance per machine window. */
     803    /* Create the drag and drop handler instance: */
    801804    m_pDnDHandler = new UIDnDHandler(uisession(), this /* pParent */);
    802805#endif /* VBOX_WITH_DRAG_AND_DROP */
     
    10591062            QSize scaledSize = size();
    10601063            const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    1061             if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
    1062                 scaledSize *= dDevicePixelRatio;
     1064            scaledSize *= dDevicePixelRatio;
     1065            if (!frameBuffer()->useUnscaledHiDPIOutput())
     1066                scaledSize /= dDevicePixelRatio;
    10631067            frameBuffer()->setScaledSize(scaledSize);
    10641068        }
     
    11221126    }
    11231127
     1128    /* Take the device-pixel-ratio into account: */
     1129    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1130    if (!frameBuffer()->useUnscaledHiDPIOutput() && dDevicePixelRatio != 1.0)
     1131        screenShot = screenShot.scaled(screenShot.size() * dDevicePixelRatio,
     1132                                       Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
     1133
    11241134    /* Dim screen-shot if it is Ok: */
    11251135    if (display().isOk() && !screenShot.isNull())
     
    11281138    /* Finally copy the screen-shot to pause-pixmap: */
    11291139    m_pausePixmap = QPixmap::fromImage(screenShot);
    1130     /* Adjust device-pixel-ratio if necessary: */
    1131     const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    1132     if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
    1133         m_pausePixmap.setDevicePixelRatio(dDevicePixelRatio);
     1140
     1141    /* Take the device-pixel-ratio into account: */
     1142    m_pausePixmap.setDevicePixelRatio(frameBuffer()->devicePixelRatio());
    11341143
    11351144    /* Update scaled pause pixmap: */
     
    11521161    machine().QuerySavedGuestScreenInfo(m_uScreenId, uGuestOriginX, uGuestOriginY, uGuestWidth, uGuestHeight, fEnabled);
    11531162
     1163    /* Calculate effective size: */
     1164    QSize effectiveSize = uGuestWidth > 0 ? QSize(uGuestWidth, uGuestHeight) : guestScreenSizeHint();
     1165
     1166    /* Take the device-pixel-ratio into account: */
     1167    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1168    if (!frameBuffer()->useUnscaledHiDPIOutput())
     1169        effectiveSize *= dDevicePixelRatio;
     1170
    11541171    /* Create a screen-shot on the basis of the screen-data we have in saved-state: */
    1155     QImage screenShot = QImage::fromData(screenData.data(), screenData.size(), "PNG").scaled(uGuestWidth > 0 ? QSize(uGuestWidth, uGuestHeight) : guestScreenSizeHint());
     1172    QImage screenShot = QImage::fromData(screenData.data(), screenData.size(), "PNG").scaled(effectiveSize);
    11561173
    11571174    /* Dim screen-shot if it is Ok: */
     
    11611178    /* Finally copy the screen-shot to pause-pixmap: */
    11621179    m_pausePixmap = QPixmap::fromImage(screenShot);
    1163     /* Adjust device-pixel-ratio if necessary: */
    1164     const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    1165     if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
    1166         m_pausePixmap.setDevicePixelRatio(dDevicePixelRatio);
     1180
     1181    /* Take the device-pixel-ratio into account: */
     1182    m_pausePixmap.setDevicePixelRatio(frameBuffer()->devicePixelRatio());
    11671183
    11681184    /* Update scaled pause pixmap: */
     
    11771193
    11781194    /* Make sure scaled-size is not null: */
    1179     const QSize scaledSize = frameBuffer()->scaledSize();
     1195    QSize scaledSize = frameBuffer()->scaledSize();
    11801196    if (!scaledSize.isValid())
    11811197        return;
    11821198
     1199    /* Take the device-pixel-ratio into account: */
     1200    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1201    if (!frameBuffer()->useUnscaledHiDPIOutput())
     1202        scaledSize *= dDevicePixelRatio;
     1203
    11831204    /* Update pause pixmap finally: */
    11841205    m_pausePixmapScaled = pausePixmap().scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    1185     /* Adjust device-pixel-ratio if necessary: */
    1186     const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    1187     if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput())
    1188         m_pausePixmapScaled.setDevicePixelRatio(dDevicePixelRatio);
     1206
     1207    /* Take the device-pixel-ratio into account: */
     1208    m_pausePixmapScaled.setDevicePixelRatio(frameBuffer()->devicePixelRatio());
    11891209}
    11901210
     
    12101230
    12111231    /* Take the device-pixel-ratio into account: */
    1212     if (frameBuffer()->useUnscaledHiDPIOutput())
    1213     {
    1214         const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    1215         if (dDevicePixelRatio > 1.0)
    1216         {
    1217             xRange *= dDevicePixelRatio;
    1218             yRange *= dDevicePixelRatio;
    1219         }
     1232    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1233    xRange *= dDevicePixelRatio;
     1234    yRange *= dDevicePixelRatio;
     1235    if (!frameBuffer()->useUnscaledHiDPIOutput())
     1236    {
     1237        xRange /= dDevicePixelRatio;
     1238        yRange /= dDevicePixelRatio;
    12201239    }
    12211240
     
    12341253
    12351254    /* Take the device-pixel-ratio into account: */
    1236     if (frameBuffer()->useUnscaledHiDPIOutput())
    1237     {
    1238         const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    1239         if (dDevicePixelRatio > 1.0)
    1240         {
    1241             iContentsX /= dDevicePixelRatio;
    1242             iContentsY /= dDevicePixelRatio;
    1243         }
    1244     }
     1255    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1256    if (!frameBuffer()->useUnscaledHiDPIOutput())
     1257    {
     1258        iContentsX *= dDevicePixelRatio;
     1259        iContentsY *= dDevicePixelRatio;
     1260    }
     1261    iContentsX /= dDevicePixelRatio;
     1262    iContentsY /= dDevicePixelRatio;
    12451263
    12461264    /* Return point shifted according scroll-bars: */
     
    13001318    updateViewport();
    13011319}
    1302 
    13031320
    13041321#ifdef VBOX_WS_MAC
     
    16351652    else if (!m_fIsDraggingFromGuest)
    16361653    {
    1637         /** @todo Add guest->guest DnD functionality here by getting
    1638          *        the source of guest B (when copying from B to A). */
     1654        // @todo Add guest->guest DnD functionality here by getting
     1655        //       the source of guest B (when copying from B to A).
    16391656        rc = m_pDnDHandler->dragCheckPending(screenId());
    16401657        if (RT_SUCCESS(rc))
     
    16621679    else
    16631680    {
    1664         /** @todo Add guest->guest DnD functionality here by getting
    1665          *        the source of guest B (when copying from B to A). */
     1681        // @todo Add guest->guest DnD functionality here by getting
     1682        //       the source of guest B (when copying from B to A).
    16661683        rc = m_pDnDHandler->dragStart(screenId());
    16671684
     
    18611878
    18621879    /* Take the device-pixel-ratio into account: */
    1863     if (frameBuffer()->useUnscaledHiDPIOutput())
    1864     {
    1865         const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    1866         if (dDevicePixelRatio > 1.0)
    1867             size = QSize(size.width() / dDevicePixelRatio, size.height() / dDevicePixelRatio);
    1868     }
     1880    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1881    if (!frameBuffer()->useUnscaledHiDPIOutput())
     1882        size = QSize(size.width() * dDevicePixelRatio, size.height() * dDevicePixelRatio);
     1883    size = QSize(size.width() / dDevicePixelRatio, size.height() / dDevicePixelRatio);
    18691884
    18701885    /* Return result: */
     
    18751890{
    18761891    /* Take the device-pixel-ratio into account: */
    1877     if (frameBuffer()->useUnscaledHiDPIOutput())
    1878     {
    1879         const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    1880         if (dDevicePixelRatio > 1.0)
    1881             size = QSize(size.width() * dDevicePixelRatio, size.height() * dDevicePixelRatio);
    1882     }
     1892    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
     1893    size = QSize(size.width() * dDevicePixelRatio, size.height() * dDevicePixelRatio);
     1894    if (!frameBuffer()->useUnscaledHiDPIOutput())
     1895        size = QSize(size.width() / dDevicePixelRatio, size.height() / dDevicePixelRatio);
    18831896
    18841897    /* Take the scale-factor into account: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r69957 r71073  
    10451045
    10461046            /* Take the device-pixel-ratio into account: */
    1047             if (pFrameBuffer->useUnscaledHiDPIOutput())
     1047            const double dDevicePixelRatio = pFrameBuffer->devicePixelRatio();
     1048            cpnt.setX(cpnt.x() * dDevicePixelRatio);
     1049            cpnt.setY(cpnt.y() * dDevicePixelRatio);
     1050            if (!pFrameBuffer->useUnscaledHiDPIOutput())
    10481051            {
    1049                 const double dDevicePixelRatio = pFrameBuffer->devicePixelRatio();
    1050                 if (dDevicePixelRatio > 1.0)
    1051                 {
    1052                     cpnt.setX((int)(cpnt.x() * dDevicePixelRatio));
    1053                     cpnt.setY((int)(cpnt.y() * dDevicePixelRatio));
    1054                 }
     1052                cpnt.setX(cpnt.x() / dDevicePixelRatio);
     1053                cpnt.setY(cpnt.y() / dDevicePixelRatio);
    10551054            }
    10561055
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp

    r70996 r71073  
    6666    const double dDevicePixelRatio = frameBuffer()->devicePixelRatio();
    6767    const bool fUseUnscaledHiDPIOutput = frameBuffer()->useUnscaledHiDPIOutput();
    68     if (dDevicePixelRatio > 1.0 && fUseUnscaledHiDPIOutput)
    69         scaledSize *= dDevicePixelRatio;
     68    scaledSize *= dDevicePixelRatio;
     69    if (!fUseUnscaledHiDPIOutput)
     70        scaledSize /= dDevicePixelRatio;
    7071    frameBuffer()->setScaledSize(scaledSize);
    7172    frameBuffer()->performRescale();
     
    158159    /* Propagate unscaled-hidpi-output feature to 3D service if necessary: */
    159160    if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
    160     {
    161161        display().NotifyHiDPIOutputPolicyChange(fUseUnscaledHiDPIOutput);
    162     }
    163162
    164163    /* Perform frame-buffer rescaling: */
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