VirtualBox

Changeset 51458 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 29, 2014 11:56:56 AM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Frame-buffer NotifyChange event handling cleanup.

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

Legend:

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

    r51436 r51458  
    4949    , m_fIsMarkedAsUnused(false)
    5050    , m_fIsAutoEnabled(false)
     51    , m_fIsUpdatesAllowed(true)
    5152#ifdef Q_OS_WIN
    5253    , m_iRefCnt(0)
     
    288289}
    289290
    290 void UIFrameBuffer::notifyChange(ULONG aScreenId)
    291 {
    292     /* Disable screen updates. */
     291void UIFrameBuffer::notifyChange()
     292{
     293    /* Lock access to frame-buffer: */
    293294    lock();
    294295
    295     if (mpPendingSourceBitmap.isNull())
    296     {
    297         /* Do nothing. Change event already processed. */
    298         LogRelFlow(("notifyChange: already processed.\n"));
     296    /* If there is NO pending source bitmap: */
     297    if (m_pendingSourceBitmap.isNull())
     298    {
     299        /* Do nothing, change-event already processed: */
     300        LogRelFlow(("UIFrameBuffer::notifyChange: Already processed.\n"));
     301        /* Unlock access to frame-buffer: */
    299302        unlock();
     303        /* Return immediately: */
    300304        return;
    301305    }
    302306
    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 
     307    /* Disable screen updates: */
     308    m_fIsUpdatesAllowed = false;
     309
     310    /* Release the current bitmap and keep the pending one: */
     311    m_sourceBitmap = m_pendingSourceBitmap;
     312    m_pendingSourceBitmap = 0;
     313
     314    /* Unlock access to frame-buffer: */
    310315    unlock();
    311316
     317    /* Acquire source bitmap: */
    312318    BYTE *pAddress = NULL;
    313319    ULONG ulWidth = 0;
     
    316322    ULONG ulBytesPerLine = 0;
    317323    ULONG ulPixelFormat = 0;
    318 
    319     mpSourceBitmap.QueryBitmapInfo(pAddress,
     324    m_sourceBitmap.QueryBitmapInfo(pAddress,
    320325                                   ulWidth,
    321326                                   ulHeight,
     
    324329                                   ulPixelFormat);
    325330
     331    /* Perform frame-buffer resize: */
    326332    UIResizeEvent e(FramebufferPixelFormat_Opaque, pAddress,
    327333                    ulBitsPerPixel, ulBytesPerLine, ulWidth, ulHeight);
     
    329335}
    330336
    331 STDMETHODIMP 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. */
     337/**
     338 * EMT callback: Informs about source bitmap change.
     339 * @param uScreenId Guest screen number.
     340 * @param uX        Horizontal origin of the update rectangle, in pixels.
     341 * @param uY        Vertical origin of the update rectangle, in pixels.
     342 * @param uWidth    Width of the guest display, in pixels.
     343 * @param uHeight   Height of the guest display, in pixels.
     344 * @note  Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     345 * @note  Calls to this and #setMarkAsUnused method are synchronized between calling threads (from GUI side).
     346 */
     347STDMETHODIMP UIFrameBuffer::NotifyChange(ULONG uScreenId,
     348                                         ULONG uX,
     349                                         ULONG uY,
     350                                         ULONG uWidth,
     351                                         ULONG uHeight)
     352{
     353    /* Lock access to frame-buffer: */
    341354    lock();
    342355
    343     /* Make sure frame-buffer is used: @todo still required? */
     356    /* Make sure frame-buffer is used: */
    344357    if (m_fIsMarkedAsUnused)
    345358    {
    346         LogRelFlow(("UIFrameBuffer::NotifyChange: Ignored!\n"));
     359        LogRel(("UIFrameBuffer::NotifyChange: Screen=%lu, Origin=%lux%lu, Size=%lux%lu, Ignored!\n",
     360                (unsigned long)uScreenId,
     361                (unsigned long)uX, (unsigned long)uY,
     362                (unsigned long)uWidth, (unsigned long)uHeight));
     363
     364        /* Unlock access to frame-buffer: */
    347365        unlock();
     366
     367        /* Ignore NotifyChange: */
    348368        return E_FAIL;
    349369    }
    350370
    351     /* Save the new bitmap. */
    352     mpPendingSourceBitmap = 0;
    353     m_pMachineView->session().GetConsole().GetDisplay().QuerySourceBitmap(aScreenId, mpPendingSourceBitmap);
    354 
    355     unlock();
     371    /* Acquire new pending bitmap: */
     372    m_pendingSourceBitmap = 0;
     373    m_pMachineView->session().GetConsole().GetDisplay().QuerySourceBitmap(uScreenId, m_pendingSourceBitmap);
    356374
    357375    /* Widget resize is NOT thread-safe and *probably* never will be,
    358376     * 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 
     377    LogRel(("UIFrameBuffer::NotifyChange: Screen=%lu, Origin=%lux%lu, Size=%lux%lu, Sending to async-handler..\n",
     378            (unsigned long)uScreenId,
     379            (unsigned long)uX, (unsigned long)uY,
     380            (unsigned long)uWidth, (unsigned long)uHeight));
     381    emit sigNotifyChange(uScreenId, uWidth, uHeight);
     382
     383    /* Unlock access to frame-buffer: */
     384    unlock();
     385
     386    /* Give up control token to other thread: */
    362387    RTThreadYield();
    363388
     389    /* Confirm NotifyChange: */
    364390    return S_OK;
    365391}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r51438 r51458  
    152152                              ULONG uWidth, ULONG uHeight,
    153153                              BOOL *pbFinished);
    154     STDMETHOD(NotifyChange)(ULONG aScreenId,
    155                             ULONG aXOrigin,
    156                             ULONG aYOrigin,
    157                             ULONG aWidth,
    158                             ULONG aHeight);
     154    STDMETHOD(NotifyChange)(ULONG uScreenId,
     155                            ULONG uX,
     156                            ULONG uY,
     157                            ULONG uWidth,
     158                            ULONG uHeight);
    159159
    160160    STDMETHOD(NotifyUpdate) (ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight);
     
    204204    virtual void applyVisibleRegion(const QRegion &region);
    205205
    206     void notifyChange(ULONG uScreenId);
     206    void notifyChange();
    207207
    208208#ifdef VBOX_WITH_VIDEOHWACCEL
     
    240240    bool m_fIsAutoEnabled;
    241241
    242     CDisplaySourceBitmap mpSourceBitmap;
    243     CDisplaySourceBitmap mpPendingSourceBitmap;
    244     bool mfUpdates;
     242    /** Source bitmap from IDisplay. */
     243    CDisplaySourceBitmap m_sourceBitmap;
     244    /** Source bitmap from IDisplay acquired but not yet applied. */
     245    CDisplaySourceBitmap m_pendingSourceBitmap;
     246    /** Reflects whether screen-updates allowed. */
     247    bool m_fIsUpdatesAllowed;
    245248
    246249    /* To avoid a seamless flicker,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQImage.cpp

    r51436 r51458  
    145145    else
    146146        popupCenter().forgetAboutWrongColorDepth(m_pMachineView->machineWindow());
     147
     148    /* Enable screen updates: */
    147149    lock();
    148     mfUpdates = true;
     150    m_fIsUpdatesAllowed = true;
    149151    unlock();
    150152}
     
    164166    if (!m_pMachineView)
    165167        return;
    166        
     168
     169    /* Lock access to frame-buffer: */
    167170    lock();
    168     if (!mfUpdates)
    169     {
    170        unlock();
    171        return;
     171
     172    /* But if updates disabled: */
     173    if (!m_fIsUpdatesAllowed)
     174    {
     175        /* Unlock access to frame-buffer: */
     176        unlock();
     177        /* And return immediately: */
     178        return;
    172179    }
    173180
     
    213220            break;
    214221    }
     222
     223    /* Unlock access to frame-buffer: */
    215224    unlock();
    216225}
     
    387396     * 2. or the machine is in the state which breaks link between
    388397     *    the framebuffer and the actual video-memory: */
    389     if (!mpSourceBitmap.isNull())
     398    if (!m_sourceBitmap.isNull())
    390399    {
    391400        BYTE *pAddress = NULL;
     
    396405        ULONG ulPixelFormat = 0;
    397406
    398         mpSourceBitmap.QueryBitmapInfo(pAddress,
     407        m_sourceBitmap.QueryBitmapInfo(pAddress,
    399408                                       ulWidth,
    400409                                       ulHeight,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r51440 r51458  
    307307
    308308        /* Perform frame-buffer mode-change: */
    309         frameBuffer()->notifyChange(uScreenId);
     309        frameBuffer()->notifyChange();
    310310
    311311        /* Scale-mode doesn't need this.. */
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