VirtualBox

Changeset 3807 in vbox for trunk/src


Ignore:
Timestamp:
Jul 24, 2007 11:17:40 AM (17 years ago)
Author:
vboxsync
Message:

FE/Qt: Don't use guest VRAM directly in QImage mode when color depth is other than 32, 8, or 1 bit and show a reminder if color depth is not 32 bit in the guest OS.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h

    r3736 r3807  
    210210    bool hostkey_in_capture : 1;
    211211
    212     bool ignore_mainwnd_resize : 1;
     212    bool mIgnoreMainwndResize : 1;
    213213    bool mAutoresizeGuest : 1;
    214214
     
    248248#endif
    249249
    250     VBoxFrameBuffer *fb;
    251     CConsoleCallback callback;
     250    VBoxFrameBuffer *mFrameBuf;
     251    CConsoleCallback mCallback;
    252252
    253253    friend class VBoxConsoleCallback;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r3718 r3807  
    5454    // helpers
    5555
    56     int message (
    57         QWidget *parent, Type type, const QString &msg,
    58         const QString &details = QString::null,
    59         const char *autoConfirmId = 0,
    60         int b1 = 0, int b2 = 0, int b3 = 0,
    61         const char *name = 0
    62     );
    63 
    64     int message (
    65         QWidget *parent, Type type, const QString &msg,
    66         const char *autoConfirmId,
    67         int b1 = 0, int b2 = 0, int b3 = 0,
    68         const char *name = 0
    69     ) {
     56    int message (QWidget *parent, Type type, const QString &msg,
     57                 const QString &details = QString::null,
     58                 const char *autoConfirmId = NULL,
     59                 int b1 = 0, int b2 = 0, int b3 = 0,
     60                 const char *name = 0);
     61
     62    int message (QWidget *parent, Type type, const QString &msg,
     63                 const char *autoConfirmId,
     64                 int b1 = 0, int b2 = 0, int b3 = 0,
     65                 const char *name = 0)
     66    {
    7067        return message (parent, type, msg, QString::null, autoConfirmId,
    7168                        b1, b2, b3, name);
    7269    }
    7370
    74     bool messageYesNo (
    75         QWidget *parent, Type type, const QString &msg,
    76         const QString &details = QString::null,
    77         const char *autoConfirmId = 0,
    78         const char *name = 0
    79     );
    80 
    81     bool messageYesNo (
    82         QWidget *parent, Type type, const QString &msg,
    83         const char *autoConfirmId,
    84         const char *name = 0
    85     ) {
     71    bool messageYesNo (QWidget *parent, Type type, const QString &msg,
     72                       const QString &details = QString::null,
     73                       const char *autoConfirmId = 0,
     74                       const char *name = 0);
     75
     76    bool messageYesNo (QWidget *parent, Type type, const QString &msg,
     77                       const char *autoConfirmId,
     78                       const char *name = 0)
     79    {
    8680        return messageYesNo (parent, type, msg, QString::null, autoConfirmId, name);
    8781    }
    8882
    89     bool showModalProgressDialog (
    90         CProgress &aProgress, const QString &aTitle, QWidget *aParent,
    91         int aMinDuration = 2000
    92     );
     83    bool showModalProgressDialog (CProgress &aProgress, const QString &aTitle,
     84                                  QWidget *aParent, int aMinDuration = 2000);
    9385
    9486    QWidget *mainWindowShown();
     
    219211                                   const QString &hostKey);
    220212
     213    void remindAboutWrongColorDepth (ulong aRealBPP, ulong aWantedBPP);
     214
    221215    void cannotRunInSelectorMode();
    222216
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r3767 r3807  
    518518    , hostkey_pressed (false)
    519519    , hostkey_alone (false)
    520     , ignore_mainwnd_resize (true)
     520    , mIgnoreMainwndResize (true)
    521521    , mAutoresizeGuest (false)
    522522    , mIsAdditionsActive (false)
     
    576576    tid = 0;
    577577#endif
    578     fb = 0;
     578    mFrameBuf = 0;
    579579
    580580    LogFlowFunc (("Rendering mode: %d\n", mode));
     
    590590#if defined (VBOX_GUI_USE_QIMAGE)
    591591        case VBoxDefs::QImageMode:
    592             fb = new VBoxQImageFrameBuffer (this);
     592            mFrameBuf = new VBoxQImageFrameBuffer (this);
    593593            break;
    594594#endif
    595595#if defined (VBOX_GUI_USE_SDL)
    596596        case VBoxDefs::SDLMode:
    597             fb = new VBoxSDLFrameBuffer (this);
     597            mFrameBuf = new VBoxSDLFrameBuffer (this);
    598598            /*
    599599             *  disable scrollbars because we cannot correctly draw in a
     
    606606#if defined (VBOX_GUI_USE_DDRAW)
    607607        case VBoxDefs::DDRAWMode:
    608             fb = new VBoxDDRAWFrameBuffer (this);
     608            mFrameBuf = new VBoxDDRAWFrameBuffer (this);
    609609            break;
    610610#endif
     
    617617
    618618#if defined (VBOX_GUI_USE_DDRAW)
    619     if (!fb || fb->address () == NULL)
    620     {
    621         if (fb)
    622             delete fb;
     619    if (!mFrameBuf || mFrameBuf->address () == NULL)
     620    {
     621        if (mFrameBuf)
     622            delete mFrameBuf;
    623623        mode = VBoxDefs::QImageMode;
    624         fb = new VBoxQImageFrameBuffer (this);
    625     }
    626 #endif
    627 
    628     if (fb)
    629     {
    630         fb->AddRef();
    631         display.RegisterExternalFramebuffer (CFramebuffer (fb));
     624        mFrameBuf = new VBoxQImageFrameBuffer (this);
     625    }
     626#endif
     627
     628    if (mFrameBuf)
     629    {
     630        mFrameBuf->AddRef();
     631        display.RegisterExternalFramebuffer (CFramebuffer (mFrameBuf));
    632632    }
    633633
    634634    /* setup the callback */
    635     callback = CConsoleCallback (new VBoxConsoleCallback (this));
    636     cconsole.RegisterCallback (callback);
     635    mCallback = CConsoleCallback (new VBoxConsoleCallback (this));
     636    cconsole.RegisterCallback (mCallback);
    637637    AssertWrapperOk (cconsole);
    638638
     
    671671        killTimer (tid);
    672672#endif
    673     if (fb)
     673    if (mFrameBuf)
    674674    {
    675675        /* detach our framebuffer from Display */
     
    678678        display.SetupInternalFramebuffer (0);
    679679        /* release the reference */
    680         fb->Release();
    681     }
    682 
    683     cconsole.UnregisterCallback (callback);
     680        mFrameBuf->Release();
     681    }
     682
     683    cconsole.UnregisterCallback (mCallback);
    684684}
    685685
     
    700700#endif
    701701    {
    702         return QSize (fb->width() + frameWidth() * 2,
    703                       fb->height() + frameWidth() * 2);
     702        return QSize (mFrameBuf->width() + frameWidth() * 2,
     703                      mFrameBuf->height() + frameWidth() * 2);
    704704    }
    705705}
     
    874874void VBoxConsoleView::onViewOpened()
    875875{
    876     /* Variable <ignore_mainwnd_resize> is initially "true" to ignore QT
     876    /* Variable mIgnoreMainwndResize was initially "true" to ignore QT
    877877     * initial resize event in case of auto-resize feature is on.
    878      * Currently initial resize event is already processed, so switching
    879      * the ignore_mainwnd_resize to "false" to process all further resize
    880      * events as user resize events. */
    881     ignore_mainwnd_resize = false;
     878     * Currently, initial resize event is already processed, so we set
     879     * mIgnoreMainwndResize to "false" to process all further resize
     880     * events as user-initiated window resize events. */
     881    mIgnoreMainwndResize = false;
    882882}
    883883
     
    906906            case VBoxDefs::ResizeEventType:
    907907            {
    908                 bool old_ignore_mainwnd_resize = ignore_mainwnd_resize;
    909                 ignore_mainwnd_resize = true;
     908                bool oldIgnoreMainwndResize = mIgnoreMainwndResize;
     909                mIgnoreMainwndResize = true;
    910910
    911911                VBoxResizeEvent *re = (VBoxResizeEvent *) e;
    912                 LogFlow (("VBoxDefs::ResizeEventType: %d,%d\n",
    913                           re->width(), re->height()));
     912                LogFlow (("VBoxDefs::ResizeEventType: %d x %d x %d bpp\n",
     913                          re->width(), re->height(), re->bitsPerPixel()));
    914914
    915915                /* do frame buffer dependent resize */
    916                 fb->resizeEvent (re);
     916                mFrameBuf->resizeEvent (re);
    917917                viewport()->unsetCursor();
    918918
     
    947947                cconsole.GetDisplay().ResizeCompleted(0);
    948948
    949                 ignore_mainwnd_resize = old_ignore_mainwnd_resize;
     949                mIgnoreMainwndResize = oldIgnoreMainwndResize;
    950950
    951951                return true;
     
    12351235                 *  in order to possibly adjust the direct screen blitting.
    12361236                 */
    1237                 if (fb)
    1238                     fb->moveEvent( (QMoveEvent *) e );
     1237                if (mFrameBuf)
     1238                    mFrameBuf->moveEvent ((QMoveEvent *) e);
    12391239                break;
    12401240            }
     
    12761276            case QEvent::Resize:
    12771277            {
    1278                 if (!ignore_mainwnd_resize)
     1278                if (!mIgnoreMainwndResize)
    12791279                {
    12801280                    if (mIsAdditionsActive && mAutoresizeGuest)
    12811281                        resize_hint_timer->start (300, TRUE);
     1282                    /// @todo disabled for the time being since seems to be not
     1283                    //  necessary anymore
     1284#if 0
    12821285                    /* During window maximization WindowStateChange event is
    1283                      * processed before Resize event, so the ignore_mainwnd_resize
     1286                     * processed before Resize event, so the mIgnoreMainwndResize
    12841287                     * variable should be set to true here in case of mainwnd is
    12851288                     * maximized or in fullscreen state. */
    12861289                    /* Not sure if it is really required */
    1287                     //if (mainwnd->isMaximized() || mainwnd->isTrueFullscreen()
    1288                     //                           || mainwnd->isTrueSeamless())
    1289                     //    ignore_mainwnd_resize = true;
     1290                    if (mainwnd->isMaximized() || mainwnd->isTrueFullscreen()
     1291                                               || mainwnd->isTrueSeamless())
     1292                        mIgnoreMainwndResize = true;
     1293#endif
    12901294                }
    12911295                break;
     
    18681872    }
    18691873
    1870     ignore_mainwnd_resize = false;
     1874    mIgnoreMainwndResize = false;
    18711875}
    18721876
     
    23482352        case CEnums::Paused:
    23492353        {
    2350             if (mode != VBoxDefs::TimerMode && fb)
     2354            if (mode != VBoxDefs::TimerMode && mFrameBuf)
    23512355            {
    23522356                /*
     
    23542358                 *  needs a 32bpp image
    23552359                 */
    2356                 QImage shot = QImage (fb->width(), fb->height(), 32, 0);
     2360                QImage shot = QImage (mFrameBuf->width(), mFrameBuf->height(), 32, 0);
    23572361                CDisplay dsp = cconsole.GetDisplay();
    23582362                dsp.TakeScreenShot (shot.bits(), shot.width(), shot.height());
     
    23792383            if (last_state == CEnums::Paused)
    23802384            {
    2381                 if (mode != VBoxDefs::TimerMode && fb)
     2385                if (mode != VBoxDefs::TimerMode && mFrameBuf)
    23822386                {
    23832387                    /* reset the pixmap to free memory */
     
    24592463        {
    24602464            /* delegate the paint function to the VBoxFrameBuffer interface */
    2461             fb->paintEvent (pe);
     2465            mFrameBuf->paintEvent (pe);
    24622466            return;
    24632467        }
     
    30523056        QSize sz (mainwnd->centralWidget()->size());
    30533057        sz -= QSize (frameWidth() * 2, frameWidth() * 2);
    3054         LogFlowFunc (("Will suggest %d,%d\n", sz.width(), sz.height()));
     3058        LogFlowFunc (("Will suggest %d x %d\n", sz.width(), sz.height()));
    30553059
    30563060        cconsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0);
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFrameBuffer.cpp

    r3763 r3807  
    2424
    2525#include "VBoxConsoleView.h"
     26#include "VBoxProblemReporter.h"
     27#include "VBoxGlobal.h"
    2628
    2729#include <qapplication.h>
     
    375377    mHgt = re->height();
    376378
     379    bool remind = false;
    377380    bool fallback = false;
    378381
     
    382385        switch (re->bitsPerPixel())
    383386        {
     387            /* 32-, 8- and 1-bpp are the only depths suported by QImage */
    384388            case 32:
    385             case 24:
    386             case 16:
     389                break;
     390            case 8:
     391            case 1:
     392                remind = true;
    387393                break;
    388394            default:
     395                remind = true;
    389396                fallback = true;
    390397                break;
     
    397404                ((mWdt * re->bitsPerPixel() + 31) / 32) * 4;
    398405            Assert (!fallback);
    399 
    400406            if (!fallback)
    401407            {
    402408                mImg = QImage ((uchar *) re->VRAM(), mWdt, mHgt,
    403409                               re->bitsPerPixel(), NULL, 0, QImage::LittleEndian);
    404                 mPixelFormat = re->pixelFormat();
     410                mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
    405411                mUsesGuestVRAM = true;
    406412            }
     
    419425        mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
    420426        mUsesGuestVRAM = false;
     427    }
     428
     429    if (remind)
     430    {
     431        class RemindEvent : public VBoxAsyncEvent
     432        {
     433            ulong mRealBPP;
     434        public:
     435            RemindEvent (ulong aRealBPP)
     436                : mRealBPP (aRealBPP) {}
     437            void handle()
     438            {
     439                vboxProblem().remindAboutWrongColorDepth (mRealBPP, 32);
     440            }
     441        };
     442        (new RemindEvent (re->bitsPerPixel()))->post();
    421443    }
    422444}
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r3802 r3807  
    267267 *      third button code or 0, see QIMessageBox
    268268 *  @param  name
    269  *      name of the underlying QIMessageBox object. If null, a value of
     269 *      name of the underlying QIMessageBox object. If NULL, a value of
    270270 *      autoConfirmId is used.
    271271 *
     
    273273 *      code of the button pressed by the user
    274274 */
    275 int VBoxProblemReporter::message (
    276     QWidget *parent, Type type, const QString &msg,
    277     const QString &details,
    278     const char *autoConfirmId,
    279     int b1, int b2, int b3,
    280     const char *name
    281 ) {
     275int VBoxProblemReporter::message (QWidget *parent, Type type, const QString &msg,
     276                                  const QString &details,
     277                                  const char *autoConfirmId,
     278                                  int b1, int b2, int b3,
     279                                  const char *name)
     280{
    282281    if (b1 == 0 && b2 == 0 && b3 == 0)
    283282        b1 = QIMessageBox::Ok | QIMessageBox::Default;
     
    13531352bool VBoxProblemReporter::remindAboutMouseIntegration (bool supportsAbsolute)
    13541353{
    1355     static const char *names [2] =
     1354    static const char *kNames [2] =
    13561355    {
    13571356        "remindAboutMouseIntegrationOff",
     
    13591358    };
    13601359
    1361     /* close the previous reminder if it is still active -- already outdated
    1362      * (the name of the modal window will correspond to autoConfirmId if
    1363      * it is our reminder) */
    1364     QWidget *modal = QApplication::activeModalWidget();
    1365     if (modal && !strcmp (modal->name(), names [int (!supportsAbsolute)]))
    1366         modal->close();
     1360    /* Close the previous (outdated) window if any. We use kName as
     1361     * autoConfirmId which is also used as the widget name by default. */
     1362    {
     1363        QWidget *outdated =
     1364            VBoxGlobal::findWidget (NULL, kNames [int (!supportsAbsolute)],
     1365                                    "QIMessageBox");
     1366        if (outdated)
     1367            outdated->close();
     1368    }
    13671369
    13681370    if (supportsAbsolute)
     
    13881390                "corresponding action from the menu bar."
    13891391                "</p>"),
    1390             names [1] /* autoConfirmId */);
     1392            kNames [1] /* autoConfirmId */);
    13911393
    13921394        return !(rc & AutoConfirmed);
     
    14001402                "display or pressing the host key) in order to use the "
    14011403                "mouse inside the guest OS.</p>"),
    1402             names [0] /* autoConfirmId */);
     1404            kNames [0] /* autoConfirmId */);
    14031405
    14041406        return !(rc & AutoConfirmed);
     
    14831485            .arg (hotKey).arg (hostKey),
    14841486        "remindAboutGoingSeamless");
     1487    NOREF(rc);
     1488}
     1489
     1490void VBoxProblemReporter::remindAboutWrongColorDepth (ulong aRealBPP,
     1491                                                      ulong aWantedBPP)
     1492{
     1493    const char *kName = "remindAboutWrongColorDepth";
     1494
     1495    /* Close the previous (outdated) window if any. We use kName as
     1496     * autoConfirmId which is also used as the widget name by default. */
     1497    {
     1498        QWidget *outdated = VBoxGlobal::findWidget (NULL, kName, "QIMessageBox");
     1499        if (outdated)
     1500            outdated->close();
     1501    }
     1502
     1503    int rc = message (&vboxGlobal().consoleWnd(), Info,
     1504        tr ("<p>The virtual machine window is optimized to work in "
     1505            "<b>%1&nbsp;bit</b> color mode but the color quality of the "
     1506            "virtual display is currently set to <b>%2&nbsp;bit</b>.</p>"
     1507            "<p>Please open the display properties dialog of the guest OS and "
     1508            "select a <b>%3&nbsp;bit</b> color mode to gain maximum "
     1509            "performance of the virtual video subsystem.</p>")
     1510            .arg (aWantedBPP).arg (aRealBPP).arg (aWantedBPP),
     1511        kName);
    14851512    NOREF(rc);
    14861513}
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