VirtualBox

Changeset 53962 in vbox


Ignore:
Timestamp:
Jan 26, 2015 2:34:13 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97856
Message:

FE/Qt: 3635: Scaling mode support: Allow to restore VM to scale-mode taking into acount corresponding scaled-size.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r53912 r53962  
    9292
    9393    /** Applies machine-view scale-factor. */
    94     void applyMachineViewScaleFactor();
     94    virtual void applyMachineViewScaleFactor();
    9595
    9696    /* Framebuffer aspect ratio: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp

    r53897 r53962  
    6666    saveMachineViewSettings();
    6767
    68     /* Return scaled-size to 'normal' mode: */
    69     applyMachineViewScaleFactor();
     68    /* Return scaled-size to 'default' mode: */
     69    UIMachineView::applyMachineViewScaleFactor();
    7070
    7171    /* Cleanup frame buffer: */
     
    7878    frameBuffer()->setScaledSize(viewport()->size());
    7979
    80     /* Propagate scale-factor to 3D service if necessary: */
    81     if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
    82     {
    83         const double xRatio = (double)frameBuffer()->scaledSize().width() / frameBuffer()->width();
    84         const double yRatio = (double)frameBuffer()->scaledSize().height() / frameBuffer()->height();
    85         display().NotifyScaleFactorChange(m_uScreenId,
    86                                           (uint32_t)(xRatio * VBOX_OGL_SCALE_FACTOR_MULTIPLIER),
    87                                           (uint32_t)(yRatio * VBOX_OGL_SCALE_FACTOR_MULTIPLIER));
     80    /* If scaled-size is valid: */
     81    const QSize scaledSize = frameBuffer()->scaledSize();
     82    if (scaledSize.isValid())
     83    {
     84        /* Propagate scale-factor to 3D service if necessary: */
     85        if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
     86        {
     87            const double xScaleFactor = (double)scaledSize.width()  / frameBuffer()->width();
     88            const double yScaleFactor = (double)scaledSize.height() / frameBuffer()->height();
     89            display().NotifyScaleFactorChange(m_uScreenId,
     90                                              (uint32_t)(xScaleFactor * VBOX_OGL_SCALE_FACTOR_MULTIPLIER),
     91                                              (uint32_t)(yScaleFactor * VBOX_OGL_SCALE_FACTOR_MULTIPLIER));
     92        }
    8893    }
    8994
     
    101106{
    102107    /* Initialize variables for scale mode: */
    103     QSize scaledSize = frameBuffer()->scaledSize();
    104     double xRatio = (double)scaledSize.width() / frameBuffer()->width();
    105     double yRatio = (double)scaledSize.height() / frameBuffer()->height();
    106     AssertMsg(contentsX() == 0, ("This can't be, else notify Dsen!\n"));
    107     AssertMsg(contentsY() == 0, ("This can't be, else notify Dsen!\n"));
     108    const QSize scaledSize = frameBuffer()->scaledSize();
     109    const double xScaleFactor = (double)scaledSize.width()  / frameBuffer()->width();
     110    const double yScaleFactor = (double)scaledSize.height() / frameBuffer()->height();
    108111
    109112    /* Update corresponding viewport part,
     
    111114     * catch all rounding errors. (use 1 time the ratio factor and
    112115     * round down on top/left, but round up for the width/height) */
    113     viewport()->update((int)(iX * xRatio) - ((int)xRatio) - 1,
    114                        (int)(iY * yRatio) - ((int)yRatio) - 1,
    115                        (int)(iW * xRatio) + ((int)xRatio + 2) * 2,
    116                        (int)(iH * yRatio) + ((int)yRatio + 2) * 2);
     116    viewport()->update((int)(iX * xScaleFactor) - ((int)xScaleFactor) - 1,
     117                       (int)(iY * yScaleFactor) - ((int)yScaleFactor) - 1,
     118                       (int)(iW * xScaleFactor) + ((int)xScaleFactor + 2) * 2,
     119                       (int)(iH * yScaleFactor) + ((int)yScaleFactor + 2) * 2);
    117120}
    118121
     
    142145    if (uisession()->isScreenVisible(screenId()))
    143146        storeGuestSizeHint(QSize(frameBuffer()->width(), frameBuffer()->height()));
     147}
     148
     149void UIMachineViewScale::applyMachineViewScaleFactor()
     150{
     151    /* If scaled-size is valid: */
     152    const QSize scaledSize = frameBuffer()->scaledSize();
     153    if (scaledSize.isValid())
     154    {
     155        /* Propagate scale-factor to 3D service if necessary: */
     156        if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
     157        {
     158            const double xScaleFactor = (double)scaledSize.width()  / frameBuffer()->width();
     159            const double yScaleFactor = (double)scaledSize.height() / frameBuffer()->height();
     160            display().NotifyScaleFactorChange(m_uScreenId,
     161                                              (uint32_t)(xScaleFactor * VBOX_OGL_SCALE_FACTOR_MULTIPLIER),
     162                                              (uint32_t)(yScaleFactor * VBOX_OGL_SCALE_FACTOR_MULTIPLIER));
     163        }
     164    }
     165
     166    /* Take unscaled HiDPI output mode into account: */
     167    const bool fUseUnscaledHiDPIOutput = gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid());
     168    frameBuffer()->setUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput);
    144169}
    145170
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h

    r53372 r53962  
    5656    void saveMachineViewSettings();
    5757
     58    /** Applies machine-view scale-factor. */
     59    void applyMachineViewScaleFactor();
     60
    5861    /** Resends guest size-hint if necessary. */
    5962    void maybeResendSizeHint();
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