VirtualBox

Ignore:
Timestamp:
Oct 23, 2013 4:57:54 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Frame-buffer interface: Next iteration in EMT vs GUI thread sync.

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

Legend:

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

    r49167 r49262  
    7373
    7474/**
    75  * Checks if the framebuffer marked as <b>unused</b>.
    76  * @returns @c true if framebuffer ingores EMT events, @c false otherwise.
    77  * @note    Any call to this (and #setMarkAsUnused method) is synchronized between calling threads.
    78  */
    79 bool UIFrameBuffer::isMarkedAsUnused() const
    80 {
    81     lock();
    82     bool fIsMarkedAsUnused = m_fIsMarkedAsUnused;
    83     unlock();
    84     return fIsMarkedAsUnused;
    85 }
    86 
    87 /**
    8875 * Sets the framebuffer <b>unused</b> status.
    8976 * @param fIsMarkAsUnused determines whether framebuffer should ignore EMT events or not.
    90  * @note  Any call to this (and #isMarkedAsUnused method) is synchronized between calling threads.
     77 * @note  Call to this (and any EMT callback) method is synchronized between calling threads (from GUI side).
    9178 */
    9279void UIFrameBuffer::setMarkAsUnused(bool fIsMarkAsUnused)
     
    190177}
    191178
     179/**
     180 * EMT callback: Requests a size and pixel format change.
     181 * @param uScreenId     Guest screen number. Must be used in the corresponding call to CDisplay::ResizeCompleted if this call is made.
     182 * @param uPixelFormat  Pixel format of the memory buffer pointed to by @a pVRAM.
     183 * @param pVRAM         Pointer to the virtual video card's VRAM (may be <i>null</i>).
     184 * @param uBitsPerPixel Color depth, bits per pixel.
     185 * @param uBytesPerLine Size of one scan line, in bytes.
     186 * @param uWidth        Width of the guest display, in pixels.
     187 * @param uHeight       Height of the guest display, in pixels.
     188 * @param pfFinished    Can the VM start using the new frame buffer immediately after this method returns or it should wait for CDisplay::ResizeCompleted.
     189 * @note  Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     190 * @note  Calls to this and #setMarkAsUnused method are synchronized between calling threads (from GUI side).
     191 */
    192192STDMETHODIMP UIFrameBuffer::RequestResize(ULONG uScreenId, ULONG uPixelFormat,
    193193                                          BYTE *pVRAM, ULONG uBitsPerPixel, ULONG uBytesPerLine,
    194194                                          ULONG uWidth, ULONG uHeight,
    195                                           BOOL *pbFinished)
     195                                          BOOL *pfFinished)
    196196{
    197197    LogRelFlow(("UIFrameBuffer::RequestResize: "
     
    204204
    205205    /* Make sure result pointer is valid: */
    206     if (!pbFinished)
    207         return E_POINTER;
     206    if (!pfFinished)
     207    {
     208        LogRelFlow(("UIFrameBuffer::RequestResize: Invalid pfFinished pointer!\n"));
     209
     210        return E_POINTER;
     211    }
     212
     213    /* Lock access to frame-buffer: */
     214    lock();
    208215
    209216    /* Make sure frame-buffer is used: */
    210     if (isMarkedAsUnused())
     217    if (m_fIsMarkedAsUnused)
    211218    {
    212219        LogRelFlow(("UIFrameBuffer::RequestResize: Ignored!\n"));
     
    215222         * It is required to report to the VM thread that we finished resizing and rely on the
    216223         * later synchronisation when the new view is attached. */
    217         *pbFinished = TRUE;
     224        *pfFinished = TRUE;
     225
     226        /* Unlock access to frame-buffer: */
     227        unlock();
    218228
    219229        /* Ignore RequestResize: */
     
    222232
    223233    /* Mark request as not-yet-finished: */
    224     *pbFinished = FALSE;
     234    *pfFinished = FALSE;
    225235
    226236    /* Widget resize is NOT thread-safe and *probably* never will be,
     
    229239    emit sigRequestResize(uPixelFormat, pVRAM, uBitsPerPixel, uBytesPerLine, uWidth, uHeight);
    230240
     241    /* Unlock access to frame-buffer: */
     242    unlock();
     243
    231244    /* Confirm RequestResize: */
    232245    return S_OK;
    233246}
    234247
     248/**
     249 * EMT callback: Informs about an update.
     250 * @param uX      Horizontal origin of the update rectangle, in pixels.
     251 * @param uY      Vertical origin of the update rectangle, in pixels.
     252 * @param uWidth  Width of the update rectangle, in pixels.
     253 * @param uHeight Height of the update rectangle, in pixels.
     254 * @note  Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     255 * @note  Calls to this and #setMarkAsUnused method are synchronized between calling threads (from GUI side).
     256 */
    235257STDMETHODIMP UIFrameBuffer::NotifyUpdate(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight)
    236258{
     
    239261             (unsigned long)uWidth, (unsigned long)uHeight));
    240262
     263    /* Lock access to frame-buffer: */
     264    lock();
     265
    241266    /* Make sure frame-buffer is used: */
    242     if (isMarkedAsUnused())
     267    if (m_fIsMarkedAsUnused)
    243268    {
    244269        LogRel2(("UIFrameBuffer::NotifyUpdate: Ignored!\n"));
     270
     271        /* Unlock access to frame-buffer: */
     272        unlock();
    245273
    246274        /* Ignore NotifyUpdate: */
     
    253281    emit sigNotifyUpdate(uX, uY, uWidth, uHeight);
    254282
     283    /* Unlock access to frame-buffer: */
     284    unlock();
     285
    255286    /* Confirm NotifyUpdate: */
    256287    return S_OK;
    257288}
    258289
    259 STDMETHODIMP UIFrameBuffer::VideoModeSupported(ULONG uWidth, ULONG uHeight, ULONG uBPP, BOOL *pbSupported)
     290/**
     291 * EMT callback: Returns whether the framebuffer implementation is willing to support a given video mode.
     292 * @param uWidth      Width of the guest display, in pixels.
     293 * @param uHeight     Height of the guest display, in pixels.
     294 * @param uBPP        Color depth, bits per pixel.
     295 * @param pfSupported Is framebuffer able/willing to render the video mode or not.
     296 * @note  Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     297 * @note  Calls to this and #setMarkAsUnused method are synchronized between calling threads (from GUI side).
     298 */
     299STDMETHODIMP UIFrameBuffer::VideoModeSupported(ULONG uWidth, ULONG uHeight, ULONG uBPP, BOOL *pfSupported)
    260300{
    261301    LogRel2(("UIFrameBuffer::IsVideoModeSupported: Mode: BPP=%lu, Size=%lux%lu\n",
    262302             (unsigned long)uBPP, (unsigned long)uWidth, (unsigned long)uHeight));
    263303
     304    /* Make sure result pointer is valid: */
     305    if (!pfSupported)
     306    {
     307        LogRel2(("UIFrameBuffer::IsVideoModeSupported: Invalid pfSupported pointer!\n"));
     308
     309        return E_POINTER;
     310    }
     311
     312    /* Lock access to frame-buffer: */
     313    lock();
     314
    264315    /* Make sure frame-buffer is used: */
    265     if (isMarkedAsUnused())
     316    if (m_fIsMarkedAsUnused)
    266317    {
    267318        LogRel2(("UIFrameBuffer::IsVideoModeSupported: Ignored!\n"));
     319
     320        /* Unlock access to frame-buffer: */
     321        unlock();
    268322
    269323        /* Ignore VideoModeSupported: */
     
    271325    }
    272326
    273     /* Make sure result pointer is valid: */
    274     if (!pbSupported)
    275         return E_POINTER;
    276 
    277327    /* Determine if supported: */
    278     *pbSupported = TRUE;
     328    *pfSupported = TRUE;
    279329    QSize screenSize = m_pMachineView->maxGuestSize();
    280330    if (   (screenSize.width() != 0)
    281331        && (uWidth > (ULONG)screenSize.width())
    282332        && (uWidth > (ULONG)width()))
    283         *pbSupported = FALSE;
     333        *pfSupported = FALSE;
    284334    if (   (screenSize.height() != 0)
    285335        && (uHeight > (ULONG)screenSize.height())
    286336        && (uHeight > (ULONG)height()))
    287         *pbSupported = FALSE;
    288 
    289     LogRel2(("UIFrameBuffer::IsVideoModeSupported: %s\n", *pbSupported ? "TRUE" : "FALSE"));
     337        *pfSupported = FALSE;
     338
     339    LogRel2(("UIFrameBuffer::IsVideoModeSupported: %s\n", *pfSupported ? "TRUE" : "FALSE"));
     340
     341    /* Unlock access to frame-buffer: */
     342    unlock();
    290343
    291344    /* Confirm VideoModeSupported: */
     
    306359}
    307360
     361/**
     362 * EMT callback: Suggests a new visible region to this framebuffer.
     363 * @param pRectangles Pointer to the RTRECT array.
     364 * @param uCount      Number of RTRECT elements in the rectangles array.
     365 * @note  Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     366 * @note  Calls to this and #setMarkAsUnused method are synchronized between calling threads (from GUI side).
     367 */
    308368STDMETHODIMP UIFrameBuffer::SetVisibleRegion(BYTE *pRectangles, ULONG uCount)
    309369{
     
    311371             (unsigned long)uCount));
    312372
     373    /* Make sure rectangles were passed: */
     374    if (!pRectangles)
     375    {
     376        LogRel2(("UIFrameBuffer::SetVisibleRegion: Invalid pRectangles pointer!\n"));
     377
     378        return E_POINTER;
     379    }
     380
     381    /* Lock access to frame-buffer: */
     382    lock();
     383
    313384    /* Make sure frame-buffer is used: */
    314     if (isMarkedAsUnused())
     385    if (m_fIsMarkedAsUnused)
    315386    {
    316387        LogRel2(("UIFrameBuffer::SetVisibleRegion: Ignored!\n"));
     388
     389        /* Unlock access to frame-buffer: */
     390        unlock();
    317391
    318392        /* Ignore SetVisibleRegion: */
     
    320394    }
    321395
    322     /* Make sure rectangles were passed: */
    323     PRTRECT rects = (PRTRECT)pRectangles;
    324     if (!rects)
    325         return E_POINTER;
    326 
    327396    /* Compose region: */
    328397    QRegion region;
     398    PRTRECT rects = (PRTRECT)pRectangles;
    329399    for (ULONG ind = 0; ind < uCount; ++ind)
    330400    {
     
    347417    emit sigSetVisibleRegion(region);
    348418
     419    /* Unlock access to frame-buffer: */
     420    unlock();
     421
    349422    /* Confirm SetVisibleRegion: */
    350423    return S_OK;
     
    357430}
    358431
     432/**
     433 * EMT callback: Notifies framebuffer about 3D backend event.
     434 * @param uType Event type. Currently only VBOX3D_NOTIFY_EVENT_TYPE_VISIBLE_3DDATA is supported.
     435 * @param pData Event-specific data, depends on the supplied event type.
     436 * @note  Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     437 * @note  Calls to this and #setMarkAsUnused method are synchronized between calling threads (from GUI side).
     438 */
    359439STDMETHODIMP UIFrameBuffer::Notify3DEvent(ULONG uType, BYTE *pData)
    360440{
    361441    LogRel2(("UIFrameBuffer::Notify3DEvent\n"));
    362442
     443    /* Lock access to frame-buffer: */
     444    lock();
     445
    363446    /* Make sure frame-buffer is used: */
    364     if (isMarkedAsUnused())
     447    if (m_fIsMarkedAsUnused)
    365448    {
    366449        LogRel2(("UIFrameBuffer::Notify3DEvent: Ignored!\n"));
     450
     451        /* Unlock access to frame-buffer: */
     452        unlock();
    367453
    368454        /* Ignore Notify3DEvent: */
     
    382468            emit sigNotifyAbout3DOverlayVisibilityChange(fVisible);
    383469
     470            /* Unlock access to frame-buffer: */
     471            unlock();
     472
    384473            /* Confirm Notify3DEvent: */
    385474            return S_OK;
     
    388477            break;
    389478    }
     479
     480    /* Unlock access to frame-buffer: */
     481    unlock();
    390482
    391483    /* Ignore Notify3DEvent: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r49167 r49262  
    105105
    106106    /* API: [Un]used status stuff: */
    107     bool isMarkedAsUnused() const;
    108107    void setMarkAsUnused(bool fIsMarkAsUnused);
    109108
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