VirtualBox

Changeset 53912 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 22, 2015 11:52:40 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97784
Message:

FE/Qt: 6278: Support for scaled video-output: Unify some of the common code under reused wrappers.

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

Legend:

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

    r53910 r53912  
    195195    AssertMsg(size.isValid(), ("Size should be valid!\n"));
    196196
    197 #ifdef Q_WS_MAC
    198     /* Take the backing-scale-factor into account: */
    199     if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
    200     {
    201         const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
    202         if (dBackingScaleFactor > 1.0)
    203             size = QSize(size.width() * dBackingScaleFactor, size.height() * dBackingScaleFactor);
    204     }
    205 #endif /* Q_WS_MAC */
    206 
    207     /* Take the scale-factor into account: */
    208     const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    209     if (dScaleFactor != 1.0)
    210         size = QSize(size.width() / dScaleFactor, size.height() / dScaleFactor);
     197    /* Take the scale-factor(s) into account: */
     198    size = scaledBackward(size);
    211199
    212200    /* Expand current limitations: */
     
    744732    QSize size(m_pFrameBuffer->width(), m_pFrameBuffer->height());
    745733
    746     /* Take the scale-factor into account: */
    747     const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    748     if (dScaleFactor != 1.0)
    749         size = QSize(size.width() * dScaleFactor, size.height() * dScaleFactor);
    750 
    751 #ifdef Q_WS_MAC
    752     /* Take the backing-scale-factor into account: */
    753     if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
    754     {
    755         const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
    756         if (dBackingScaleFactor > 1.0)
    757             size = QSize(size.width() / dBackingScaleFactor, size.height() / dBackingScaleFactor);
    758     }
    759 #endif /* Q_WS_MAC */
     734    /* Take the scale-factor(s) into account: */
     735    size = scaledForward(size);
    760736
    761737#ifdef VBOX_WITH_DEBUGGER_GUI
     
    839815        size = QSize(800, 600);
    840816
    841     /* Take the scale-factor into account: */
    842     const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    843     if (dScaleFactor != 1.0)
    844         size = QSize(size.width() * dScaleFactor, size.height() * dScaleFactor);
    845 
    846 #ifdef Q_WS_MAC
    847     /* Take the backing-scale-factor into account: */
    848     if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
    849     {
    850         const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
    851         if (dBackingScaleFactor > 1.0)
    852             size = QSize(size.width() / dBackingScaleFactor, size.height() / dBackingScaleFactor);
    853     }
    854 #endif /* Q_WS_MAC */
     817    /* Take the scale-factor(s) into account: */
     818    size = scaledForward(size);
    855819
    856820    /* Return size: */
     
    983947    QSize v = QSize(frameBuffer()->width(), frameBuffer()->height());
    984948
    985     /* Take the scale-factor into account: */
    986     const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    987     if (dScaleFactor != 1.0)
    988         v = QSize(v.width() * dScaleFactor, v.height() * dScaleFactor);
    989 
    990 #ifdef Q_WS_MAC
    991     /* Take the backing-scale-factor into account: */
    992     if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
    993     {
    994         const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
    995         if (dBackingScaleFactor > 1.0)
    996             v = QSize(v.width() / dBackingScaleFactor, v.height() / dBackingScaleFactor);
    997     }
    998 #endif /* Q_WS_MAC */
     949    /* Take the scale-factor(s) into account: */
     950    v = scaledForward(v);
    999951
    1000952    /* No scroll bars needed: */
     
    14211373#endif /* Q_WS_X11 */
    14221374
     1375QSize UIMachineView::scaledForward(QSize size) const
     1376{
     1377    /* Take the scale-factor into account: */
     1378    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     1379    if (dScaleFactor != 1.0)
     1380        size = QSize(size.width() * dScaleFactor, size.height() * dScaleFactor);
     1381
     1382#ifdef Q_WS_MAC
     1383    /* Take the backing-scale-factor into account: */
     1384    if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
     1385    {
     1386        const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
     1387        if (dBackingScaleFactor > 1.0)
     1388            size = QSize(size.width() / dBackingScaleFactor, size.height() / dBackingScaleFactor);
     1389    }
     1390#endif /* Q_WS_MAC */
     1391
     1392    /* Return result: */
     1393    return size;
     1394}
     1395
     1396QSize UIMachineView::scaledBackward(QSize size) const
     1397{
     1398#ifdef Q_WS_MAC
     1399    /* Take the backing-scale-factor into account: */
     1400    if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
     1401    {
     1402        const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
     1403        if (dBackingScaleFactor > 1.0)
     1404            size = QSize(size.width() * dBackingScaleFactor, size.height() * dBackingScaleFactor);
     1405    }
     1406#endif /* Q_WS_MAC */
     1407
     1408    /* Take the scale-factor into account: */
     1409    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     1410    if (dScaleFactor != 1.0)
     1411        size = QSize(size.width() / dScaleFactor, size.height() / dScaleFactor);
     1412
     1413    /* Return result: */
     1414    return size;
     1415}
     1416
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r53892 r53912  
    256256#endif
    257257
     258    /** Scales passed size forward. */
     259    QSize scaledForward(QSize size) const;
     260    /** Scales passed size backward. */
     261    QSize scaledBackward(QSize size) const;
     262
    258263    /* Protected members: */
    259264    UIMachineWindow *m_pMachineWindow;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp

    r53909 r53912  
    3838# include "UIFrameBuffer.h"
    3939# include "UIExtraDataManager.h"
    40 # ifdef Q_WS_MAC
    41 #  include "VBoxUtils-darwin.h"
    42 # endif /* Q_WS_MAC */
    4340
    4441#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    152149    /* Acquire frame-buffer size: */
    153150    QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height());
    154 
    155     /* Take the scale-factor into account: */
    156     const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    157     if (dScaleFactor != 1.0)
    158         frameBufferSize = QSize(frameBufferSize.width() * dScaleFactor, frameBufferSize.height() * dScaleFactor);
    159 
    160 #ifdef Q_WS_MAC
    161     /* Take the backing-scale-factor into account: */
    162     if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
    163     {
    164         const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
    165         if (dBackingScaleFactor > 1.0)
    166             frameBufferSize = QSize(frameBufferSize.width() / dBackingScaleFactor, frameBufferSize.height() / dBackingScaleFactor);
    167     }
    168 #endif /* Q_WS_MAC */
    169 
     151    /* Take the scale-factor(s) into account: */
     152    frameBufferSize = scaledForward(frameBufferSize);
    170153    /* Check if we should adjust guest-screen to new size: */
    171154    if (frameBuffer()->isAutoEnabled() ||
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r53909 r53912  
    3737# include "UIExtraDataManager.h"
    3838# include "UIFrameBuffer.h"
    39 # ifdef Q_WS_MAC
    40 #  include "VBoxUtils-darwin.h"
    41 # endif /* Q_WS_MAC */
    4239
    4340#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    175172    /* Acquire frame-buffer size: */
    176173    QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height());
    177 
    178     /* Take the scale-factor into account: */
    179     const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    180     if (dScaleFactor != 1.0)
    181         frameBufferSize = QSize(frameBufferSize.width() * dScaleFactor, frameBufferSize.height() * dScaleFactor);
    182 
    183 #ifdef Q_WS_MAC
    184     /* Take the backing-scale-factor into account: */
    185     if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
    186     {
    187         const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
    188         if (dBackingScaleFactor > 1.0)
    189             frameBufferSize = QSize(frameBufferSize.width() / dBackingScaleFactor, frameBufferSize.height() / dBackingScaleFactor);
    190     }
    191 #endif /* Q_WS_MAC */
    192 
     174    /* Take the scale-factor(s) into account: */
     175    frameBufferSize = scaledForward(frameBufferSize);
    193176    /* Check if we should adjust guest-screen to new size: */
    194177    if (frameBufferSize != centralWidgetSize)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r53909 r53912  
    3737# include "UIFrameBuffer.h"
    3838# include "UIExtraDataManager.h"
    39 # ifdef Q_WS_MAC
    40 #  include "VBoxUtils-darwin.h"
    41 # endif /* Q_WS_MAC */
    4239
    4340/* COM includes: */
     
    169166    /* Acquire frame-buffer size: */
    170167    QSize frameBufferSize(frameBuffer()->width(), frameBuffer()->height());
    171 
    172     /* Take the scale-factor into account: */
    173     const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    174     if (dScaleFactor != 1.0)
    175         frameBufferSize = QSize(frameBufferSize.width() * dScaleFactor, frameBufferSize.height() * dScaleFactor);
    176 
    177 #ifdef Q_WS_MAC
    178     /* Take the backing-scale-factor into account: */
    179     if (gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid()))
    180     {
    181         const double dBackingScaleFactor = darwinBackingScaleFactor(machineWindow());
    182         if (dBackingScaleFactor > 1.0)
    183             frameBufferSize = QSize(frameBufferSize.width() / dBackingScaleFactor, frameBufferSize.height() / dBackingScaleFactor);
    184     }
    185 #endif /* Q_WS_MAC */
    186 
     168    /* Take the scale-factor(s) into account: */
     169    frameBufferSize = scaledForward(frameBufferSize);
    187170    /* Check if we should adjust guest-screen to new size: */
    188171    if (frameBuffer()->isAutoEnabled() ||
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