VirtualBox

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


Ignore:
Timestamp:
Oct 29, 2009 3:25:14 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
54101
Message:

2d accel: fix reset handling

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h

    r23766 r24162  
    919919    void completeCurrentEvent();
    920920    class VBoxVHWACommandElement * detachCmdList(class VBoxVHWACommandElement * pFirst2Free, VBoxVHWACommandElement * pLast2Free);
    921 
     921    void reset(class VBoxVHWACommandElement ** ppHead, class VBoxVHWACommandElement ** ppTail);
    922922private:
    923923    RTCRITSECT mCritSect;
     
    926926    class VBoxConsoleView *mView;
    927927    bool mbNewEvent;
     928    bool mbProcessingList;
    928929    VBoxVHWACommandElementStack mFreeElements;
    929930    VBoxVHWACommandElement mElementsBuffer[2048];
     
    12471248
    12481249    int vhwaConstruct(struct _VBOXVHWACMD_HH_CONSTRUCT *pCmd);
     1250
     1251    int reset();
    12491252
    12501253    VBoxGLWidget *mpOverlayWidget;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp

    r24044 r24162  
    47244724}
    47254725
     4726int VBoxQGLOverlay::reset()
     4727{
     4728    VBoxVHWACommandElement * pHead, * pTail;
     4729    mCmdPipe.reset(&pHead, &pTail);
     4730    if(pHead)
     4731    {
     4732        CDisplay display = mView->console().GetDisplay();
     4733        Assert (!display.isNull());
     4734
     4735        /* complete aborted commands */
     4736        for(VBoxVHWACommandElement * pCur = pHead; pCur; pCur = pCur->mpNext)
     4737        {
     4738            switch(pCur->type())
     4739            {
     4740#ifdef VBOX_WITH_VIDEOHWACCEL
     4741            case VBOXVHWA_PIPECMD_VHWA:
     4742                {
     4743                    struct _VBOXVHWACMD * pCmd = pCur->vhwaCmd();
     4744                    pCmd->rc = VERR_INVALID_STATE;
     4745                    display.CompleteVHWACommand((BYTE*)pCmd);
     4746                }
     4747                break;
     4748            case VBOXVHWA_PIPECMD_OP:
     4749                /* should not happen, don't handle this for now */
     4750                Assert(0);
     4751                break;
     4752            case VBOXVHWA_PIPECMD_FUNC:
     4753                /* should not happen, don't handle this for now */
     4754                Assert(0);
     4755                break;
     4756#endif
     4757            }
     4758        }
     4759
     4760        VBoxVHWACommandElement *pTest = mCmdPipe.detachCmdList(pHead, pTail);
     4761        Assert(!pTest);
     4762        NOREF(pTest);
     4763    }
     4764    return VINF_SUCCESS;
     4765}
     4766
    47264767int VBoxQGLOverlay::onVHWACommand(struct _VBOXVHWACMD * pCmd)
    47274768{
     
    47344775            flags |= VBOXVHWACMDPIPEC_COMPLETEEVENT;
    47354776            break;
     4777        case VBOXVHWACMD_TYPE_HH_RESET:
     4778        {
     4779            /* we do not post a reset command to the gui thread since this may lead to a deadlock
     4780             * when reset is initiated by the gui thread*/
     4781            pCmd->Flags &= ~VBOXVHWACMD_FLAG_HG_ASYNCH;
     4782            pCmd->rc = reset();
     4783            return VINF_SUCCESS;
     4784        }
    47364785        default:
    47374786            break;
     
    53015350
    53025351
    5303 VBoxVHWACommandElementProcessor::VBoxVHWACommandElementProcessor(VBoxConsoleView *aView)
     5352VBoxVHWACommandElementProcessor::VBoxVHWACommandElementProcessor(VBoxConsoleView *aView) :
     5353    mpFirstEvent (NULL),
     5354    mpLastEvent (NULL),
     5355    mbNewEvent (false),
     5356    mbProcessingList (false)
    53045357{
    53055358    int rc = RTCritSectInit(&mCritSect);
    53065359    AssertRC(rc);
    53075360
    5308     mpFirstEvent = NULL;
    5309     mpLastEvent = NULL;
    5310     mbNewEvent = false;
    53115361    mView = aView;
     5362
    53125363    for(int i = RT_ELEMENTS(mElementsBuffer) - 1; i >= 0; i--)
    53135364    {
     
    54085459    {
    54095460        pList = mpFirstEvent->pipe().detachList();
    5410         if(!pList)
     5461        if(pList)
     5462        {
     5463            /* assume the caller atimically calls detachCmdList to free the elements obtained now those and reset the state */
     5464            mbProcessingList = true;
     5465            RTCritSectLeave(&mCritSect);
     5466            return pList;
     5467        }
     5468        else
    54115469        {
    54125470            VBoxVHWACommandProcessEvent *pNext = mpFirstEvent->mpNext;
     
    54225480        }
    54235481    }
     5482
     5483    /* assume the caller atimically calls detachCmdList to free the elements obtained now those and reset the state */
     5484    mbProcessingList = false;
    54245485    RTCritSectLeave(&mCritSect);
    5425 
    5426     return pList;
    5427 }
    5428 
     5486    return NULL;
     5487}
     5488
     5489/* it is currently assumed no one sends any new commands while reset is in progress */
     5490void VBoxVHWACommandElementProcessor::reset(VBoxVHWACommandElement ** ppHead, VBoxVHWACommandElement ** ppTail)
     5491{
     5492    VBoxVHWACommandElement * pHead = NULL;
     5493    VBoxVHWACommandElement * pTail = NULL;
     5494    VBoxVHWACommandProcessEvent * pFirst;
     5495    VBoxVHWACommandProcessEvent * pLast;
     5496    RTCritSectEnter(&mCritSect);
     5497    pFirst = mpFirstEvent;
     5498    pLast = mpLastEvent;
     5499    mpFirstEvent = NULL;
     5500    mpLastEvent = NULL;
     5501
     5502    if(mbProcessingList)
     5503    {
     5504        for(;;)
     5505        {
     5506            RTCritSectLeave(&mCritSect);
     5507            RTThreadSleep(2000); /* 2 ms */
     5508            RTCritSectEnter(&mCritSect);
     5509            /* it is assumed no one sends any new commands while reset is in progress */
     5510            Assert(!mpFirstEvent);
     5511            Assert(!mpLastEvent);
     5512            if(!mbProcessingList)
     5513            {
     5514                break;
     5515            }
     5516        }
     5517    }
     5518
     5519    if(pFirst)
     5520    {
     5521        Assert(pLast);
     5522        pHead = pFirst->pipe().detachList();
     5523        VBoxVHWACommandElement * pCurHead;
     5524        for(VBoxVHWACommandProcessEvent * pCur = pFirst; pCur ; pCur = pCur->mpNext)
     5525        {
     5526            pCurHead = pCur->pipe().detachList();
     5527            if(!pCurHead)
     5528                continue;
     5529            if(!pHead)
     5530                pHead = pCurHead;
     5531            if(pTail)
     5532                pTail->mpNext = pCurHead;
     5533
     5534            for(VBoxVHWACommandElement * pCurEl = pCurHead; pCurEl; pCurEl = pCurEl->mpNext)
     5535            {
     5536                pTail = pCurEl;
     5537            }
     5538        }
     5539
     5540        if(!pTail)
     5541            pTail = pHead;
     5542    }
     5543
     5544    if(pHead)
     5545        mbProcessingList = true;
     5546
     5547    RTCritSectLeave(&mCritSect);
     5548
     5549    *ppHead = pHead;
     5550    *ppTail = pTail;
     5551}
    54295552
    54305553void VBoxVHWACommandsQueue::enqueue(PFNVBOXQGLFUNC pfn, void* pContext1, void* pContext2)
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