VirtualBox

Ignore:
Timestamp:
Jun 3, 2013 3:02:38 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86180
Message:

FE/Qt: 6749: Runtime UI: Frame-buffer interface: Using signal instead of event for SetVisibleRegion stuff.

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

Legend:

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

    r46361 r46364  
    163163}
    164164
    165 /* This method is called on EMT from under this object's lock! */
    166165STDMETHODIMP UIFrameBuffer::RequestResize(ULONG uScreenId, ULONG uPixelFormat,
    167166                                          BYTE *pVRAM, ULONG uBitsPerPixel, ULONG uBytesPerLine,
     
    220219}
    221220
    222 /**
    223  * Returns whether we like the given video mode.
    224  * @note We always like a mode smaller than the current framebuffer
    225  *       size.
    226  *
    227  * @returns COM status code
    228  * @param   width     video mode width in pixels
    229  * @param   height    video mode height in pixels
    230  * @param   bpp       video mode bit depth in bits per pixel
    231  * @param   supported pointer to result variable
    232  */
    233221STDMETHODIMP UIFrameBuffer::VideoModeSupported(ULONG uWidth, ULONG uHeight, ULONG uBPP, BOOL *pbSupported)
    234222{
     
    281269STDMETHODIMP UIFrameBuffer::SetVisibleRegion(BYTE *pRectangles, ULONG uCount)
    282270{
     271    /* Make sure frame-buffer is not yet scheduled for removal: */
     272    if (m_fIsScheduledToDelete)
     273        return E_FAIL;
     274
     275    /* Make sure rectangles were passed: */
    283276    PRTRECT rects = (PRTRECT)pRectangles;
    284 
    285277    if (!rects)
    286278        return E_POINTER;
    287279
    288     QRegion reg;
    289     for (ULONG ind = 0; ind < uCount; ++ ind)
     280    /* Compose region: */
     281    QRegion region;
     282    for (ULONG ind = 0; ind < uCount; ++ind)
    290283    {
     284        /* Get current rectangle: */
    291285        QRect rect;
    292286        rect.setLeft(rects->xLeft);
    293287        rect.setTop(rects->yTop);
    294         /* QRect are inclusive */
     288        /* Which is inclusive: */
    295289        rect.setRight(rects->xRight - 1);
    296290        rect.setBottom(rects->yBottom - 1);
    297         reg += rect;
    298         ++ rects;
     291        /* Append region: */
     292        region += rect;
     293        ++rects;
    299294    }
    300     lock(); /* See comment in setView(). */
    301     m_syncVisibleRegion = reg;
    302     if (m_pMachineView)
    303         QApplication::postEvent(m_pMachineView, new UISetRegionEvent(reg));
    304     unlock();
    305 
     295
     296    /* See comment in setView(): */
     297    lock();
     298
     299    /* We are directly updating synchronous visible-region: */
     300    m_syncVisibleRegion = region;
     301    /* And send async signal to update asynchronous one: */
     302    if (m_pMachineView)
     303        emit sigSetVisibleRegion(region);
     304
     305    /* Unlock thread finally: */
     306    unlock();
     307
     308    /* Confirm SetVisibleRegion: */
    306309    return S_OK;
    307310}
     
    369372            m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)),
    370373            Qt::QueuedConnection);
     374    connect(this, SIGNAL(sigSetVisibleRegion(QRegion)),
     375            m_pMachineView, SLOT(sltHandleSetVisibleRegion(QRegion)),
     376            Qt::QueuedConnection);
    371377}
    372378
     
    377383    disconnect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)),
    378384               m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int)));
    379 }
    380 
     385    disconnect(this, SIGNAL(sigSetVisibleRegion(QRegion)),
     386               m_pMachineView, SLOT(sltHandleSetVisibleRegion(QRegion)));
     387}
     388
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r46361 r46364  
    6767
    6868/**
    69  *  Frame buffer set region event.
    70  */
    71 class UISetRegionEvent : public QEvent
    72 {
    73 public:
    74 
    75     UISetRegionEvent(const QRegion &region)
    76         : QEvent((QEvent::Type)SetRegionEventType)
    77         , m_region(region) {}
    78     QRegion region() { return m_region; }
    79 
    80 private:
    81 
    82     QRegion m_region;
    83 };
    84 
    85 /**
    8669 *  Common IFramebuffer implementation for all methods used by GUI to maintain
    8770 *  the VM display video memory.
     
    11598                          int iWidth, int iHeight);
    11699    void sigNotifyUpdate(int iX, int iY, int iWidth, int iHeight);
     100    void sigSetVisibleRegion(QRegion region);
    117101
    118102public:
     
    206190    virtual void resizeEvent(UIResizeEvent *pEvent) = 0;
    207191    virtual void paintEvent(QPaintEvent *pEvent) = 0;
    208     virtual void applyVisibleRegionEvent(UISetRegionEvent *pEvent) = 0;
     192    virtual void applyVisibleRegion(const QRegion &region) = 0;
    209193
    210194#ifdef VBOX_WITH_VIDEOHWACCEL
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQImage.cpp

    r46322 r46364  
    178178}
    179179
    180 void UIFrameBufferQImage::applyVisibleRegionEvent(UISetRegionEvent *pEvent)
     180void UIFrameBufferQImage::applyVisibleRegion(const QRegion &region)
    181181{
    182182    /* Make sure async visible-region changed: */
    183     if (m_asyncVisibleRegion == pEvent->region())
     183    if (m_asyncVisibleRegion == region)
    184184        return;
    185185
    186186    /* We are accounting async visible-regions one-by-one
    187187     * to keep corresponding viewport area always updated! */
    188     m_pMachineView->viewport()->update(pEvent->region() + m_asyncVisibleRegion);
    189     m_asyncVisibleRegion = pEvent->region();
     188    m_pMachineView->viewport()->update(region + m_asyncVisibleRegion);
     189    m_asyncVisibleRegion = region;
    190190
    191191#ifdef Q_WS_X11
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQImage.h

    r46255 r46364  
    4747    void resizeEvent(UIResizeEvent *pEvent);
    4848    void paintEvent(QPaintEvent *pEvent);
    49     void applyVisibleRegionEvent(UISetRegionEvent *pEvent);
     49    void applyVisibleRegion(const QRegion &region);
    5050
    5151private:
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.cpp

    r46283 r46364  
    7373}
    7474
    75 STDMETHODIMP UIFrameBufferQuartz2D::SetVisibleRegion(BYTE *aRectangles, ULONG aCount)
    76 {
    77     PRTRECT rects = (PRTRECT)aRectangles;
    78 
     75STDMETHODIMP UIFrameBufferQuartz2D::SetVisibleRegion(BYTE *pRectangles, ULONG aCount)
     76{
     77    /* Make sure frame-buffer is not yet scheduled for removal: */
     78    if (m_fIsScheduledToDelete)
     79        return E_FAIL;
     80
     81    /* Make sure rectangles were passed: */
     82    PRTRECT rects = (PRTRECT)pRectangles;
    7983    if (!rects)
    8084        return E_POINTER;
     
    103107    rgnRcts->used = 0;
    104108
     109    /* Compose region: */
    105110    QRegion reg;
    106 //    printf ("Region rects follow...\n");
    107     QRect vmScreenRect (0, 0, width(), height());
     111    QRect vmScreenRect(0, 0, width(), height());
    108112    for (ULONG ind = 0; ind < aCount; ++ ind)
    109113    {
     114        /* Get current rectangle: */
    110115        QRect rect;
    111116        rect.setLeft(rects->xLeft);
    112117        rect.setTop(rects->yTop);
    113         /* QRect are inclusive */
     118        /* Which is inclusive: */
    114119        rect.setRight(rects->xRight - 1);
    115120        rect.setBottom(rects->yBottom - 1);
     
    117122        /* The rect should intersect with the vm screen. */
    118123        rect = vmScreenRect.intersect(rect);
    119         ++ rects;
    120         /* Make sure only valid rects are distributed */
    121         /* todo: Test if the other framebuffer implementation have the same
    122          * problem with invalid rects (In Linux/Windows) */
     124        ++rects;
     125        /* Make sure only valid rects are distributed: */
    123126        if (rect.isValid() &&
    124127           rect.width() > 0 && rect.height() > 0)
     
    127130            continue;
    128131
     132        /* That is some *magic* added by Knut in r27807: */
    129133        CGRect *cgRct = &rgnRcts->rcts[rgnRcts->used];
    130134        cgRct->origin.x = rect.x();
     
    132136        cgRct->size.width = rect.width();
    133137        cgRct->size.height = rect.height();
    134 //        printf ("Region rect[%d - %d]: %d %d %d %d\n", rgnRcts->used, aCount, rect.x(), rect.y(), rect.height(), rect.width());
    135138        rgnRcts->used++;
    136139    }
    137 //    printf ("..................................\n");
    138140
    139141    RegionRects *pOld = ASMAtomicXchgPtrT(&mRegion, rgnRcts, RegionRects *);
     
    142144        RTMemFree(pOld);
    143145
    144     QApplication::postEvent(m_pMachineView, new UISetRegionEvent (reg));
    145 
     146    /* Send async signal to update asynchronous visible-region: */
     147    if (m_pMachineView)
     148        emit sigSetVisibleRegion(region);
     149
     150    /* Confirm SetVisibleRegion: */
    146151    return S_OK;
    147152}
     
    463468}
    464469
    465 void UIFrameBufferQuartz2D::applyVisibleRegionEvent(UISetRegionEvent *pEvent)
     470void UIFrameBufferQuartz2D::applyVisibleRegion(const QRegion &region)
    466471{
    467472    /* Make sure async visible-region changed: */
    468     if (m_asyncVisibleRegion == pEvent->region())
     473    if (m_asyncVisibleRegion == region)
    469474        return;
    470475
     
    472477     * to invalidate whole the viewport area! */
    473478    ::darwinWindowInvalidateShape(m_pMachineView->viewport());
    474     m_asyncVisibleRegion = pEvent->region();
     479    m_asyncVisibleRegion = region;
    475480}
    476481
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.h

    r46255 r46364  
    5050    void resizeEvent(UIResizeEvent *pEvent);
    5151    void paintEvent(QPaintEvent *pEvent);
    52     void applyVisibleRegionEvent(UISetRegionEvent *pEvent);
     52    void applyVisibleRegion(const QRegion &region);
    5353
    5454#ifdef VBOX_WITH_VIDEOHWACCEL
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r46361 r46364  
    283283    /* Update corresponding viewport part: */
    284284    viewport()->update(iX - contentsX(), iY - contentsY(), iWidth, iHeight);
     285}
     286
     287void UIMachineView::sltHandleSetVisibleRegion(QRegion region)
     288{
     289    /* Used only in seamless-mode. */
     290    Q_UNUSED(region);
    285291}
    286292
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r46361 r46364  
    9393
    9494    /* Handler: Frame-buffer RequestResize stuff: */
    95     void sltHandleRequestResize(int iPixelFormat, uchar *pVRAM,
     95    virtual void sltHandleRequestResize(int iPixelFormat, uchar *pVRAM,
    9696                                int iBitsPerPixel, int iBytesPerLine,
    9797                                int iWidth, int iHeight);
    9898
    9999    /* Handler: Frame-buffer NotifyUpdate stuff: */
    100     void sltHandleNotifyUpdate(int iX, int iY, int iWidth, int iHeight);
     100    virtual void sltHandleNotifyUpdate(int iX, int iY, int iWidth, int iHeight);
     101
     102    /* Handler: Frame-buffer SetVisibleRegion stuff: */
     103    virtual void sltHandleSetVisibleRegion(QRegion region);
    101104
    102105    /* Watch dog for desktop resizes: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r46362 r46364  
    7070}
    7171
    72 bool UIMachineViewSeamless::event(QEvent *pEvent)
     72void UIMachineViewSeamless::sltHandleSetVisibleRegion(QRegion region)
    7373{
    74     switch (pEvent->type())
    75     {
    76         case SetRegionEventType:
    77         {
    78             /* Apply new seamless-region: */
    79             m_pFrameBuffer->applyVisibleRegionEvent(static_cast<UISetRegionEvent*>(pEvent));
    80             return true;
    81         }
    82 
    83         default:
    84             break;
    85     }
    86     return UIMachineView::event(pEvent);
     74    /* Apply new seamless-region: */
     75    m_pFrameBuffer->applyVisibleRegion(region);
    8776}
    8877
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h

    r46362 r46364  
    3939    virtual ~UIMachineViewSeamless();
    4040
     41private slots:
     42
     43    /* Handler: Frame-buffer SetVisibleRegion stuff: */
     44    virtual void sltHandleSetVisibleRegion(QRegion region);
     45
    4146private:
    4247
    4348    /* Event handlers: */
    44     bool event(QEvent *pEvent);
    4549    bool eventFilter(QObject *pWatched, QEvent *pEvent);
    4650
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