Changeset 22796 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Sep 6, 2009 12:17:31 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h
r22795 r22796 939 939 } 940 940 941 size_t size() {return mSurfaces.size(); } 942 941 943 void remove(VBoxVHWASurfaceBase *pSurf) 942 944 { … … 985 987 // mSurfPrimary = pVga; 986 988 mOverlays.clear(); 989 return old; 990 } 991 992 VBoxVHWASurfaceBase * updateVGA(VBoxVHWASurfaceBase * pVga) 993 { 994 VBoxVHWASurfaceBase * old = mSurfVGA; 995 Assert(old); 996 mSurfVGA = pVga; 987 997 return old; 988 998 } … … 1114 1124 const VBOXVHWACALLBACKINFO & op() const {return u.mCallback; } 1115 1125 1116 private:1117 1126 VBoxVHWACommandElement * mpNext; 1127 private: 1118 1128 VBOXVHWA_PIPECMD_TYPE mType; 1119 1129 union … … 1123 1133 }u; 1124 1134 QRect mRect; 1125 1126 friend class VBoxVHWACommandElementPipe;1127 friend class VBoxVHWACommandElementStack;1128 friend class VBoxGLWidget;1129 1135 }; 1130 1136 … … 1202 1208 VBoxVHWACommandElement *mpFirst; 1203 1209 }; 1210 1211 class VBoxVHWACommandElementProcessor 1212 { 1213 public: 1214 VBoxVHWACommandElementProcessor(VBoxConsoleView *aView); 1215 ~VBoxVHWACommandElementProcessor(); 1216 void postCmd(VBOXVHWA_PIPECMD_TYPE aType, void * pvData); 1217 class VBoxVHWACommandElement * detachCmdList(class VBoxVHWACommandElement * pFirst2Free, VBoxVHWACommandElement * pLast2Free); 1218 1219 private: 1220 RTCRITSECT mCritSect; 1221 class VBoxVHWACommandProcessEvent *mpFirstEvent; 1222 class VBoxVHWACommandProcessEvent *mpLastEvent; 1223 VBoxConsoleView *mView; 1224 bool mbNewEvent; 1225 VBoxVHWACommandElementStack mFreeElements; 1226 VBoxVHWACommandElement mElementsBuffer[2048]; 1227 }; 1228 1204 1229 1205 1230 class VBoxGLWidget : public QGLWidget … … 1247 1272 void vboxResizeEvent (VBoxResizeEvent *re) {vboxPerformGLOp(&VBoxGLWidget::vboxDoResize, re); } 1248 1273 1249 void vboxProcessVHWACommands(class VBoxVHWACommand ProcessEvent * pEvent) {vboxPerformGLOp(&VBoxGLWidget::vboxDoProcessVHWACommands, pEvent);}1274 void vboxProcessVHWACommands(class VBoxVHWACommandElementProcessor * pPipe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoProcessVHWACommands, pPipe);} 1250 1275 #ifdef VBOX_WITH_VIDEOHWACCEL 1251 1276 void vboxVHWACmd (struct _VBOXVHWACMD * pCmd) {vboxPerformGLOp(&VBoxGLWidget::vboxDoVHWACmd, pCmd);} … … 1254 1279 1255 1280 VBoxVHWASurfaceBase * vboxGetVGASurface() { return mDisplay.getVGA(); } 1256 1257 void postCmd(VBOXVHWA_PIPECMD_TYPE aType, void * pvData);1258 1281 1259 1282 static void doSetupMatrix(const QSize & aSize, bool bInverted); … … 1333 1356 void vboxExecOnResize(PFNVBOXQGLOP pfn, void* pContext); 1334 1357 1335 void cmdPipeInit();1336 void cmdPipeDelete();1337 1358 void vboxDoProcessVHWACommands(void *pContext); 1338 1359 1339 class VBoxVHWACommandElement * detachCmdList(class VBoxVHWACommandElement * pFirst2Free, VBoxVHWACommandElement * pLast2Free);1340 1360 class VBoxVHWACommandElement * processCmdList(class VBoxVHWACommandElement * pCmd); 1341 1361 … … 1354 1374 ulong mPixelFormat; 1355 1375 bool mUsesGuestVRAM; 1356 bool mbVGASurfCreated;1376 // bool mbVGASurfCreated; 1357 1377 QRect mViewport; 1358 1359 RTCRITSECT mCritSect;1360 class VBoxVHWACommandProcessEvent *mpFirstEvent;1361 class VBoxVHWACommandProcessEvent *mpLastEvent;1362 bool mbNewEvent;1363 VBoxVHWACommandElementStack mFreeElements;1364 VBoxVHWACommandElement mElementsBuffer[2048];1365 1378 1366 1379 VBoxConsoleView *mView; … … 1413 1426 // void vboxMakeCurrent(); 1414 1427 VBoxGLWidget * vboxWidget(); 1428 1429 VBoxVHWACommandElementProcessor mCmdPipe; 1415 1430 }; 1416 1431 … … 1441 1456 void vboxUpdateOverlayPosition(const QPoint & pos); 1442 1457 void vboxUpdateOverlay(const QRect & rect, bool show); 1458 VBoxVHWACommandElement * processCmdList(VBoxVHWACommandElement * pCmd); 1443 1459 VBoxGLWidget *mpOverlayWidget; 1444 1460 bool mGlOn; 1445 1461 bool mOverlayVisible; 1446 1462 VBoxVHWADirtyRect mMainDirtyRect; 1463 1464 VBoxVHWACommandElementProcessor mCmdPipe; 1447 1465 }; 1448 1466 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp
r22795 r22796 806 806 } 807 807 VBoxVHWACommandElementPipe & pipe() { return mCmdPipe; } 808 809 VBoxVHWACommandProcessEvent *mpNext; 808 810 private: 809 811 VBoxVHWACommandElementPipe mCmdPipe; 810 VBoxVHWACommandProcessEvent *mpNext;811 812 friend class VBoxGLWidget;813 812 }; 814 813 … … 2931 2930 2932 2931 VBoxQGLFrameBuffer::VBoxQGLFrameBuffer (VBoxConsoleView *aView) : 2933 VBoxFrameBuffer (aView) 2932 VBoxFrameBuffer (aView), 2933 mCmdPipe(aView) 2934 2934 { 2935 2935 // mWidget = new GLWidget(aView->viewport()); … … 2956 2956 #else 2957 2957 QRect r(aX, aY, aW, aH); 2958 vboxWidget()->postCmd(VBOXVHWA_PIPECMD_PAINT, &r);2958 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_PAINT, &r); 2959 2959 #endif 2960 2960 return S_OK; … … 3022 3022 void VBoxQGLFrameBuffer::doProcessVHWACommand(QEvent * pEvent) 3023 3023 { 3024 vboxWidget()->vboxProcessVHWACommands( (VBoxVHWACommandProcessEvent*)pEvent);3024 vboxWidget()->vboxProcessVHWACommands(&mCmdPipe); 3025 3025 } 3026 3026 … … 3032 3032 mPixelFormat(0), 3033 3033 mUsesGuestVRAM(false), 3034 mbVGASurfCreated(false),3034 // mbVGASurfCreated(false), 3035 3035 mView(aView), 3036 3036 mConstructingList(NULL), 3037 3037 mcRemaining2Contruct(0) 3038 3038 { 3039 cmdPipeInit();3040 3039 mpMngr = new VBoxVHWAGlProgramMngr(); 3041 3040 // /* No need for background drawing */ … … 3060 3059 { 3061 3060 delete mpMngr; 3062 cmdPipeDelete(); 3063 } 3064 3065 void VBoxGLWidget::cmdPipeInit() 3066 { 3067 int rc = RTCritSectInit(&mCritSect); 3068 AssertRC(rc); 3069 3070 mpFirstEvent = NULL; 3071 mpLastEvent = NULL; 3072 mbNewEvent = false; 3073 for(int i = RT_ELEMENTS(mElementsBuffer) - 1; i >= 0; i--) 3074 { 3075 mFreeElements.push(&mElementsBuffer[i]); 3076 } 3077 } 3078 3079 void VBoxGLWidget::cmdPipeDelete() 3080 { 3081 RTCritSectDelete(&mCritSect); 3082 } 3061 } 3062 3083 3063 3084 3064 void VBoxGLWidget::doSetupMatrix(const QSize & aSize, bool bInverted) … … 3127 3107 } 3128 3108 3129 void VBoxGLWidget::postCmd(VBOXVHWA_PIPECMD_TYPE aType, void * pvData)3130 {3131 /* 1. lock*/3132 RTCritSectEnter(&mCritSect);3133 VBoxVHWACommandElement * pCmd = mFreeElements.pop();3134 if(!pCmd)3135 {3136 VBOXQGLLOG(("!!!no more free elements!!!\n"));3137 #ifdef VBOXQGL_PROF_BASE3138 RTCritSectLeave(&mCritSect);3139 return;3140 #else3141 //TODO:3142 #endif3143 }3144 pCmd->setData(aType, pvData);3145 /* 2. if can add to current*/3146 if(!mbNewEvent)3147 {3148 /* 3. if event is being processed (event != 0) */3149 if(mpLastEvent)3150 {3151 /* 3.a add cmd to event */3152 mpLastEvent->pipe().put(pCmd);3153 /* 3.b unlock and return */3154 RTCritSectLeave(&mCritSect);3155 return;3156 }3157 }3158 3159 /* we're here because the cmd was NOT be added to the current event queue */3160 /* 4. unlock*/3161 RTCritSectLeave(&mCritSect);3162 /* 5. create & initialize new Event */3163 VBoxVHWACommandProcessEvent *pCurrentEvent = new VBoxVHWACommandProcessEvent(pCmd);3164 /* 6. lock */3165 RTCritSectEnter(&mCritSect);3166 /* 7. if no current event set event as current */3167 if(!mpLastEvent)3168 {3169 Assert(!mpFirstEvent);3170 mpFirstEvent = pCurrentEvent;3171 mpLastEvent = pCurrentEvent;3172 pCurrentEvent->mpNext = NULL;3173 }3174 else3175 {3176 mpLastEvent->mpNext = pCurrentEvent;3177 mpLastEvent = pCurrentEvent;3178 }3179 /* 8. reset blocking events counter */3180 mbNewEvent = false;3181 /* 9. unlock */3182 RTCritSectLeave(&mCritSect);3183 /* 10. post event */3184 QApplication::postEvent (mView, pCurrentEvent);3185 }3186 3187 VBoxVHWACommandElement * VBoxGLWidget::detachCmdList(VBoxVHWACommandElement * pFirst2Free, VBoxVHWACommandElement * pLast2Free)3188 {3189 VBoxVHWACommandElement * pList = NULL;3190 RTCritSectEnter(&mCritSect);3191 if(pFirst2Free)3192 {3193 mFreeElements.pusha(pFirst2Free, pLast2Free);3194 }3195 if(mpFirstEvent)3196 {3197 pList = mpFirstEvent->pipe().detachList();3198 if(!pList)3199 {3200 VBoxVHWACommandProcessEvent *pNext = mpFirstEvent->mpNext;3201 if(pNext)3202 {3203 mpFirstEvent = pNext;3204 }3205 else3206 {3207 mpFirstEvent = NULL;3208 mpLastEvent = NULL;3209 }3210 }3211 }3212 RTCritSectLeave(&mCritSect);3213 3214 return pList;3215 }3216 3217 3109 VBoxVHWACommandElement * VBoxGLWidget::processCmdList(VBoxVHWACommandElement * pCmd) 3218 3110 { … … 3248 3140 void VBoxGLWidget::vboxDoProcessVHWACommands(void *pContext) 3249 3141 { 3250 Q_UNUSED(pContext);3251 VBoxVHWACommandElement * pFirst = detachCmdList(NULL, NULL);3142 VBoxVHWACommandElementProcessor * pPipe = (VBoxVHWACommandElementProcessor*)pContext; 3143 VBoxVHWACommandElement * pFirst = pPipe->detachCmdList(NULL, NULL); 3252 3144 do 3253 3145 { 3254 3146 VBoxVHWACommandElement * pLast = processCmdList(pFirst); 3255 3147 3256 pFirst = detachCmdList(pFirst, pLast);3148 pFirst = pPipe->detachCmdList(pFirst, pLast); 3257 3149 } while(pFirst); 3258 3150 … … 3277 3169 // QApplication::postEvent (mView, 3278 3170 // new VBoxVHWACommandProcessEvent (pCmd)); 3279 vboxWidget()->postCmd(VBOXVHWA_PIPECMD_VHWA, pCmd);3171 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_VHWA, pCmd); 3280 3172 return S_OK; 3281 3173 } … … 3518 3410 { 3519 3411 bPrimary = true; 3520 if(!mbVGASurfCreated) 3521 { 3522 VBoxVHWASurfaceBase * pVga = vboxGetVGASurface(); 3523 if(pCmd->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_RGB) 3412 VBoxVHWASurfaceBase * pVga = vboxGetVGASurface(); 3413 3414 if(pVga->handle() == VBOXVHWA_SURFHANDLE_INVALID) 3415 { 3416 Assert(pCmd->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_RGB); 3417 // if(pCmd->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_RGB) 3524 3418 { 3525 if(pCmd->SurfInfo.width == pVga->width() 3526 && pCmd->SurfInfo.height == pVga->height()) 3419 Assert(pCmd->SurfInfo.width == pVga->width()); 3420 Assert(pCmd->SurfInfo.height == pVga->height()); 3421 // if(pCmd->SurfInfo.width == pVga->width() 3422 // && pCmd->SurfInfo.height == pVga->height()) 3527 3423 { 3528 3424 VBoxVHWAColorFormat format(pCmd->SurfInfo.PixelFormat.c.rgbBitCount, … … 3530 3426 pCmd->SurfInfo.PixelFormat.m2.rgbGBitMask, 3531 3427 pCmd->SurfInfo.PixelFormat.m3.rgbBBitMask); 3532 if(pVga->colorFormat().equals(format)) 3428 Assert(pVga->colorFormat().equals(format)); 3429 // if(pVga->colorFormat().equals(format)) 3533 3430 { 3534 3431 surf = pVga; … … 3542 3439 surf->setDefaultSrcOverlayCKey(pDstOverlayCKey); 3543 3440 surf->resetDefaultSrcOverlayCKey(); 3544 mbVGASurfCreated = true;3441 // mbVGASurfCreated = true; 3545 3442 } 3546 3443 } … … 3613 3510 else if(bPrimary) 3614 3511 { 3615 Assert(mbVGASurfCreated); 3512 VBoxVHWASurfaceBase * pVga = vboxGetVGASurface(); 3513 Assert(pVga->handle() != VBOXVHWA_SURFHANDLE_INVALID); 3514 Assert(pVga != surf); 3515 // Assert(mbVGASurfCreated); 3616 3516 mDisplay.getVGA()->getComplexList()->add(surf); 3617 if(pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_VISIBLE) 3517 Assert(pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_VISIBLE); 3518 // if(pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_VISIBLE) 3618 3519 { 3619 3520 Assert(surf->getComplexList() == mDisplay.getVGA()->getComplexList()); 3620 3521 surf->getComplexList()->setCurrentVisible(surf); 3522 mDisplay.updateVGA(surf); 3621 3523 } 3622 3524 } … … 3631 3533 } 3632 3534 } 3535 3536 Assert(mDisplay.getVGA() == mDisplay.getPrimary()); 3633 3537 3634 3538 /* tell the guest how we think the memory is organized */ … … 3666 3570 { 3667 3571 VBoxVHWASurfaceBase *pSurf = handle2Surface(pCmd->u.in.hSurf); 3572 VBoxVHWASurfList *pList = pSurf->getComplexList(); 3573 Assert(pSurf->handle() != VBOXVHWA_SURFHANDLE_INVALID); 3574 3668 3575 VBOXQGLLOG_ENTER(("pSurf (0x%x)\n",pSurf)); 3669 if(pSurf != mDisplay.getVGA()) 3670 { 3671 VBoxVHWASurfList *pList = pSurf->getComplexList(); 3672 if(pList) 3673 { 3674 pList->remove(pSurf); 3675 if(pList->surfaces().empty()) 3576 if(pList != mDisplay.getVGA()->getComplexList()) 3577 { 3578 Assert(pList); 3579 pList->remove(pSurf); 3580 if(pList->surfaces().empty()) 3581 { 3582 mDisplay.removeOverlay(pList); 3583 // Assert(mConstructingList != pList); 3584 if(pList == mConstructingList) 3676 3585 { 3677 mDisplay.removeOverlay(pList); 3678 // Assert(mConstructingList != pList); 3679 if(pList == mConstructingList) 3586 mConstructingList = NULL; 3587 mcRemaining2Contruct = 0; 3588 } 3589 delete pList; 3590 } 3591 3592 delete(pSurf); 3593 } 3594 else 3595 { 3596 Assert(pList->size() >= 1); 3597 if(pList->size() > 1) 3598 { 3599 if(pSurf == mDisplay.getVGA()) 3600 { 3601 const SurfList & surfaces = pList->surfaces(); 3602 3603 for (SurfList::const_iterator it = surfaces.begin(); 3604 it != surfaces.end(); ++ it) 3680 3605 { 3681 mConstructingList = NULL; 3682 mcRemaining2Contruct = 0; 3683 } 3684 delete pList; 3685 } 3686 else if(pList == mDisplay.getVGA()->getComplexList()) 3687 { 3688 if(pList->current() == NULL) 3689 { 3690 pList->setCurrentVisible(mDisplay.getVGA()); 3606 VBoxVHWASurfaceBase *pCurSurf = (*it); 3607 if(pCurSurf != pSurf) 3608 { 3609 mDisplay.updateVGA(pCurSurf); 3610 pList->setCurrentVisible(pCurSurf); 3611 break; 3612 } 3691 3613 } 3692 3614 } 3693 } 3694 3695 delete(pSurf);3696 }3697 else3698 {3699 Assert(mbVGASurfCreated);3700 mbVGASurfCreated = false;3615 3616 pList->remove(pSurf); 3617 delete(pSurf); 3618 } 3619 else 3620 { 3621 pSurf->setHandle(VBOXVHWA_SURFHANDLE_INVALID); 3622 } 3701 3623 } 3702 3624 … … 3934 3856 vboxCheckUpdateAddress (pDstSurf, pCmd->u.in.offDstSurface); 3935 3857 VBOXQGLLOG(("pDstSurf (0x%x)\n",pDstSurf)); 3858 Assert(pDstSurf == mDisplay.getVGA()); 3859 Assert(mDisplay.getVGA() == mDisplay.getPrimary()); 3860 Assert(pDstSurf->getComplexList() == mDisplay.getVGA()->getComplexList()); 3861 3862 if(pCmd->u.in.flags & VBOXVHWA_OVER_SHOW) 3863 { 3864 if(pDstSurf != mDisplay.getPrimary()) 3865 { 3866 mDisplay.updateVGA(pDstSurf); 3867 pDstSurf->getComplexList()->setCurrentVisible(pDstSurf); 3868 } 3869 } 3936 3870 } 3937 3871 … … 4468 4402 uint32_t cPrimary = (uint32_t)primaryList.size(); 4469 4403 Assert(cPrimary >= 1); 4470 if( !mbVGASurfCreated)4404 if(mDisplay.getVGA()->handle() == VBOXVHWA_SURFHANDLE_INVALID) 4471 4405 { 4472 4406 cPrimary -= 1; … … 4478 4412 { 4479 4413 VBoxVHWASurfaceBase *pSurf = *pr; 4480 bool bVga = (pSurf == mDisplay.getVGA());4414 // bool bVga = (pSurf == mDisplay.getVGA()); 4481 4415 bool bVisible = (pSurf == mDisplay.getPrimary()); 4482 4416 uint32_t flags = VBOXVHWA_SCAPS_PRIMARYSURFACE; … … 4484 4418 flags |= VBOXVHWA_SCAPS_VISIBLE; 4485 4419 4486 if( mbVGASurfCreated || !bVga)4420 if(pSurf->handle() != VBOXVHWA_SURFHANDLE_INVALID) 4487 4421 { 4488 4422 rc = vhwaSaveSurface(pSSM, *pr, flags); AssertRC(rc); … … 4491 4425 Assert(cPrimary < UINT32_MAX / 2); 4492 4426 #endif 4427 } 4428 else 4429 { 4430 Assert(pSurf == mDisplay.getVGA()); 4493 4431 } 4494 4432 } … … 5290 5228 : VBoxQImageFrameBuffer(aView), 5291 5229 mGlOn(false), 5292 mOverlayVisible(false) 5230 mOverlayVisible(false), 5231 mCmdPipe(aView) 5293 5232 { 5294 5233 mpOverlayWidget = new VBoxGLWidget (aView, aView->viewport()); … … 5305 5244 // QApplication::postEvent (mView, 5306 5245 // new VBoxVHWACommandProcessEvent (pCmd)); 5307 m pOverlayWidget->postCmd(VBOXVHWA_PIPECMD_VHWA, pCmd);5246 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_VHWA, pCmd); 5308 5247 return S_OK; 5309 5248 // return E_NOTIMPL; … … 5312 5251 void VBoxQGLOverlayFrameBuffer::doProcessVHWACommand(QEvent * pEvent) 5313 5252 { 5314 mpOverlayWidget->vboxProcessVHWACommands((VBoxVHWACommandProcessEvent*)pEvent); 5253 Q_UNUSED(pEvent); 5254 VBoxVHWACommandElement * pFirst = mCmdPipe.detachCmdList(NULL, NULL); 5255 do 5256 { 5257 VBoxVHWACommandElement * pLast = processCmdList(pFirst); 5258 5259 pFirst = mCmdPipe.detachCmdList(pFirst, pLast); 5260 } while(pFirst); 5315 5261 } 5316 5262 … … 5318 5264 ULONG aW, ULONG aH) 5319 5265 { 5320 return VBoxQImageFrameBuffer::NotifyUpdate(aX, aY, aW, aH); 5266 QRect r(aX, aY, aW, aH); 5267 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_PAINT, &r); 5268 return S_OK; 5321 5269 } 5322 5270 … … 5494 5442 } 5495 5443 } 5496 #endif 5497 #endif 5444 5445 VBoxVHWACommandElement * VBoxQGLOverlayFrameBuffer::processCmdList(VBoxVHWACommandElement * pCmd) 5446 { 5447 VBoxVHWACommandElement * pCur; 5448 do 5449 { 5450 pCur = pCmd; 5451 switch(pCmd->type()) 5452 { 5453 case VBOXVHWA_PIPECMD_PAINT: 5454 // vboxDoUpdateRect(&pCmd->rect()); 5455 break; 5456 #ifdef VBOX_WITH_VIDEOHWACCEL 5457 case VBOXVHWA_PIPECMD_VHWA: 5458 // vboxDoVHWACmd(pCmd->vhwaCmd()); 5459 break; 5460 case VBOXVHWA_PIPECMD_OP: 5461 { 5462 const VBOXVHWACALLBACKINFO & info = pCmd->op(); 5463 (info.pThis->*(info.pfnCallback))(info.pContext); 5464 break; 5465 } 5466 #endif 5467 default: 5468 Assert(0); 5469 } 5470 pCmd = pCmd->mpNext; 5471 } while(pCmd); 5472 5473 return pCur; 5474 } 5475 5476 #endif 5477 5478 VBoxVHWACommandElementProcessor::VBoxVHWACommandElementProcessor(VBoxConsoleView *aView) 5479 { 5480 int rc = RTCritSectInit(&mCritSect); 5481 AssertRC(rc); 5482 5483 mpFirstEvent = NULL; 5484 mpLastEvent = NULL; 5485 mbNewEvent = false; 5486 mView = aView; 5487 for(int i = RT_ELEMENTS(mElementsBuffer) - 1; i >= 0; i--) 5488 { 5489 mFreeElements.push(&mElementsBuffer[i]); 5490 } 5491 } 5492 5493 VBoxVHWACommandElementProcessor::~VBoxVHWACommandElementProcessor() 5494 { 5495 RTCritSectDelete(&mCritSect); 5496 } 5497 5498 void VBoxVHWACommandElementProcessor::postCmd(VBOXVHWA_PIPECMD_TYPE aType, void * pvData) 5499 { 5500 /* 1. lock*/ 5501 RTCritSectEnter(&mCritSect); 5502 VBoxVHWACommandElement * pCmd = mFreeElements.pop(); 5503 if(!pCmd) 5504 { 5505 VBOXQGLLOG(("!!!no more free elements!!!\n")); 5506 #ifdef VBOXQGL_PROF_BASE 5507 RTCritSectLeave(&mCritSect); 5508 return; 5509 #else 5510 //TODO: 5511 #endif 5512 } 5513 pCmd->setData(aType, pvData); 5514 /* 2. if can add to current*/ 5515 if(!mbNewEvent) 5516 { 5517 /* 3. if event is being processed (event != 0) */ 5518 if(mpLastEvent) 5519 { 5520 /* 3.a add cmd to event */ 5521 mpLastEvent->pipe().put(pCmd); 5522 /* 3.b unlock and return */ 5523 RTCritSectLeave(&mCritSect); 5524 return; 5525 } 5526 } 5527 5528 /* we're here because the cmd was NOT be added to the current event queue */ 5529 /* 4. unlock*/ 5530 RTCritSectLeave(&mCritSect); 5531 /* 5. create & initialize new Event */ 5532 VBoxVHWACommandProcessEvent *pCurrentEvent = new VBoxVHWACommandProcessEvent(pCmd); 5533 /* 6. lock */ 5534 RTCritSectEnter(&mCritSect); 5535 /* 7. if no current event set event as current */ 5536 if(!mpLastEvent) 5537 { 5538 Assert(!mpFirstEvent); 5539 mpFirstEvent = pCurrentEvent; 5540 mpLastEvent = pCurrentEvent; 5541 pCurrentEvent->mpNext = NULL; 5542 } 5543 else 5544 { 5545 mpLastEvent->mpNext = pCurrentEvent; 5546 mpLastEvent = pCurrentEvent; 5547 } 5548 /* 8. reset blocking events counter */ 5549 mbNewEvent = false; 5550 /* 9. unlock */ 5551 RTCritSectLeave(&mCritSect); 5552 /* 10. post event */ 5553 QApplication::postEvent (mView, pCurrentEvent); 5554 } 5555 5556 VBoxVHWACommandElement * VBoxVHWACommandElementProcessor::detachCmdList(VBoxVHWACommandElement * pFirst2Free, VBoxVHWACommandElement * pLast2Free) 5557 { 5558 VBoxVHWACommandElement * pList = NULL; 5559 RTCritSectEnter(&mCritSect); 5560 if(pFirst2Free) 5561 { 5562 mFreeElements.pusha(pFirst2Free, pLast2Free); 5563 } 5564 if(mpFirstEvent) 5565 { 5566 pList = mpFirstEvent->pipe().detachList(); 5567 if(!pList) 5568 { 5569 VBoxVHWACommandProcessEvent *pNext = mpFirstEvent->mpNext; 5570 if(pNext) 5571 { 5572 mpFirstEvent = pNext; 5573 } 5574 else 5575 { 5576 mpFirstEvent = NULL; 5577 mpLastEvent = NULL; 5578 } 5579 } 5580 } 5581 RTCritSectLeave(&mCritSect); 5582 5583 return pList; 5584 } 5585 5586 #endif
Note:
See TracChangeset
for help on using the changeset viewer.