VirtualBox

Changeset 27419 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 16, 2010 5:46:10 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: new core: check the video memory constrains on mode and screen switch

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp

    r27242 r27419  
    979979}
    980980
     981void VBoxProblemReporter::cannotSwitchScreenInSeamless(quint64 minVRAM)
     982{
     983    message(mainMachineWindowShown(), Error,
     984            tr("<p>Could not change the guest screen to this host screen "
     985               "due to insufficient guest video memory.</p>"
     986               "<p>You should configure the virtual machine to have at "
     987               "least <b>%1</b> of video memory.</p>")
     988            .arg(VBoxGlobal::formatSize(minVRAM)));
     989}
     990
     991int VBoxProblemReporter::cannotSwitchScreenInFullscreen(quint64 minVRAM)
     992{
     993    return message(mainMachineWindowShown(), Warning,
     994                   tr("<p>Could not change the guest screen to this host screen "
     995                      "due to insufficient guest video memory.</p>"
     996                      "<p>You should configure the virtual machine to have at "
     997                      "least <b>%1</b> of video memory.</p>"
     998                      "<p>Press <b>Ignore</b> to switch the screen anyway "
     999                      "or press <b>Cancel</b> to cancel the operation.</p>")
     1000                   .arg(VBoxGlobal::formatSize(minVRAM)),
     1001                   0, /* aAutoConfirmId */
     1002                   QIMessageBox::Ignore | QIMessageBox::Default,
     1003                   QIMessageBox::Cancel | QIMessageBox::Escape);
     1004}
     1005
    9811006int VBoxProblemReporter::cannotEnterFullscreenMode()
    9821007{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h

    r27028 r27419  
    226226    int cannotEnterFullscreenMode (ULONG aWidth, ULONG aHeight,
    227227                                   ULONG aBpp, ULONG64 aMinVRAM);
     228    void cannotSwitchScreenInSeamless(quint64 minVRAM);
     229    int cannotSwitchScreenInFullscreen(quint64 minVRAM);
    228230
    229231    int cannotEnterFullscreenMode();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.cpp

    r27337 r27419  
    2727#include "UIActionsPool.h"
    2828#include "UIMachineLogic.h"
     29#include "UISession.h"
     30#include "VBoxProblemReporter.h"
    2931
    3032/* Global includes */
     
    129131}
    130132
     133quint64 UIMultiScreenLayout::memoryRequirements() const
     134{
     135    return memoryRequirements(m_pScreenMap);
     136}
     137
    131138void UIMultiScreenLayout::sltScreenLayoutChanged(QAction *pAction)
    132139{
     
    136143
    137144    CMachine machine = m_pMachineLogic->session().GetMachine();
     145    QMap<int,int> *pTmpMap = new QMap<int,int>(*m_pScreenMap);
    138146    /* Search for the virtual screen which is currently displayed on the
    139147     * requested host screen. When there is one found, we swap both. */
    140     int r = m_pScreenMap->key(cHostScreen, -1);
     148    int r = pTmpMap->key(cHostScreen, -1);
    141149    if (r != -1)
    142         m_pScreenMap->insert(r, m_pScreenMap->value(cGuestScreen));
     150        pTmpMap->insert(r, pTmpMap->value(cGuestScreen));
    143151    /* Set the new host screen */
    144     m_pScreenMap->insert(cGuestScreen, cHostScreen);
    145 
     152    pTmpMap->insert(cGuestScreen, cHostScreen);
     153
     154    bool fSuccess = true;
     155    if (m_pMachineLogic->uisession()->isGuestAdditionsActive())
     156    {
     157        quint64 availBits = machine.GetVRAMSize() /* VRAM */
     158            * _1M /* MB to bytes */
     159            * 8; /* to bits */
     160        quint64 usedBits = memoryRequirements(pTmpMap);
     161
     162        fSuccess = availBits >= usedBits;
     163        if (!fSuccess)
     164        {
     165            /* We have to little video memory for the new layout, so say it to the
     166             * user and revert all changes. */
     167            if (m_pMachineLogic->visualStateType() == UIVisualStateType_Seamless)
     168                vboxProblem().cannotSwitchScreenInSeamless((((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
     169            else
     170                fSuccess = vboxProblem().cannotSwitchScreenInFullscreen((((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M) != QIMessageBox::Cancel;
     171        }
     172    }
     173    if (fSuccess)
     174    {
     175        /* Swap the temporary with the previous map. */
     176        delete m_pScreenMap;
     177        m_pScreenMap = pTmpMap;
     178    }
     179
     180    /* Update the menu items. Even if we can't switch we have to revert the
     181     * menu items. */
    146182    QList<QAction*> actions = m_pMachineLogic->actionsPool()->action(UIActionIndex_Menu_View)->menu()->actions();
    147183    /* Update the settings. */
     
    160196    }
    161197
    162     emit screenLayoutChanged();
    163 }
    164 
     198    /* On success inform the observer. */
     199    if (fSuccess)
     200        emit screenLayoutChanged();
     201}
     202
     203quint64 UIMultiScreenLayout::memoryRequirements(const QMap<int, int> *pScreenLayout) const
     204{
     205    int guestBpp = m_pMachineLogic->uisession()->session().GetConsole().GetDisplay().GetBitsPerPixel();
     206    quint64 usedBits = 0;
     207    for (int i = 0; i < m_cGuestScreens; ++ i)
     208    {
     209        QRect screen = QApplication::desktop()->availableGeometry(pScreenLayout->value(i, 0));
     210        usedBits += screen.width() * /* display width */
     211                    screen.height() * /* display height */
     212                    guestBpp + /* guest bits per pixel */
     213                    _1M * 8; /* current cache per screen - may be changed in future */
     214    }
     215    usedBits += 4096 * 8; /* adapter info */
     216    return usedBits;
     217}
     218
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.h

    r27335 r27419  
    4646    int guestScreenCount() const;
    4747    int hostScreenForGuestScreen(int screenId) const;
     48    quint64 memoryRequirements() const;
    4849
    4950signals:
     
    5556
    5657private:
     58
     59    quint64 memoryRequirements(const QMap<int, int> *pScreenLayout) const;
    5760
    5861    /* Private member vars */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r27365 r27419  
    6868    /* Temporary get a machine object: */
    6969    const CMachine &machine = uisession()->session().GetMachine();
    70     const CConsole &console = uisession()->session().GetConsole();
    7170
    7271    int cHostScreens = m_pScreenLayout->hostScreenCount();
     
    8483    if (uisession()->isGuestAdditionsActive())
    8584    {
    86         ULONG64 availBits = machine.GetVRAMSize() /* VRAM */
    87                           * _1M /* MB to bytes */
    88                           * 8; /* to bits */
    89         ULONG guestBpp = console.GetDisplay().GetBitsPerPixel();
    90         ULONG64 usedBits = 0;
    91         for (int i = 0; i < cGuestScreens; ++ i)
    92         {
    93             // TODO_NEW_CORE: really take the screen geometry into account the
    94             // different fb will be displayed. */
    95             QRect screen = QApplication::desktop()->screenGeometry(i);
    96             usedBits += screen.width() /* display width */
    97                       * screen.height() /* display height */
    98                       * guestBpp
    99                       + _1M * 8; /* current cache per screen - may be changed in future */
    100         }
    101         usedBits += 4096 * 8; /* adapter info */
    102 
     85        quint64 availBits = machine.GetVRAMSize() /* VRAM */
     86                            * _1M /* MB to bytes */
     87                            * 8; /* to bits */
     88        quint64 usedBits = m_pScreenLayout->memoryRequirements();
    10389        if (availBits < usedBits)
    10490        {
    105 //            int result = vboxProblem().cannotEnterFullscreenMode(screen.width(), screen.height(), guestBpp,
    106 //                                                                 (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
    107             int result = vboxProblem().cannotEnterFullscreenMode(0, 0, guestBpp,
     91            int result = vboxProblem().cannotEnterFullscreenMode(0, 0, 0,
    10892                                                                 (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
    10993            if (result == QIMessageBox::Cancel)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp

    r27381 r27419  
    6666    /* Temporary get a machine object: */
    6767    const CMachine &machine = uisession()->session().GetMachine();
    68     const CConsole &console = uisession()->session().GetConsole();
    6968
    7069    int cHostScreens = m_pScreenLayout->hostScreenCount();
     
    8281    if (uisession()->isGuestAdditionsActive())
    8382    {
    84         ULONG64 availBits = machine.GetVRAMSize() /* VRAM */
    85                           * _1M /* MB to bytes */
    86                           * 8; /* to bits */
    87         ULONG guestBpp = console.GetDisplay().GetBitsPerPixel();
    88         ULONG64 usedBits = 0;
    89         for (int i = 0; i < cGuestScreens; ++ i)
    90         {
    91             // TODO_NEW_CORE: really take the screen geometry into account the
    92             // different fb will be displayed. */
    93             QRect screen = QApplication::desktop()->availableGeometry(i);
    94             usedBits += screen.width() /* display width */
    95                       * screen.height() /* display height */
    96                       * guestBpp
    97                       + _1M * 8; /* current cache per screen - may be changed in future */
    98         }
    99         usedBits += 4096 * 8; /* adapter info */
    100 
     83        quint64 availBits = machine.GetVRAMSize() /* VRAM */
     84                            * _1M /* MB to bytes */
     85                            * 8; /* to bits */
     86        quint64 usedBits = m_pScreenLayout->memoryRequirements();
    10187        if (availBits < usedBits)
    10288        {
    103 //          vboxProblem().cannotEnterSeamlessMode(screen.width(), screen.height(), guestBpp,
    104 //                                                (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
    105             vboxProblem().cannotEnterSeamlessMode(0, 0, guestBpp,
     89            vboxProblem().cannotEnterSeamlessMode(0, 0, 0,
    10690                                                  (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
    10791            return false;
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