Changeset 22800 in vbox
- Timestamp:
- Sep 7, 2009 10:38:06 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 52006
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h
r22798 r22800 911 911 typedef std::list <VBoxVHWASurfaceBase*> SurfList; 912 912 typedef std::list <VBoxVHWASurfList*> OverlayList; 913 typedef std::list <struct _VBOXVHWACMD *> VHWACommandList; 913 914 914 915 class VBoxVHWASurfList … … 1065 1066 typedef void (VBoxGLWidget::*PFNVBOXQGLOP)(void* ); 1066 1067 1068 typedef void (*PFNVBOXQGLFUNC)(void*, void*); 1069 1067 1070 typedef enum 1068 1071 { … … 1070 1073 VBOXVHWA_PIPECMD_VHWA, 1071 1074 VBOXVHWA_PIPECMD_OP, 1075 VBOXVHWA_PIPECMD_FUNC, 1072 1076 }VBOXVHWA_PIPECMD_TYPE; 1073 1077 … … 1079 1083 }VBOXVHWACALLBACKINFO; 1080 1084 1085 typedef struct VBOXVHWAFUNCCALLBACKINFO 1086 { 1087 PFNVBOXQGLFUNC pfnCallback; 1088 void * pContext1; 1089 void * pContext2; 1090 }VBOXVHWAFUNCCALLBACKINFO; 1091 1081 1092 class VBoxVHWACommandElement 1082 1093 { … … 1098 1109 mType = VBOXVHWA_PIPECMD_OP; 1099 1110 u.mCallback = aOp; 1111 } 1112 1113 void setFunc(const VBOXVHWAFUNCCALLBACKINFO & aOp) 1114 { 1115 mType = VBOXVHWA_PIPECMD_FUNC; 1116 u.mFuncCallback = aOp; 1100 1117 } 1101 1118 … … 1113 1130 setOp(*((VBOXVHWACALLBACKINFO *)pvData)); 1114 1131 break; 1132 case VBOXVHWA_PIPECMD_FUNC: 1133 setFunc(*((VBOXVHWAFUNCCALLBACKINFO *)pvData)); 1134 break; 1115 1135 default: 1116 1136 Assert(0); … … 1123 1143 struct _VBOXVHWACMD * vhwaCmd() const {return u.mpCmd;} 1124 1144 const VBOXVHWACALLBACKINFO & op() const {return u.mCallback; } 1145 const VBOXVHWAFUNCCALLBACKINFO & func() const {return u.mFuncCallback; } 1125 1146 1126 1147 VBoxVHWACommandElement * mpNext; … … 1131 1152 struct _VBOXVHWACMD * mpCmd; 1132 1153 VBOXVHWACALLBACKINFO mCallback; 1154 VBOXVHWAFUNCCALLBACKINFO mFuncCallback; 1133 1155 }u; 1134 1156 QRect mRect; … … 1227 1249 }; 1228 1250 1251 class VBoxVHWACommandsQueue 1252 { 1253 public: 1254 void enqueue(PFNVBOXQGLFUNC pfn, void* pContext1, void* pContext2); 1255 1256 VBoxVHWACommandElement * detachList(); 1257 1258 void freeList(VBoxVHWACommandElement * pList); 1259 1260 private: 1261 VBoxVHWACommandElementPipe mCmds; 1262 }; 1229 1263 1230 1264 class VBoxGLWidget : public QGLWidget … … 1245 1279 1246 1280 void vhwaSaveExec(struct SSMHANDLE * pSSM); 1247 int vhwaLoadExec( struct SSMHANDLE * pSSM, uint32_t u32Version);1281 int vhwaLoadExec(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version); 1248 1282 1249 1283 int vhwaSurfaceCanCreate(struct _VBOXVHWACMD_SURF_CANCREATE *pCmd); … … 1268 1302 ulong vboxBitsPerPixel() { return mDisplay.getVGA()->bitsPerPixel(); } 1269 1303 ulong vboxBytesPerLine() { return mDisplay.getVGA() ? mDisplay.getVGA()->bytesPerLine() : 0; } 1304 int vboxFbWidth() {return mDisplay.getVGA()->width(); } 1305 int vboxFbHeight() {return mDisplay.getVGA()->height(); } 1306 bool vboxIsInitialized() {return mDisplay.getVGA() != NULL; } 1270 1307 1271 1308 // void vboxPaintEvent (QPaintEvent *pe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoPaint, pe); } … … 1333 1370 1334 1371 int vhwaSaveSurface(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, uint32_t surfCaps); 1335 int vhwaLoadSurface( struct SSMHANDLE * pSSM, uint32_t u32Version);1372 int vhwaLoadSurface(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version); 1336 1373 int vhwaSaveOverlayData(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, bool bVisible); 1337 int vhwaLoadOverlayData( struct SSMHANDLE * pSSM, uint32_t u32Version);1374 int vhwaLoadOverlayData(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version); 1338 1375 void vhwaDoSurfaceOverlayUpdate(VBoxVHWASurfaceBase *pDstSurf, VBoxVHWASurfaceBase *pSrcSurf, struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE *pCmd); 1339 1376 #endif … … 1355 1392 // /* posts op to UI thread */ 1356 1393 // int vboxExecOpSynch(PFNVBOXQGLOP pfn, void* pContext); 1357 void vboxExecOnResize(PFNVBOXQGLOP pfn, void* pContext);1394 // void vboxExecOnResize(PFNVBOXQGLOP pfn, void* pContext); 1358 1395 1359 1396 void vboxDoProcessVHWACommands(void *pContext); … … 1385 1422 /* this is used in saved state restore to postpone surface restoration 1386 1423 * till the framebuffer size is restored */ 1387 V BoxVHWACommandElementPipe mResizePostProcessCmds;1424 VHWACommandList mOnResizeCmdList; 1388 1425 1389 1426 class VBoxVHWAGlProgramMngr *mpMngr; … … 1449 1486 1450 1487 void vboxUpdateRect(const QRect * pRect); 1488 1489 int vhwaLoadExec(struct SSMHANDLE * pSSM, uint32_t u32Version); 1490 void vhwaSaveExec(struct SSMHANDLE * pSSM); 1451 1491 private: 1452 1492 void makeCurrent() … … 1491 1531 void vboxCheckUpdateOverlay(const QRect & rect); 1492 1532 VBoxVHWACommandElement * processCmdList(VBoxVHWACommandElement * pCmd); 1533 1534 int vhwaConstruct(struct _VBOXVHWACMD_HH_CONSTRUCT *pCmd); 1535 1493 1536 VBoxGLWidget *mpOverlayWidget; 1494 1537 bool mGlOn; … … 1501 1544 1502 1545 VBoxVHWACommandElementProcessor mCmdPipe; 1546 1547 /* this is used in saved state restore to postpone surface restoration 1548 * till the framebuffer size is restored */ 1549 VHWACommandList mOnResizeCmdList; 1503 1550 }; 1504 1551 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp
r22798 r22800 58 58 #define VBOXQGL_STATE_NAMEBASE "QGLVHWAData" 59 59 #define VBOXQGL_STATE_VERSION 1 60 61 //#define VBOXQGLOVERLAY_STATE_NAMEBASE "QGLOverlayVHWAData" 62 //#define VBOXQGLOVERLAY_STATE_VERSION 1 63 60 64 #ifdef DEBUG_misha 61 65 # define VBOXQGL_STATE_DEBUG … … 3128 3132 break; 3129 3133 } 3134 case VBOXVHWA_PIPECMD_FUNC: 3135 { 3136 const VBOXVHWAFUNCCALLBACKINFO & info = pCmd->func(); 3137 info.pfnCallback(info.pContext1, info.pContext2); 3138 break; 3139 } 3130 3140 #endif 3131 3141 default: … … 4075 4085 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 4076 4086 VBoxGLWidget * pw = (VBoxGLWidget*)pvUser; 4077 return pw->vhwaLoadExec( pSSM, u32Version);4087 return pw->vhwaLoadExec(NULL, pSSM, u32Version); 4078 4088 } 4079 4089 … … 4157 4167 } 4158 4168 4159 int VBoxGLWidget::vhwaLoadSurface( struct SSMHANDLE * pSSM, uint32_t u32Version)4169 int VBoxGLWidget::vhwaLoadSurface(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version) 4160 4170 { 4161 4171 Q_UNUSED(u32Version); … … 4220 4230 } 4221 4231 4222 vboxExecOnResize(&VBoxGLWidget::vboxDoVHWACmdAndFree, pCmd); AssertRC(rc); 4232 pCmdList->push_back(pCmd); 4233 // vboxExecOnResize(&VBoxGLWidget::vboxDoVHWACmdAndFree, pCmd); AssertRC(rc); 4223 4234 // if(RT_SUCCESS(rc)) 4224 4235 // { … … 4308 4319 } 4309 4320 4310 int VBoxGLWidget::vhwaLoadOverlayData( struct SSMHANDLE * pSSM, uint32_t u32Version)4321 int VBoxGLWidget::vhwaLoadOverlayData(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version) 4311 4322 { 4312 4323 Q_UNUSED(u32Version); … … 4364 4375 rc = SSMR3GetS32(pSSM, &pUpdateOverlay->u.in.srcRect.bottom); AssertRC(rc); 4365 4376 4366 vboxExecOnResize(&VBoxGLWidget::vboxDoVHWACmdAndFree, pCmd); AssertRC(rc); 4377 pCmdList->push_back(pCmd); 4378 // vboxExecOnResize(&VBoxGLWidget::vboxDoVHWACmdAndFree, pCmd); AssertRC(rc); 4367 4379 // if(RT_SUCCESS(rc)) 4368 4380 // { … … 4402 4414 * 4403 4415 */ 4404 const SurfList & primaryList = mDisplay. getVGA()->getComplexList()->surfaces();4416 const SurfList & primaryList = mDisplay.primaries().surfaces(); 4405 4417 uint32_t cPrimary = (uint32_t)primaryList.size(); 4406 4418 Assert(cPrimary >= 1); 4407 if(mDisplay.getVGA() ->handle() == VBOXVHWA_SURFHANDLE_INVALID)4419 if(mDisplay.getVGA() == NULL || mDisplay.getVGA()->handle() == VBOXVHWA_SURFHANDLE_INVALID) 4408 4420 { 4409 4421 cPrimary -= 1; … … 4472 4484 } 4473 4485 4474 int VBoxGLWidget::vhwaLoadExec( struct SSMHANDLE * pSSM, uint32_t u32Version)4486 int VBoxGLWidget::vhwaLoadExec(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version) 4475 4487 { 4476 4488 VBOXQGL_LOAD_START(pSSM); … … 4479 4491 uint32_t u32; 4480 4492 4493 if(pCmdList == NULL) 4494 { 4495 /* use our own list */ 4496 pCmdList = &mOnResizeCmdList; 4497 } 4498 4481 4499 rc = SSMR3GetU32(pSSM, &u32); AssertRC(rc); 4482 4500 if(RT_SUCCESS(rc)) … … 4484 4502 for(uint32_t i = 0; i < u32; ++i) 4485 4503 { 4486 rc = vhwaLoadSurface(p SSM, u32Version); AssertRC(rc);4504 rc = vhwaLoadSurface(pCmdList, pSSM, u32Version); AssertRC(rc); 4487 4505 if(RT_FAILURE(rc)) 4488 4506 break; … … 4500 4518 for(uint32_t j = 0; j < cSurfs; ++j) 4501 4519 { 4502 rc = vhwaLoadSurface(p SSM, u32Version); AssertRC(rc);4520 rc = vhwaLoadSurface(pCmdList, pSSM, u32Version); AssertRC(rc); 4503 4521 if(RT_FAILURE(rc)) 4504 4522 break; … … 4507 4525 if(RT_SUCCESS(rc)) 4508 4526 { 4509 rc = vhwaLoadOverlayData(p SSM, u32Version); AssertRC(rc);4527 rc = vhwaLoadOverlayData(pCmdList, pSSM, u32Version); AssertRC(rc); 4510 4528 } 4511 4529 … … 4988 5006 #endif 4989 5007 4990 VBoxVHWACommandElement * pPpCmd = mResizePostProcessCmds.detachList();4991 if(pPpCmd)4992 {4993 processCmdList(pPpCmd);4994 while(pPpCmd)4995 {4996 VBoxVHWACommandElement * pCur = pPpCmd;4997 pPpCmd = pCur->mpNext;4998 delete pCur;4999 }5008 if(!mOnResizeCmdList.empty()) 5009 { 5010 for (VHWACommandList::const_iterator it = mOnResizeCmdList.begin(); 5011 it != mOnResizeCmdList.end(); ++ it) 5012 { 5013 VBOXVHWACMD * pCmd = (*it); 5014 vboxDoVHWACmdExec(pCmd); 5015 free(pCmd); 5016 } 5017 mOnResizeCmdList.clear(); 5000 5018 } 5001 5019 … … 5033 5051 // delete pEl; 5034 5052 //} 5035 5036 void VBoxGLWidget::vboxExecOnResize(PFNVBOXQGLOP pfn, void* pContext)5037 {5038 VBoxVHWACommandElement *pCmd = new VBoxVHWACommandElement();5039 VBOXVHWACALLBACKINFO info;5040 info.pThis = this;5041 info.pfnCallback = pfn;5042 info.pContext = pContext;5043 pCmd->setOp(info);5044 mResizePostProcessCmds.put(pCmd);5045 }5046 5053 5047 5054 //int VBoxGLWidget::vboxExecOpSynch(PFNVBOXQGLOP pfn, void* pContext) … … 5244 5251 mOverlayWidgetVisible = true; /* to ensure it is set hidden with vboxShowOverlay */ 5245 5252 vboxShowOverlay(false); 5253 5254 resizeEvent (new VBoxResizeEvent (FramebufferPixelFormat_Opaque, 5255 NULL, 0, 0, 640, 480)); 5246 5256 } 5247 5257 … … 5314 5324 VBoxQImageFrameBuffer::resizeEvent(re); 5315 5325 5326 bool bDoOpExit = false; 5327 5328 Assert(0); 5329 5316 5330 if(mGlOn) 5317 5331 { … … 5321 5335 /* need to ensure we're in synch */ 5322 5336 vboxSynchGl(); 5337 bDoOpExit = true; 5338 } 5339 5340 if(!mOnResizeCmdList.empty()) 5341 { 5342 for (VHWACommandList::const_iterator it = mOnResizeCmdList.begin(); 5343 it != mOnResizeCmdList.end(); ++ it) 5344 { 5345 VBOXVHWACMD * pCmd = (*it); 5346 vboxDoVHWACmdExec(pCmd); 5347 free(pCmd); 5348 } 5349 mOnResizeCmdList.clear(); 5350 bDoOpExit = true; 5351 } 5352 5353 if(bDoOpExit) 5354 { 5323 5355 vboxOpExit(); 5324 Assert(mGlCurrent == false); 5325 } 5356 } 5357 Assert(mGlCurrent == false); 5358 5326 5359 } 5327 5360 … … 5357 5390 void VBoxQGLOverlayFrameBuffer::vboxSynchGl() 5358 5391 { 5392 if(mpOverlayWidget->vboxIsInitialized() 5393 && pixelFormat() == mpOverlayWidget->vboxPixelFormat() 5394 && address() == mpOverlayWidget->vboxAddress() 5395 && bitsPerPixel() == mpOverlayWidget->vboxBitsPerPixel() 5396 && bytesPerLine() == mpOverlayWidget->vboxBytesPerLine() 5397 && width() == mpOverlayWidget->vboxFbWidth() 5398 && height() == mpOverlayWidget->vboxFbHeight()) 5399 { 5400 return; 5401 } 5359 5402 /* create and issue a resize event to the gl widget to ensure we have all gl data initialized 5360 5403 * and synchronized with the framebuffer */ … … 5396 5439 void VBoxQGLOverlayFrameBuffer::vboxDoCheckUpdateViewport() 5397 5440 { 5398 Assert(0); 5441 if(!mOverlayVisible) 5442 { 5443 vboxShowOverlay(false); 5444 return; 5445 } 5446 5399 5447 int cX = mView->contentsX(); 5400 5448 int cY = mView->contentsY(); … … 5488 5536 mOverlayViewport = mpOverlayWidget->overlaysRectUnion(); 5489 5537 } 5538 vboxDoCheckUpdateViewport(); 5490 5539 } 5491 5540 } break; … … 5505 5554 mOverlayViewport = mpOverlayWidget->overlaysRectUnion(); 5506 5555 } 5556 vboxDoCheckUpdateViewport(); 5507 5557 } 5508 5558 } break; … … 5571 5621 { 5572 5622 VBOXVHWACMD_HH_CONSTRUCT * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_HH_CONSTRUCT); 5573 pCmd->rc = mpOverlayWidget->vhwaConstruct(pBody);5623 pCmd->rc = vhwaConstruct(pBody); 5574 5624 } break; 5575 5625 default: … … 5578 5628 break; 5579 5629 } 5630 } 5631 5632 static DECLCALLBACK(void) vboxQGLOverlaySaveExec(PSSMHANDLE pSSM, void *pvUser) 5633 { 5634 VBoxQGLOverlayFrameBuffer * fb = (VBoxQGLOverlayFrameBuffer*)pvUser; 5635 fb->vhwaSaveExec(pSSM); 5636 } 5637 5638 static DECLCALLBACK(int) vboxQGLOverlayLoadExec(PSSMHANDLE pSSM, void *pvUser, uint32_t u32Version, uint32_t uPass) 5639 { 5640 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 5641 VBoxQGLOverlayFrameBuffer * fb = (VBoxQGLOverlayFrameBuffer*)pvUser; 5642 return fb->vhwaLoadExec(pSSM, u32Version); 5643 } 5644 5645 int VBoxQGLOverlayFrameBuffer::vhwaLoadExec(struct SSMHANDLE * pSSM, uint32_t u32Version) 5646 { 5647 // bool bTmp; 5648 // int rc = SSMR3GetBool(pSSM, &bTmp /*&mGlOn*/); AssertRC(rc); 5649 // rc = SSMR3GetBool(pSSM, &bTmp /*&mOverlayVisible*/); AssertRC(rc); 5650 // if(RT_SUCCESS(rc)) 5651 return mpOverlayWidget->vhwaLoadExec(&mOnResizeCmdList, pSSM, u32Version); 5652 // return rc; 5653 } 5654 5655 void VBoxQGLOverlayFrameBuffer::vhwaSaveExec(struct SSMHANDLE * pSSM) 5656 { 5657 // int rc = SSMR3PutBool(pSSM, mGlOn); AssertRC(rc); 5658 // rc = SSMR3PutBool(pSSM, mOverlayVisible); AssertRC(rc); 5659 // 5660 mpOverlayWidget->vhwaSaveExec(pSSM); 5661 } 5662 5663 int VBoxQGLOverlayFrameBuffer::vhwaConstruct(struct _VBOXVHWACMD_HH_CONSTRUCT *pCmd) 5664 { 5665 PVM pVM = (PVM)pCmd->pVM; 5666 uint32_t intsId = 0; /* @todo: set the proper id */ 5667 5668 char nameFuf[sizeof(VBOXQGL_STATE_NAMEBASE) + 8]; 5669 5670 char * pszName = nameFuf; 5671 sprintf(pszName, "%s%d", VBOXQGL_STATE_NAMEBASE, intsId); 5672 int rc = SSMR3RegisterExternal( 5673 pVM, /* The VM handle*/ 5674 pszName, /* Data unit name. */ 5675 intsId, /* The instance identifier of the data unit. 5676 * This must together with the name be unique. */ 5677 VBOXQGL_STATE_VERSION, /* Data layout version number. */ 5678 128, /* The approximate amount of data in the unit. 5679 * Only for progress indicators. */ 5680 NULL, NULL, NULL, /* pfnLiveXxx */ 5681 NULL, /* Prepare save callback, optional. */ 5682 vboxQGLOverlaySaveExec, /* Execute save callback, optional. */ 5683 NULL, /* Done save callback, optional. */ 5684 NULL, /* Prepare load callback, optional. */ 5685 vboxQGLOverlayLoadExec, /* Execute load callback, optional. */ 5686 NULL, /* Done load callback, optional. */ 5687 this /* User argument. */ 5688 ); 5689 Assert(RT_SUCCESS(rc)); 5690 return rc; 5580 5691 } 5581 5692 … … 5599 5710 const VBOXVHWACALLBACKINFO & info = pCmd->op(); 5600 5711 (info.pThis->*(info.pfnCallback))(info.pContext); 5712 break; 5713 } 5714 case VBOXVHWA_PIPECMD_FUNC: 5715 { 5716 const VBOXVHWAFUNCCALLBACKINFO & info = pCmd->func(); 5717 info.pfnCallback(info.pContext1, info.pContext2); 5601 5718 break; 5602 5719 } … … 5721 5838 } 5722 5839 5723 #endif 5840 5841 void VBoxVHWACommandsQueue::enqueue(PFNVBOXQGLFUNC pfn, void* pContext1, void* pContext2) 5842 { 5843 VBoxVHWACommandElement *pCmd = new VBoxVHWACommandElement(); 5844 VBOXVHWAFUNCCALLBACKINFO info; 5845 info.pfnCallback = pfn; 5846 info.pContext1 = pContext1; 5847 info.pContext2 = pContext2; 5848 pCmd->setFunc(info); 5849 mCmds.put(pCmd); 5850 } 5851 5852 VBoxVHWACommandElement * VBoxVHWACommandsQueue::detachList() 5853 { 5854 return mCmds.detachList(); 5855 } 5856 5857 void VBoxVHWACommandsQueue::freeList(VBoxVHWACommandElement * pList) 5858 { 5859 while(pList) 5860 { 5861 VBoxVHWACommandElement * pCur = pList; 5862 pList = pCur->mpNext; 5863 delete pCur; 5864 } 5865 } 5866 #endif
Note:
See TracChangeset
for help on using the changeset viewer.