VirtualBox

Changeset 39063 in vbox


Ignore:
Timestamp:
Oct 20, 2011 4:41:44 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
74485
Message:

FE/Qt: do not re-create the framebuffer on every view switch (only implemented for QImage so far).

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

Legend:

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

    r39023 r39063  
    159159
    160160    NOREF(uScreenId);
    161     QApplication::postEvent (m_pMachineView,
    162                              new UIResizeEvent(uPixelFormat, pVRAM, uBitsPerPixel,
    163                                                uBytesPerLine, uWidth, uHeight));
     161    /* A resize event can happen while we are switching machine view classes,
     162     * but we synchronise afterwards so that shouldn't be a problem.  We must
     163     * temporarily remove the framebuffer in Display though while switching
     164     * to respect the thread synchronisation logic (see UIFrameBuffer.h). */
     165    if (m_pMachineView)
     166        QApplication::postEvent(m_pMachineView,
     167                                new UIResizeEvent(uPixelFormat, pVRAM,
     168                                                  uBitsPerPixel, uBytesPerLine,
     169                                                  uWidth, uHeight));
     170    else
     171    {
     172        /* Report to the VM thread that we finished resizing and rely on the
     173         * synchronisation when the new view is attached. */
     174        *pbFinished = TRUE;
     175        return S_OK;
     176    }
    164177
    165178    *pbFinished = FALSE;
     
    250263    AssertBreakpoint();
    251264}
     265#endif
    252266
    253267void UIFrameBuffer::setView(UIMachineView * pView)
     
    256270    m_WinId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0;
    257271}
    258 #endif
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r39023 r39063  
    276276#ifdef VBOX_GUI_USE_QIMAGE
    277277        case VBoxDefs::QImageMode:
     278        {
     279            UIFrameBuffer* pFrameBuffer = uisession()->frameBuffer(screenId());
     280            if (pFrameBuffer)
     281                pFrameBuffer->setView(this);
     282            else
     283            {
    278284# ifdef VBOX_WITH_VIDEOHWACCEL
    279             if (m_fAccelerate2DVideo)
    280             {
    281                 UIFrameBuffer* pFramebuffer = uisession()->frameBuffer(screenId());
    282                 if (pFramebuffer)
    283                     pFramebuffer->setView(this);
     285                if (m_fAccelerate2DVideo)
     286                {
     287                    /** these two additional template args is a workaround to
     288                     * this [VBox|UI] duplication
     289                     * @todo: they are to be removed once VBox stuff is gone */
     290                    pFrameBuffer = new VBoxOverlayFrameBuffer<UIFrameBufferQImage, UIMachineView, UIResizeEvent>(this, &machineWindowWrapper()->session(), (uint32_t)screenId());
     291                }
    284292                else
    285                 {
    286                     /* these two additional template args is a workaround to this [VBox|UI] duplication
    287                      * @todo: they are to be removed once VBox stuff is gone */
    288                     pFramebuffer = new VBoxOverlayFrameBuffer<UIFrameBufferQImage, UIMachineView, UIResizeEvent>(this, &machineWindowWrapper()->session(), (uint32_t)screenId());
    289                     uisession()->setFrameBuffer(screenId(), pFramebuffer);
    290                 }
    291                 m_pFrameBuffer = pFramebuffer;
    292             }
    293             else
    294                 m_pFrameBuffer = new UIFrameBufferQImage(this);
     293                    pFrameBuffer = new UIFrameBufferQImage(this);
    295294# else /* VBOX_WITH_VIDEOHWACCEL */
    296             m_pFrameBuffer = new UIFrameBufferQImage(this);
     295                pFrameBuffer = new UIFrameBufferQImage(this);
    297296# endif /* !VBOX_WITH_VIDEOHWACCEL */
    298             break;
     297                uisession()->setFrameBuffer(screenId(), pFrameBuffer);
     298            }
     299            m_pFrameBuffer = pFrameBuffer;
     300            break;
     301        }
    299302#endif /* VBOX_GUI_USE_QIMAGE */
    300303#ifdef VBOX_GUI_USE_QGLFB
     
    393396        CDisplay display = session().GetConsole().GetDisplay();
    394397        Assert(!display.isNull());
    395 #ifdef VBOX_WITH_VIDEOHWACCEL
    396398        CFramebuffer fb(NULL);
    397         if (m_fAccelerate2DVideo)
    398         {
    399             LONG XOrigin, YOrigin;
    400             /* Check if the framebuffer is already assigned;
    401              * in this case we do not need to re-assign it neither do we need to AddRef. */
    402             display.GetFramebuffer(m_uScreenId, fb, XOrigin, YOrigin);
    403         }
    404         if (fb.raw() != m_pFrameBuffer) /* <-this will evaluate to true iff m_fAccelerate2DVideo is disabled or iff no framebuffer is yet assigned */
    405 #endif /* VBOX_WITH_VIDEOHWACCEL */
     399        LONG XOrigin, YOrigin;
     400        /* Check if the framebuffer is already assigned;
     401         * in this case we do not need to re-assign it neither do we need to AddRef. */
     402        display.GetFramebuffer(m_uScreenId, fb, XOrigin, YOrigin);
     403        if (fb.raw() != m_pFrameBuffer) /* <-this will evaluate to true iff no framebuffer is yet assigned */
    406404        {
    407405            m_pFrameBuffer->AddRef();
     
    504502        /* Process pending frame-buffer resize events: */
    505503        QApplication::sendPostedEvents(this, VBoxDefs::ResizeEventType);
    506 #ifdef VBOX_WITH_VIDEOHWACCEL
    507         if (m_fAccelerate2DVideo)
    508         {
    509             /* When 2D is enabled we do not re-create Framebuffers. This is done to
    510              * 1. avoid 2D command loss during the time slot when no framebuffer is assigned to the display
    511              * 2. make it easier to preserve the current 2D state */
     504        if (   m_fAccelerate2DVideo
     505            || vboxGlobal().vmRenderMode() == VBoxDefs::QImageMode)
     506        {
    512507            Assert(m_pFrameBuffer == uisession()->frameBuffer(screenId()));
     508            CDisplay display = session().GetConsole().GetDisplay();
     509            /* Temporarily remove the framebuffer in Display while unsetting
     510             * the view in order to respect the thread synchonisation logic
     511             * (see UIFrameBuffer.h). */
     512            /** @note VBOX_WITH_CROGL additionally requires us to call
     513             * SetFramebuffer to ensure 3D gets notified of view being
     514             * destroyed */
     515            display.SetFramebuffer(m_uScreenId, CFramebuffer(NULL));
    513516            m_pFrameBuffer->setView(NULL);
    514 #ifdef VBOX_WITH_CROGL
    515             /* Call SetFramebuffer to ensure 3D gets notified of view being destroyed */
    516             CDisplay display = session().GetConsole().GetDisplay();
    517517            display.SetFramebuffer(m_uScreenId, CFramebuffer(m_pFrameBuffer));
    518 #endif
    519518        }
    520519        else
    521 #endif /* VBOX_WITH_VIDEOHWACCEL */
    522520        {
    523521            /* Warn framebuffer about its no more necessary: */
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