VirtualBox

Ignore:
Timestamp:
May 28, 2014 9:12:15 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
93991
Message:

Main,Frontends: IDisplay provides the guest screen bitmap to frontends.

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

Legend:

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

    r51359 r51436  
    3333
    3434#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     35
     36#include "CConsole.h"
     37#include "CDisplay.h"
    3538
    3639#if defined (Q_OS_WIN32)
     
    282285
    283286    /* Confirm RequestResize: */
     287    return S_OK;
     288}
     289
     290void UIFrameBuffer::notifyChange(ULONG aScreenId)
     291{
     292    /* Disable screen updates. */
     293    lock();
     294
     295    if (mpPendingSourceBitmap.isNull())
     296    {
     297        /* Do nothing. Change event already processed. */
     298        LogRelFlow(("notifyChange: already processed.\n"));
     299        unlock();
     300        return;
     301    }
     302
     303    /* Disable screen updates. */
     304    mfUpdates = false;
     305
     306    /* Release the current bitmap and keep the pending one. */
     307    mpSourceBitmap = mpPendingSourceBitmap;
     308    mpPendingSourceBitmap = 0;
     309
     310    unlock();
     311
     312    BYTE *pAddress = NULL;
     313    ULONG ulWidth = 0;
     314    ULONG ulHeight = 0;
     315    ULONG ulBitsPerPixel = 0;
     316    ULONG ulBytesPerLine = 0;
     317    ULONG ulPixelFormat = 0;
     318
     319    mpSourceBitmap.QueryBitmapInfo(pAddress,
     320                                   ulWidth,
     321                                   ulHeight,
     322                                   ulBitsPerPixel,
     323                                   ulBytesPerLine,
     324                                   ulPixelFormat);
     325
     326    UIResizeEvent e(FramebufferPixelFormat_Opaque, pAddress,
     327                    ulBitsPerPixel, ulBytesPerLine, ulWidth, ulHeight);
     328    resizeEvent(&e);
     329}
     330
     331STDMETHODIMP UIFrameBuffer::NotifyChange(ULONG aScreenId,
     332                                         ULONG aXOrigin,
     333                                         ULONG aYOrigin,
     334                                         ULONG aWidth,
     335                                         ULONG aHeight)
     336{
     337    LogRelFlow(("NotifyChange: %d %d,%d %dx%d\n",
     338                aScreenId, aXOrigin, aYOrigin, aWidth, aHeight));
     339
     340    /* Obtain the new screen bitmap. */
     341    lock();
     342
     343    /* Make sure frame-buffer is used: @todo still required? */
     344    if (m_fIsMarkedAsUnused)
     345    {
     346        LogRelFlow(("UIFrameBuffer::NotifyChange: Ignored!\n"));
     347        unlock();
     348        return E_FAIL;
     349    }
     350
     351    /* Save the new bitmap. */
     352    mpPendingSourceBitmap = 0;
     353    m_pMachineView->session().GetConsole().GetDisplay().QuerySourceBitmap(aScreenId, mpPendingSourceBitmap);
     354
     355    unlock();
     356
     357    /* Widget resize is NOT thread-safe and *probably* never will be,
     358     * We have to notify machine-view with the async-signal to perform resize operation. */
     359    LogRelFlow(("UIFrameBuffer::NotifyChange: Sending to async-handler...\n"));
     360    emit sigNotifyChange(aScreenId, aWidth, aHeight);
     361
     362    RTThreadYield();
     363
    284364    return S_OK;
    285365}
     
    606686            m_pMachineView, SLOT(sltHandleRequestResize(int, uchar*, int, int, int, int)),
    607687            Qt::QueuedConnection);
     688    connect(this, SIGNAL(sigNotifyChange(ulong, int, int)),
     689            m_pMachineView, SLOT(sltHandleNotifyChange(ulong, int, int)),
     690            Qt::QueuedConnection);
    608691    connect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)),
    609692            m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)),
     
    621704    disconnect(this, SIGNAL(sigRequestResize(int, uchar*, int, int, int, int)),
    622705               m_pMachineView, SLOT(sltHandleRequestResize(int, uchar*, int, int, int, int)));
     706    disconnect(this, SIGNAL(sigNotifyChange(ulong, int, int)),
     707               m_pMachineView, SLOT(sltHandleNotifyChange(ulong, int, int)));
    623708    disconnect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)),
    624709               m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r51187 r51436  
    2828/* COM includes: */
    2929#include "CFramebuffer.h"
     30#include "CDisplaySourceBitmap.h"
    3031
    3132/* Other VBox includes: */
     
    9697                          int iBitsPerPixel, int iBytesPerLine,
    9798                          int iWidth, int iHeight);
     99    void sigNotifyChange(ulong uScreenId, int iWidth, int iHeight);
    98100    void sigNotifyUpdate(int iX, int iY, int iWidth, int iHeight);
    99101    void sigSetVisibleRegion(QRegion region);
     
    150152                              ULONG uWidth, ULONG uHeight,
    151153                              BOOL *pbFinished);
     154    STDMETHOD(NotifyChange)(ULONG aScreenId,
     155                            ULONG aXOrigin,
     156                            ULONG aYOrigin,
     157                            ULONG aWidth,
     158                            ULONG aHeight);
    152159
    153160    STDMETHOD(NotifyUpdate) (ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight);
     
    196203    virtual void paintEvent(QPaintEvent *pEvent) = 0;
    197204    virtual void applyVisibleRegion(const QRegion &region);
     205
     206    void notifyChange(ulong uScreenId);
    198207
    199208#ifdef VBOX_WITH_VIDEOHWACCEL
     
    230239    bool m_fIsMarkedAsUnused;
    231240    bool m_fIsAutoEnabled;
     241
     242    CDisplaySourceBitmap mpSourceBitmap;
     243    CDisplaySourceBitmap mpPendingSourceBitmap;
     244    bool mfUpdates;
    232245
    233246    /* To avoid a seamless flicker,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQImage.cpp

    r51404 r51436  
    145145    else
    146146        popupCenter().forgetAboutWrongColorDepth(m_pMachineView->machineWindow());
     147    lock();
     148    mfUpdates = true;
     149    unlock();
    147150}
    148151
     
    161164    if (!m_pMachineView)
    162165        return;
     166       
     167    lock();
     168    if (!mfUpdates)
     169    {
     170       unlock();
     171       return;
     172    }
    163173
    164174    /* If the machine is NOT in 'running', 'paused' or 'saving' state,
     
    203213            break;
    204214    }
     215    unlock();
    205216}
    206217
     
    376387     * 2. or the machine is in the state which breaks link between
    377388     *    the framebuffer and the actual video-memory: */
    378     m_img = QImage(m_width, m_height, QImage::Format_RGB32);
    379     m_img.fill(0);
    380     m_uPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
    381     m_bUsesGuestVRAM = false;
    382 }
    383 
     389    if (!mpSourceBitmap.isNull())
     390    {
     391        BYTE *pAddress = NULL;
     392        ULONG ulWidth = 0;
     393        ULONG ulHeight = 0;
     394        ULONG ulBitsPerPixel = 0;
     395        ULONG ulBytesPerLine = 0;
     396        ULONG ulPixelFormat = 0;
     397
     398        mpSourceBitmap.QueryBitmapInfo(pAddress,
     399                                       ulWidth,
     400                                       ulHeight,
     401                                       ulBitsPerPixel,
     402                                       ulBytesPerLine,
     403                                       ulPixelFormat);
     404
     405        m_img = QImage(pAddress, ulWidth, ulHeight, ulBytesPerLine, QImage::Format_RGB32);
     406        m_uPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
     407        m_bUsesGuestVRAM = true;
     408    }
     409}
     410
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r51404 r51436  
    276276    }
    277277
    278     /* Report to the VM thread that we finished resizing: */
    279     session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    280 
    281278    /* Emit a signal about guest was resized: */
    282279    emit resizeHintDone();
     
    288285                (unsigned long)m_uScreenId, iPixelFormat,
    289286                iBitsPerPixel, iBytesPerLine, iWidth, iHeight));
     287}
     288
     289void UIMachineView::sltHandleNotifyChange(ulong uScreenId, int iWidth, int iHeight)
     290{
     291    LogRelFlow(("UIMachineView::HandleNotifyChange: Screen=%d, Size=%dx%d.\n",
     292                (unsigned long)m_uScreenId, iWidth, iHeight));
     293
     294    // TODO: Move to appropriate place!
     295    /* Some situations require frame-buffer resize-events to be ignored at all,
     296     * leaving machine-window, machine-view and frame-buffer sizes preserved: */
     297    if (uisession()->isGuestResizeIgnored())
     298        return;
     299
     300    /* If machine-window is visible: */
     301    if (uisession()->isScreenVisible(m_uScreenId))
     302    {
     303        // TODO: Move to appropriate place!
     304        /* Adjust 'scale' mode for current machine-view size: */
     305        if (visualStateType() == UIVisualStateType_Scale)
     306            frameBuffer()->setScaledSize(size());
     307
     308        /* Perform frame-buffer mode-change: */
     309        frameBuffer()->notifyChange(uScreenId);
     310
     311        /* Scale-mode doesn't need this.. */
     312        if (visualStateType() != UIVisualStateType_Scale)
     313        {
     314            /* Adjust maximum-size restriction for machine-view: */
     315            setMaximumSize(sizeHint());
     316
     317            /* Disable the resize hint override hack: */
     318            m_sizeHintOverride = QSize(-1, -1);
     319
     320            /* Force machine-window update own layout: */
     321            QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest);
     322
     323            /* Update machine-view sliders: */
     324            updateSliders();
     325
     326            /* By some reason Win host forgets to update machine-window central-widget
     327             * after main-layout was updated, let's do it for all the hosts: */
     328            machineWindow()->centralWidget()->update();
     329
     330            /* Normalize machine-window geometry: */
     331            if (visualStateType() == UIVisualStateType_Normal)
     332                machineWindow()->normalizeGeometry(true /* adjust position */);
     333        }
     334
     335#ifdef Q_WS_MAC
     336        /* Update MacOS X dock icon size: */
     337        machineLogic()->updateDockIconSize(screenId(), iWidth, iHeight);
     338#endif /* Q_WS_MAC */
     339    }
     340
     341    /* Emit a signal about guest was resized: */
     342    emit resizeHintDone();
     343
     344    LogRelFlow(("UIMachineView::ResizeHandled: Screen=%d, Size=%dx%d.\n",
     345                (unsigned long)m_uScreenId, iWidth, iHeight));
    290346}
    291347
     
    354410                    /* Ask for full guest display update (it will also update
    355411                     * the viewport through IFramebuffer::NotifyUpdate): */
    356                     if (m_previousState == KMachineState_Paused ||
    357                         m_previousState == KMachineState_TeleportingPausedVM)
    358                     {
    359                         CDisplay dsp = session().GetConsole().GetDisplay();
    360                         dsp.InvalidateAndUpdate();
    361                     }
     412                    CDisplay dsp = session().GetConsole().GetDisplay();
     413                    dsp.InvalidateAndUpdate();
    362414                }
    363415            }
     
    497549        Assert(!display.isNull());
    498550        CFramebuffer fb(NULL);
    499         LONG XOrigin, YOrigin;
    500551        /* Check if the framebuffer is already assigned;
    501552         * in this case we do not need to re-assign it neither do we need to AddRef. */
    502         display.GetFramebuffer(m_uScreenId, fb, XOrigin, YOrigin);
     553        display.QueryFramebuffer(m_uScreenId, fb);
    503554        if (fb.raw() != m_pFrameBuffer) /* <-this will evaluate to true iff no framebuffer is yet assigned */
    504555        {
    505556            m_pFrameBuffer->AddRef();
    506557        }
    507         /* Always perform SetFramebuffer to ensure 3D gets notified: */
    508         display.SetFramebuffer(m_uScreenId, CFramebuffer(m_pFrameBuffer));
     558        /* Always perform AttachFramebuffer to ensure 3D gets notified: */
     559        if (!fb.isNull())
     560            display.DetachFramebuffer(m_uScreenId);
     561        display.AttachFramebuffer(m_uScreenId, CFramebuffer(m_pFrameBuffer));
    509562    }
    510563
     
    629682    /* Temporarily detach the framebuffer from IDisplay before detaching
    630683     * from view in order to respect the thread synchonisation logic (see UIFrameBuffer.h).
    631      * Note: VBOX_WITH_CROGL additionally requires us to call SetFramebuffer
     684     * Note: VBOX_WITH_CROGL additionally requires us to call DetachFramebuffer
    632685     * to ensure 3D gets notified of view being destroyed... */
    633686    CDisplay display = session().GetConsole().GetDisplay();
    634     display.SetFramebuffer(m_uScreenId, CFramebuffer(NULL));
     687    display.DetachFramebuffer(m_uScreenId);
    635688
    636689    /* Detach framebuffer from view: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r51187 r51436  
    9797                                int iBitsPerPixel, int iBytesPerLine,
    9898                                int iWidth, int iHeight);
     99
     100    /* Handler: Frame-buffer NotifyChange stuff: */
     101    virtual void sltHandleNotifyChange(ulong uScreenId, int iWidth, int iHeight);
    99102
    100103    /* Handler: Frame-buffer NotifyUpdate stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r51395 r51436  
    12301230            /* Detach framebuffer from Display: */
    12311231            CDisplay display = session().GetConsole().GetDisplay();
    1232             display.SetFramebuffer(i, CFramebuffer(NULL));
     1232            display.DetachFramebuffer(i);
    12331233            /* Release framebuffer reference: */
    12341234            pFb->Release();
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