Changeset 51260 in vbox for trunk/src/VBox/HostServices/SharedOpenGL
- Timestamp:
- May 15, 2014 3:35:56 PM (11 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h
r51217 r51260 417 417 int CrPMgrViewportUpdate(uint32_t idScreen); 418 418 int CrPMgrScreenChanged(uint32_t idScreen); 419 int CrPMgr NotifyResize(HCR_FRAMEBUFFER hFb);419 int CrPMgrResize(const struct VBVAINFOSCREEN *pScreen, void *pvVRAM, const uint32_t *pTargetMap); 420 420 int CrPMgrSaveState(PSSMHANDLE pSSM); 421 421 int CrPMgrLoadState(PSSMHANDLE pSSM, uint32_t version); … … 474 474 int8_t crVBoxServerCrCmdClrFillProcess(const VBOXCMDVBVA_CLRFILL_HDR *pCmd, uint32_t cbCmd); 475 475 int8_t crVBoxServerCrCmdFlipProcess(const VBOXCMDVBVA_FLIP *pFlip); 476 477 int crVBoxServerResizeScreen(const struct VBVAINFOSCREEN *pScreen, void *pvVRAM);478 476 479 477 //#define VBOX_WITH_CRSERVER_DUMPER -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
r51217 r51260 3576 3576 } 3577 3577 3578 static DECLCALLBACK(int) crVBoxCrCmdResize(HVBOXCRCMDSVR hSvr, const struct VBVAINFOSCREEN *pScreen, void *pvVRAM)3578 static DECLCALLBACK(int) crVBoxCrCmdResize(HVBOXCRCMDSVR hSvr, const struct VBVAINFOSCREEN *pScreen, const uint32_t *pTargetMap) 3579 3579 { 3580 3580 CRASSERT(cr_server.fCrCmdEnabled); 3581 return crVBoxServerResizeScreen(pScreen, pvVRAM);3581 return CrPMgrResize(pScreen, NULL, pTargetMap); 3582 3582 } 3583 3583 -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.cpp
r51141 r51260 113 113 mural->cUsedFBDatas = 0; 114 114 115 for (i = 0; i < cr_server.screenCount; ++i)115 for (i = 0; i < (uint32_t)cr_server.screenCount; ++i) 116 116 { 117 117 GLuint j; … … 360 360 } 361 361 362 for ( int j = pMI->cUsedFBDatas; j > i; --j)362 for (uint32_t j = pMI->cUsedFBDatas; j > i; --j) 363 363 { 364 364 pMI->apUsedFBDatas[j] = pMI->apUsedFBDatas[j-1]; … … 374 374 if (fFbWasUsed) 375 375 { 376 for ( int j = i; j < pMI->cUsedFBDatas - 1; ++j)376 for (uint32_t j = i; j < pMI->cUsedFBDatas - 1; ++j) 377 377 { 378 378 pMI->apUsedFBDatas[j] = pMI->apUsedFBDatas[j+1]; … … 394 394 } 395 395 396 397 int crVBoxServerResizeScreen(const struct VBVAINFOSCREEN *pScreen, void *pvVRAM)398 {399 int rc;400 HCR_FRAMEBUFFER hFb = CrPMgrFbGet(pScreen->u32ViewIndex);401 if (!hFb)402 {403 WARN(("CrPMgrFbGet failed"));404 return VERR_INVALID_PARAMETER;405 }406 407 rc = CrFbUpdateBegin(hFb);408 if (!RT_SUCCESS(rc))409 {410 WARN(("CrFbUpdateBegin failed %d", rc));411 return rc;412 }413 414 crVBoxServerMuralFbResizeBegin(hFb);415 416 rc = CrFbResize(hFb, pScreen, pvVRAM);417 if (!RT_SUCCESS(rc))418 {419 WARN(("CrFbResize failed %d", rc));420 }421 422 crVBoxServerMuralFbResizeEnd(hFb);423 424 CrFbUpdateEnd(hFb);425 426 CrPMgrNotifyResize(hFb);427 428 return rc;429 }430 431 396 DECLEXPORT(int) crVBoxServerNotifyResize(const struct VBVAINFOSCREEN *pScreen, void *pvVRAM) 432 397 { … … 437 402 } 438 403 439 int rc = crVBoxServerResizeScreen(pScreen, pvVRAM); 404 if (pScreen->u32ViewIndex >= (uint32_t)cr_server.screenCount) 405 { 406 WARN(("invalid view index")); 407 return VERR_INVALID_PARAMETER; 408 } 409 410 VBOXCMDVBVA_SCREENMAP_DECL(uint32_t, aTargetMap); 411 412 memset(aTargetMap, 0, sizeof (aTargetMap)); 413 414 ASMBitSet(aTargetMap, pScreen->u32ViewIndex); 415 416 int rc = CrPMgrResize(pScreen, pvVRAM, aTargetMap); 440 417 if (!RT_SUCCESS(rc)) 441 418 { -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp
r51217 r51260 114 114 #define PCR_FBENTRY_FROM_ENTRY(_pEntry) ((CR_FRAMEBUFFER_ENTRY*)((uint8_t*)(_pEntry) - RT_OFFSETOF(CR_FRAMEBUFFER_ENTRY, Entry))) 115 115 116 typedef struct CR_FB_INFO 117 { 118 CrFbDisplayComposite *pDpComposite; 119 uint32_t u32Id; 120 VBOXCMDVBVA_SCREENMAP_DECL(uint32_t, aTargetMap); 121 } CR_FB_INFO; 116 122 117 123 typedef struct CR_FBDISPLAY_INFO 118 124 { 119 uint32_t u32Mode;120 125 CrFbDisplayWindow *pDpWin; 121 126 CrFbDisplayWindowRootVr *pDpWinRootVr; 122 127 CrFbDisplayVrdp *pDpVrdp; 123 CrFbDisplayComposite *pDpComposite; 128 uint32_t u32Id; 129 int32_t iFb; 124 130 } CR_FBDISPLAY_INFO; 125 131 … … 138 144 CR_FBMAP FramebufferInitMap; 139 145 CR_FRAMEBUFFER aFramebuffers[CR_MAX_GUEST_MONITORS]; 146 CR_FB_INFO aFbInfos[CR_MAX_GUEST_MONITORS]; 140 147 bool fWindowsForceHidden; 141 148 uint32_t cbTmpBuf; … … 935 942 936 943 pFb->ScreenInfo = *pScreen; 937 pFb->pvVram = pvVRAM ;944 pFb->pvVram = pvVRAM ? pvVRAM : g_pvVRamBase + pScreen->u32StartOffset; 938 945 939 946 if (pFb->pDisplay) … … 992 999 993 1000 static int crPMgrModeModifyGlobal(uint32_t u32ModeAdd, uint32_t u32ModeRemove); 1001 static void crPMgrCleanUnusedDisplays(); 994 1002 995 1003 static CR_FBTEX* crFbTexAlloc() … … 3784 3792 } 3785 3793 3794 crPMgrCleanUnusedDisplays(); 3795 3786 3796 g_CrPresenter.fEnabled = false; 3787 3797 … … 3814 3824 memset(&g_CrPresenter, 0, sizeof (g_CrPresenter)); 3815 3825 g_CrPresenter.fEnabled = true; 3826 for (int i = 0; i < RT_ELEMENTS(g_CrPresenter.aDisplayInfos); ++i) 3827 { 3828 g_CrPresenter.aDisplayInfos[i].u32Id = i; 3829 g_CrPresenter.aDisplayInfos[i].iFb = -1; 3830 3831 g_CrPresenter.aFbInfos[i].u32Id = i; 3832 } 3833 3816 3834 g_CrPresenter.pFbTexMap = crAllocHashtable(); 3817 3835 if (g_CrPresenter.pFbTexMap) … … 3889 3907 hFb = CrPMgrFbGetNextInitialized(hFb)) 3890 3908 { 3891 uint32_t i dScreen= CrFbGetScreenInfo(hFb)->u32ViewIndex;3909 uint32_t iFb = CrFbGetScreenInfo(hFb)->u32ViewIndex; 3892 3910 CrFbDisplaySet(hFb, NULL); 3893 CR_FBDISPLAY_INFO *pInfo = &g_CrPresenter.aDisplayInfos[idScreen]; 3894 3895 if (pInfo->pDpComposite) 3896 delete pInfo->pDpComposite; 3897 3898 Assert(!pInfo->pDpWin); 3899 Assert(!pInfo->pDpWinRootVr); 3900 Assert(!pInfo->pDpVrdp); 3911 CR_FB_INFO *pFbInfo = &g_CrPresenter.aFbInfos[iFb]; 3912 if (pFbInfo->pDpComposite) 3913 { 3914 delete pFbInfo->pDpComposite; 3915 pFbInfo->pDpComposite = NULL; 3916 } 3901 3917 3902 3918 CrFbTerm(hFb); 3903 3919 } 3920 3921 crPMgrCleanUnusedDisplays(); 3904 3922 3905 3923 #ifndef VBOXVDBG_MEMCACHE_DISABLE … … 4047 4065 } 4048 4066 4049 CR_FBDISPLAY_INFO *p Info = &g_CrPresenter.aDisplayInfos[idScreen];4050 if (p Info->pDpWin)4051 { 4052 HCR_FRAMEBUFFER hFb = CrPMgrFbGet(idScreen);4053 if ( CrFbIsUpdating(hFb))4067 CR_FBDISPLAY_INFO *pDpInfo = &g_CrPresenter.aDisplayInfos[idScreen]; 4068 if (pDpInfo->pDpWin) 4069 { 4070 HCR_FRAMEBUFFER hFb = pDpInfo->iFb >= 0 ? CrPMgrFbGet(pDpInfo->iFb) : NULL; 4071 if (hFb && CrFbIsUpdating(hFb)) 4054 4072 { 4055 4073 WARN(("trying to update viewport while framebuffer is being updated")); … … 4057 4075 } 4058 4076 4059 int rc = p Info->pDpWin->UpdateBegin(hFb);4077 int rc = pDpInfo->pDpWin->UpdateBegin(hFb); 4060 4078 if (RT_SUCCESS(rc)) 4061 4079 { 4062 p Info->pDpWin->reparent(cr_server.screen[idScreen].winID);4063 4064 p Info->pDpWin->UpdateEnd(hFb);4080 pDpInfo->pDpWin->reparent(cr_server.screen[idScreen].winID); 4081 4082 pDpInfo->pDpWin->UpdateEnd(hFb); 4065 4083 } 4066 4084 else … … 4079 4097 } 4080 4098 4081 CR_FBDISPLAY_INFO *p Info = &g_CrPresenter.aDisplayInfos[idScreen];4082 if (p Info->pDpWin)4083 { 4084 HCR_FRAMEBUFFER hFb = CrPMgrFbGet( idScreen);4099 CR_FBDISPLAY_INFO *pDpInfo = &g_CrPresenter.aDisplayInfos[idScreen]; 4100 if (pDpInfo->iFb >= 0) 4101 { 4102 HCR_FRAMEBUFFER hFb = CrPMgrFbGet(pDpInfo->iFb); 4085 4103 if (CrFbIsUpdating(hFb)) 4086 4104 { … … 4089 4107 } 4090 4108 4091 int rc = p Info->pDpWin->UpdateBegin(hFb);4109 int rc = pDpInfo->pDpWin->UpdateBegin(hFb); 4092 4110 if (RT_SUCCESS(rc)) 4093 4111 { 4094 p Info->pDpWin->setViewportRect(&cr_server.screenVieport[idScreen].Rect);4095 p Info->pDpWin->UpdateEnd(hFb);4112 pDpInfo->pDpWin->setViewportRect(&cr_server.screenVieport[idScreen].Rect); 4113 pDpInfo->pDpWin->UpdateEnd(hFb); 4096 4114 } 4097 4115 else … … 4102 4120 } 4103 4121 4104 int CrPMgrModeModify(HCR_FRAMEBUFFER hFb, uint32_t u32ModeAdd, uint32_t u32ModeRemove) 4105 { 4106 uint32_t idScreen = CrFbGetScreenInfo(hFb)->u32ViewIndex; 4107 4108 CR_FBDISPLAY_INFO *pInfo = &g_CrPresenter.aDisplayInfos[idScreen]; 4122 static int crPMgrFbDisconnectDisplay(HCR_FRAMEBUFFER hFb, CrFbDisplayBase *pDp) 4123 { 4124 if (pDp->getFramebuffer() != hFb) 4125 return VINF_SUCCESS; 4126 4127 CrFbDisplayBase * pCurDp = (CrFbDisplayBase*)CrFbDisplayGet(hFb); 4128 if (!pCurDp) 4129 { 4130 WARN(("no display set, unexpected")); 4131 return VERR_INTERNAL_ERROR; 4132 } 4133 4134 if (pCurDp == pDp) 4135 { 4136 pDp->setFramebuffer(NULL); 4137 CrFbDisplaySet(hFb, NULL); 4138 return VINF_SUCCESS; 4139 } 4140 4141 uint32_t idFb = CrFbGetScreenInfo(hFb)->u32ViewIndex; 4142 CR_FB_INFO *pFbInfo = &g_CrPresenter.aFbInfos[idFb]; 4143 if (pFbInfo->pDpComposite != pCurDp) 4144 { 4145 WARN(("misconfig, expectig the curret framebuffer to be present, and thus composite is expected")); 4146 return VERR_INTERNAL_ERROR; 4147 } 4148 4149 if (pDp->getContainer() == pFbInfo->pDpComposite) 4150 { 4151 pFbInfo->pDpComposite->remove(pDp); 4152 uint32_t cDisplays = pFbInfo->pDpComposite->getDisplayCount(); 4153 if (cDisplays <= 1) 4154 { 4155 Assert(cDisplays == 1); 4156 CrFbDisplayBase *pDpFirst = pFbInfo->pDpComposite->first(); 4157 if (pDpFirst) 4158 pFbInfo->pDpComposite->remove(pDpFirst, false); 4159 CrFbDisplaySet(hFb, pDpFirst); 4160 } 4161 return VINF_SUCCESS; 4162 } 4163 4164 WARN(("misconfig")); 4165 return VERR_INTERNAL_ERROR; 4166 } 4167 4168 static int crPMgrFbConnectDisplay(HCR_FRAMEBUFFER hFb, CrFbDisplayBase *pDp) 4169 { 4170 if (pDp->getFramebuffer() == hFb) 4171 return VINF_SUCCESS; 4172 4173 CrFbDisplayBase * pCurDp = (CrFbDisplayBase*)CrFbDisplayGet(hFb); 4174 if (!pCurDp) 4175 { 4176 pDp->setFramebuffer(hFb); 4177 CrFbDisplaySet(hFb, pDp); 4178 return VINF_SUCCESS; 4179 } 4180 4181 if (pCurDp == pDp) 4182 { 4183 WARN(("misconfig, current framebuffer is not expected to be set")); 4184 return VERR_INTERNAL_ERROR; 4185 } 4186 4187 uint32_t idFb = CrFbGetScreenInfo(hFb)->u32ViewIndex; 4188 CR_FB_INFO *pFbInfo = &g_CrPresenter.aFbInfos[idFb]; 4189 if (pFbInfo->pDpComposite != pCurDp) 4190 { 4191 if (!pFbInfo->pDpComposite) 4192 { 4193 pFbInfo->pDpComposite = new CrFbDisplayComposite(); 4194 pFbInfo->pDpComposite->setFramebuffer(hFb); 4195 } 4196 4197 pFbInfo->pDpComposite->add(pCurDp); 4198 CrFbDisplaySet(hFb, pFbInfo->pDpComposite); 4199 } 4200 4201 pFbInfo->pDpComposite->add(pDp); 4202 return VINF_SUCCESS; 4203 } 4204 4205 static int crPMgrFbDisconnectTarget(HCR_FRAMEBUFFER hFb, uint32_t i) 4206 { 4207 uint32_t idFb = CrFbGetScreenInfo(hFb)->u32ViewIndex; 4208 CR_FB_INFO *pFbInfo = &g_CrPresenter.aFbInfos[idFb]; 4209 CR_FBDISPLAY_INFO *pDpInfo = &g_CrPresenter.aDisplayInfos[i]; 4210 if (pDpInfo->iFb != idFb) 4211 { 4212 WARN(("target not connected")); 4213 Assert(!ASMBitTest(pFbInfo->aTargetMap, i)); 4214 return VINF_SUCCESS; 4215 } 4216 4217 Assert(ASMBitTest(pFbInfo->aTargetMap, i)); 4218 4219 int rc = VINF_SUCCESS; 4220 if (pDpInfo->pDpVrdp) 4221 { 4222 rc = crPMgrFbDisconnectDisplay(hFb, pDpInfo->pDpVrdp); 4223 if (RT_FAILURE(rc)) 4224 { 4225 WARN(("crPMgrFbDisconnectDisplay failed %d", rc)); 4226 return rc; 4227 } 4228 } 4229 4230 if (pDpInfo->pDpWinRootVr) 4231 { 4232 rc = crPMgrFbDisconnectDisplay(hFb, pDpInfo->pDpWinRootVr); 4233 if (RT_FAILURE(rc)) 4234 { 4235 WARN(("crPMgrFbDisconnectDisplay failed %d", rc)); 4236 return rc; 4237 } 4238 } 4239 4240 if (pDpInfo->pDpWin) 4241 { 4242 rc = crPMgrFbDisconnectDisplay(hFb, pDpInfo->pDpWin); 4243 if (RT_FAILURE(rc)) 4244 { 4245 WARN(("crPMgrFbDisconnectDisplay failed %d", rc)); 4246 return rc; 4247 } 4248 } 4249 4250 ASMBitClear(pFbInfo->aTargetMap, i); 4251 pDpInfo->iFb = -1; 4252 4253 return VINF_SUCCESS; 4254 } 4255 4256 static void crPMgrDpWinRootVrCreate(CR_FBDISPLAY_INFO *pDpInfo) 4257 { 4258 if (!pDpInfo->pDpWinRootVr) 4259 { 4260 CrFbWindow *pWin = NULL; 4261 if (pDpInfo->pDpWin) 4262 { 4263 pWin = pDpInfo->pDpWin->windowDetach(); 4264 CRASSERT(pWin); 4265 delete pDpInfo->pDpWin; 4266 pDpInfo->pDpWin = NULL; 4267 } 4268 else 4269 pWin = new CrFbWindow(cr_server.screen[pDpInfo->u32Id].winID); 4270 4271 pDpInfo->pDpWinRootVr = new CrFbDisplayWindowRootVr(pWin, &cr_server.screenVieport[pDpInfo->u32Id].Rect); 4272 pDpInfo->pDpWin = pDpInfo->pDpWinRootVr; 4273 } 4274 } 4275 4276 static void crPMgrDpWinCreate(CR_FBDISPLAY_INFO *pDpInfo) 4277 { 4278 CrFbWindow *pWin = NULL; 4279 if (pDpInfo->pDpWinRootVr) 4280 { 4281 CRASSERT(pDpInfo->pDpWinRootVr == pDpInfo->pDpWin); 4282 pWin = pDpInfo->pDpWin->windowDetach(); 4283 CRASSERT(pWin); 4284 delete pDpInfo->pDpWinRootVr; 4285 pDpInfo->pDpWinRootVr = NULL; 4286 pDpInfo->pDpWin = NULL; 4287 } 4288 4289 if (!pDpInfo->pDpWin) 4290 { 4291 if (!pWin) 4292 pWin = new CrFbWindow(cr_server.screen[pDpInfo->u32Id].winID); 4293 4294 pDpInfo->pDpWin = new CrFbDisplayWindow(pWin, &cr_server.screenVieport[pDpInfo->u32Id].Rect); 4295 } 4296 } 4297 4298 static int crPMgrFbDisconnectTargetDisplays(HCR_FRAMEBUFFER hFb, CR_FBDISPLAY_INFO *pDpInfo, uint32_t u32ModeRemove) 4299 { 4300 int rc = VINF_SUCCESS; 4301 if (u32ModeRemove & CR_PMGR_MODE_ROOTVR) 4302 { 4303 CRASSERT(pDpInfo->pDpWinRootVr); 4304 CRASSERT(pDpInfo->pDpWin == pDpInfo->pDpWinRootVr); 4305 rc = crPMgrFbDisconnectDisplay(hFb, pDpInfo->pDpWinRootVr); 4306 if (RT_FAILURE(rc)) 4307 { 4308 WARN(("crPMgrFbDisconnectDisplay pDpWinRootVr failed %d", rc)); 4309 return rc; 4310 } 4311 } 4312 else if (u32ModeRemove & CR_PMGR_MODE_WINDOW) 4313 { 4314 CRASSERT(!pDpInfo->pDpWinRootVr); 4315 CRASSERT(pDpInfo->pDpWin); 4316 rc = crPMgrFbDisconnectDisplay(hFb, pDpInfo->pDpWin); 4317 if (RT_FAILURE(rc)) 4318 { 4319 WARN(("crPMgrFbDisconnectDisplay pDpWin failed %d", rc)); 4320 return rc; 4321 } 4322 } 4323 4324 if (u32ModeRemove & CR_PMGR_MODE_VRDP) 4325 { 4326 CRASSERT(pDpInfo->pDpVrdp); 4327 rc = crPMgrFbDisconnectDisplay(hFb, pDpInfo->pDpVrdp); 4328 if (RT_FAILURE(rc)) 4329 { 4330 WARN(("crPMgrFbDisconnectDisplay pDpVrdp failed %d", rc)); 4331 return rc; 4332 } 4333 } 4334 4335 return VINF_SUCCESS; 4336 } 4337 4338 static int crPMgrFbConnectTargetDisplays(HCR_FRAMEBUFFER hFb, CR_FBDISPLAY_INFO *pDpInfo, uint32_t u32ModeAdd) 4339 { 4340 int rc = VINF_SUCCESS; 4341 4342 if (u32ModeAdd & CR_PMGR_MODE_ROOTVR) 4343 { 4344 crPMgrDpWinRootVrCreate(pDpInfo); 4345 4346 rc = crPMgrFbConnectDisplay(hFb, pDpInfo->pDpWinRootVr); 4347 if (RT_FAILURE(rc)) 4348 { 4349 WARN(("crPMgrFbConnectDisplay pDpWinRootVr failed %d", rc)); 4350 return rc; 4351 } 4352 } 4353 else if (u32ModeAdd & CR_PMGR_MODE_WINDOW) 4354 { 4355 crPMgrDpWinCreate(pDpInfo); 4356 4357 rc = crPMgrFbConnectDisplay(hFb, pDpInfo->pDpWin); 4358 if (RT_FAILURE(rc)) 4359 { 4360 WARN(("crPMgrFbConnectDisplay pDpWin failed %d", rc)); 4361 return rc; 4362 } 4363 } 4364 4365 if (u32ModeAdd & CR_PMGR_MODE_VRDP) 4366 { 4367 if (!pDpInfo->pDpVrdp) 4368 pDpInfo->pDpVrdp = new CrFbDisplayVrdp(); 4369 4370 rc = crPMgrFbConnectDisplay(hFb, pDpInfo->pDpVrdp); 4371 if (RT_FAILURE(rc)) 4372 { 4373 WARN(("crPMgrFbConnectDisplay pDpVrdp failed %d", rc)); 4374 return rc; 4375 } 4376 } 4377 4378 return VINF_SUCCESS; 4379 } 4380 4381 static int crPMgrFbConnectTarget(HCR_FRAMEBUFFER hFb, uint32_t i) 4382 { 4383 uint32_t idFb = CrFbGetScreenInfo(hFb)->u32ViewIndex; 4384 CR_FB_INFO *pFbInfo = &g_CrPresenter.aFbInfos[idFb]; 4385 CR_FBDISPLAY_INFO *pDpInfo = &g_CrPresenter.aDisplayInfos[i]; 4386 if (pDpInfo->iFb == idFb) 4387 { 4388 WARN(("target not connected")); 4389 Assert(ASMBitTest(pFbInfo->aTargetMap, i)); 4390 return VINF_SUCCESS; 4391 } 4392 4393 Assert(!ASMBitTest(pFbInfo->aTargetMap, i)); 4394 4395 int rc = VINF_SUCCESS; 4396 4397 if (pDpInfo->iFb != -1) 4398 { 4399 Assert(pDpInfo->iFb < cr_server.screenCount); 4400 HCR_FRAMEBUFFER hAssignedFb = CrPMgrFbGet(pDpInfo->iFb); 4401 Assert(hAssignedFb); 4402 rc = crPMgrFbDisconnectTarget(hAssignedFb, i); 4403 if (RT_FAILURE(rc)) 4404 { 4405 WARN(("crPMgrFbDisconnectTarget failed %d", rc)); 4406 return rc; 4407 } 4408 } 4409 4410 rc = crPMgrFbConnectTargetDisplays(hFb, pDpInfo, g_CrPresenter.u32DisplayMode); 4411 if (RT_FAILURE(rc)) 4412 { 4413 WARN(("crPMgrFbConnectTargetDisplays failed %d", rc)); 4414 return rc; 4415 } 4416 4417 ASMBitSet(pFbInfo->aTargetMap, i); 4418 pDpInfo->iFb = idFb; 4419 4420 return VINF_SUCCESS; 4421 } 4422 4423 static int crPMgrFbDisconnect(HCR_FRAMEBUFFER hFb, const uint32_t *pTargetMap) 4424 { 4425 int rc = VINF_SUCCESS; 4426 for (int i = ASMBitFirstSet(pTargetMap, cr_server.screenCount); 4427 i >= 0; 4428 i = ASMBitNextSet(pTargetMap, cr_server.screenCount, i)) 4429 { 4430 rc = crPMgrFbDisconnectTarget(hFb, (uint32_t)i); 4431 if (RT_FAILURE(rc)) 4432 { 4433 WARN(("crPMgrFbDisconnectTarget failed %d", rc)); 4434 return rc; 4435 } 4436 } 4437 4438 return VINF_SUCCESS; 4439 } 4440 4441 static int crPMgrFbConnect(HCR_FRAMEBUFFER hFb, const uint32_t *pTargetMap) 4442 { 4443 int rc = VINF_SUCCESS; 4444 for (int i = ASMBitFirstSet(pTargetMap, cr_server.screenCount); 4445 i >= 0; 4446 i = ASMBitNextSet(pTargetMap, cr_server.screenCount, i)) 4447 { 4448 rc = crPMgrFbConnectTarget(hFb, (uint32_t)i); 4449 if (RT_FAILURE(rc)) 4450 { 4451 WARN(("crPMgrFbConnectTarget failed %d", rc)); 4452 return rc; 4453 } 4454 } 4455 4456 return VINF_SUCCESS; 4457 } 4458 4459 static int crPMgrModeModifyTarget(HCR_FRAMEBUFFER hFb, uint32_t iDisplay, uint32_t u32ModeAdd, uint32_t u32ModeRemove) 4460 { 4461 CR_FBDISPLAY_INFO *pDpInfo = &g_CrPresenter.aDisplayInfos[iDisplay]; 4462 int rc = crPMgrFbDisconnectTargetDisplays(hFb, pDpInfo, u32ModeRemove); 4463 if (RT_FAILURE(rc)) 4464 { 4465 WARN(("crPMgrFbDisconnectTargetDisplays failed %d", rc)); 4466 return rc; 4467 } 4468 4469 rc = crPMgrFbConnectTargetDisplays(hFb, pDpInfo, u32ModeAdd); 4470 if (RT_FAILURE(rc)) 4471 { 4472 WARN(("crPMgrFbConnectTargetDisplays failed %d", rc)); 4473 return rc; 4474 } 4475 4476 return VINF_SUCCESS; 4477 } 4478 4479 static int crPMgrModeModify(HCR_FRAMEBUFFER hFb, uint32_t u32ModeAdd, uint32_t u32ModeRemove) 4480 { 4481 int rc = VINF_SUCCESS; 4482 uint32_t idFb = CrFbGetScreenInfo(hFb)->u32ViewIndex; 4483 CR_FB_INFO *pFbInfo = &g_CrPresenter.aFbInfos[idFb]; 4484 for (int i = ASMBitFirstSet(pFbInfo->aTargetMap, cr_server.screenCount); 4485 i >= 0; 4486 i = ASMBitNextSet(pFbInfo->aTargetMap, cr_server.screenCount, i)) 4487 { 4488 rc = crPMgrModeModifyTarget(hFb, (uint32_t)i, u32ModeAdd, u32ModeRemove); 4489 if (RT_FAILURE(rc)) 4490 { 4491 WARN(("crPMgrModeModifyTarget failed %d", rc)); 4492 return rc; 4493 } 4494 } 4495 4496 return VINF_SUCCESS; 4497 } 4498 4499 static void crPMgrCleanUnusedDisplays() 4500 { 4501 for (int i = 0; i < cr_server.screenCount; ++i) 4502 { 4503 CR_FBDISPLAY_INFO *pDpInfo = &g_CrPresenter.aDisplayInfos[i]; 4504 4505 if (pDpInfo->pDpWinRootVr) 4506 { 4507 if (!pDpInfo->pDpWinRootVr->getFramebuffer()) 4508 { 4509 delete pDpInfo->pDpWinRootVr; 4510 pDpInfo->pDpWinRootVr = NULL; 4511 pDpInfo->pDpWin = NULL; 4512 } 4513 else 4514 WARN(("pDpWinRootVr is used")); 4515 } 4516 else if (pDpInfo->pDpWin) 4517 { 4518 if (!pDpInfo->pDpWin->getFramebuffer()) 4519 { 4520 delete pDpInfo->pDpWin; 4521 pDpInfo->pDpWin = NULL; 4522 } 4523 else 4524 WARN(("pDpWin is used")); 4525 } 4526 4527 if (pDpInfo->pDpVrdp) 4528 { 4529 if (!pDpInfo->pDpVrdp->getFramebuffer()) 4530 { 4531 delete pDpInfo->pDpVrdp; 4532 pDpInfo->pDpVrdp = NULL; 4533 } 4534 else 4535 WARN(("pDpVrdp is used")); 4536 } 4537 } 4538 } 4539 4540 static int crPMgrModeModifyGlobal(uint32_t u32ModeAdd, uint32_t u32ModeRemove) 4541 { 4542 uint32_t u32InternalMode = g_CrPresenter.fEnabled ? g_CrPresenter.u32DisplayMode : g_CrPresenter.u32DisabledDisplayMode; 4543 4109 4544 u32ModeRemove = ((u32ModeRemove | crPMgrModeAdjustVal(u32ModeRemove)) & CR_PMGR_MODE_ALL); 4110 4545 u32ModeAdd = crPMgrModeAdjustVal(u32ModeAdd); 4111 u32ModeRemove &= pInfo->u32Mode;4112 u32ModeAdd &= ~(u32ModeRemove | pInfo->u32Mode);4113 uint32_t u32ModeResulting = (( pInfo->u32Mode | u32ModeAdd) & ~u32ModeRemove);4546 u32ModeRemove &= u32InternalMode; 4547 u32ModeAdd &= ~(u32ModeRemove | u32InternalMode); 4548 uint32_t u32ModeResulting = ((u32InternalMode | u32ModeAdd) & ~u32ModeRemove); 4114 4549 uint32_t u32Tmp = crPMgrModeAdjustVal(u32ModeResulting); 4115 4550 if (u32Tmp != u32ModeResulting) … … 4118 4553 u32ModeRemove |= (~u32Tmp & u32ModeResulting); 4119 4554 u32ModeResulting = u32Tmp; 4120 Assert(u32ModeResulting == (( pInfo->u32Mode | u32ModeAdd) & ~u32ModeRemove));4555 Assert(u32ModeResulting == ((u32InternalMode | u32ModeAdd) & ~u32ModeRemove)); 4121 4556 } 4122 4557 if (!u32ModeRemove && !u32ModeAdd) 4123 4558 return VINF_SUCCESS; 4124 4559 4125 if (!pInfo->pDpComposite)4126 {4127 pInfo->pDpComposite = new CrFbDisplayComposite();4128 pInfo->pDpComposite->setFramebuffer(hFb);4129 }4130 4131 CrFbWindow * pOldWin = NULL;4132 4133 if (u32ModeRemove & CR_PMGR_MODE_ROOTVR)4134 {4135 CRASSERT(pInfo->pDpWinRootVr);4136 CRASSERT(pInfo->pDpWin == pInfo->pDpWinRootVr);4137 pInfo->pDpComposite->remove(pInfo->pDpWinRootVr);4138 pOldWin = pInfo->pDpWinRootVr->windowDetach();4139 CRASSERT(pOldWin);4140 delete pInfo->pDpWinRootVr;4141 pInfo->pDpWinRootVr = NULL;4142 pInfo->pDpWin = NULL;4143 }4144 else if (u32ModeRemove & CR_PMGR_MODE_WINDOW)4145 {4146 CRASSERT(!pInfo->pDpWinRootVr);4147 CRASSERT(pInfo->pDpWin);4148 pInfo->pDpComposite->remove(pInfo->pDpWin);4149 pOldWin = pInfo->pDpWin->windowDetach();4150 CRASSERT(pOldWin);4151 delete pInfo->pDpWin;4152 pInfo->pDpWin = NULL;4153 }4154 4155 if (u32ModeRemove & CR_PMGR_MODE_VRDP)4156 {4157 CRASSERT(pInfo->pDpVrdp);4158 if (pInfo->pDpComposite)4159 pInfo->pDpComposite->remove(pInfo->pDpVrdp);4160 else4161 CrFbDisplaySet(hFb, NULL);4162 4163 delete pInfo->pDpVrdp;4164 pInfo->pDpVrdp = NULL;4165 }4166 4167 CrFbDisplayBase *pDpToSet = NULL;4168 4169 if (u32ModeAdd & CR_PMGR_MODE_ROOTVR)4170 {4171 CRASSERT(!pInfo->pDpWin);4172 CRASSERT(!pInfo->pDpWinRootVr);4173 4174 if (!pOldWin)4175 pOldWin = new CrFbWindow(cr_server.screen[idScreen].winID);4176 4177 pInfo->pDpWinRootVr = new CrFbDisplayWindowRootVr(pOldWin, &cr_server.screenVieport[idScreen].Rect);4178 pOldWin = NULL;4179 pInfo->pDpWin = pInfo->pDpWinRootVr;4180 pInfo->pDpComposite->add(pInfo->pDpWinRootVr);4181 }4182 else if (u32ModeAdd & CR_PMGR_MODE_WINDOW)4183 {4184 CRASSERT(!pInfo->pDpWin);4185 CRASSERT(!pInfo->pDpWinRootVr);4186 4187 if (!pOldWin)4188 pOldWin = new CrFbWindow(cr_server.screen[idScreen].winID);4189 4190 pInfo->pDpWin = new CrFbDisplayWindow(pOldWin, &cr_server.screenVieport[idScreen].Rect);4191 pOldWin = NULL;4192 pInfo->pDpComposite->add(pInfo->pDpWin);4193 }4194 4195 if (u32ModeAdd & CR_PMGR_MODE_VRDP)4196 {4197 CRASSERT(!pInfo->pDpVrdp);4198 pInfo->pDpVrdp = new CrFbDisplayVrdp();4199 pInfo->pDpComposite->add(pInfo->pDpVrdp);4200 }4201 4202 if (pInfo->pDpComposite->getDisplayCount() > 1)4203 {4204 ICrFbDisplay* pCur = CrFbDisplayGet(hFb);4205 if (pCur != (ICrFbDisplay*)pInfo->pDpComposite)4206 CrFbDisplaySet(hFb, pInfo->pDpComposite);4207 }4208 else4209 {4210 ICrFbDisplay* pCur = CrFbDisplayGet(hFb);4211 ICrFbDisplay* pFirst = pInfo->pDpComposite->first();4212 if (pCur != pFirst)4213 CrFbDisplaySet(hFb, pFirst);4214 }4215 4216 if (pOldWin)4217 delete pOldWin;4218 4219 pInfo->u32Mode = u32ModeResulting;4220 4221 return VINF_SUCCESS;4222 }4223 4224 static int crPMgrModeModifyGlobal(uint32_t u32ModeAdd, uint32_t u32ModeRemove)4225 {4226 4560 uint32_t u32DisplayMode = (g_CrPresenter.u32DisplayMode | u32ModeAdd) & ~u32ModeRemove; 4227 4561 if (!g_CrPresenter.fEnabled) 4228 4562 { 4563 Assert(g_CrPresenter.u32DisplayMode == 0); 4229 4564 g_CrPresenter.u32DisabledDisplayMode = u32DisplayMode; 4230 4565 return VINF_SUCCESS; … … 4237 4572 hFb = CrPMgrFbGetNextEnabled(hFb)) 4238 4573 { 4239 CrPMgrModeModify(hFb, u32ModeAdd, u32ModeRemove);4574 crPMgrModeModify(hFb, u32ModeAdd, u32ModeRemove); 4240 4575 } 4241 4576 … … 4283 4618 g_CrPresenter.fWindowsForceHidden = !fEnable; 4284 4619 4620 for (int i = 0; i < cr_server.screenCount; ++i) 4621 { 4622 CR_FBDISPLAY_INFO *pDpInfo = &g_CrPresenter.aDisplayInfos[i]; 4623 4624 if (pDpInfo->iFb < 0) 4625 continue; 4626 4627 if (pDpInfo->pDpWin) 4628 pDpInfo->pDpWin->winVisibilityChanged(); 4629 } 4630 4631 return VINF_SUCCESS; 4632 } 4633 4634 int CrPMgrRootVrUpdate() 4635 { 4285 4636 for (HCR_FRAMEBUFFER hFb = CrPMgrFbGetFirstEnabled(); 4286 4637 hFb; 4287 4638 hFb = CrPMgrFbGetNextEnabled(hFb)) 4288 4639 { 4289 uint32_t idScreen = CrFbGetScreenInfo(hFb)->u32ViewIndex;4290 4291 CR_FBDISPLAY_INFO *pInfo = &g_CrPresenter.aDisplayInfos[idScreen];4292 4293 if (pInfo->pDpWin)4294 pInfo->pDpWin->winVisibilityChanged();4295 }4296 4297 return VINF_SUCCESS;4298 }4299 4300 int CrPMgrRootVrUpdate()4301 {4302 for (HCR_FRAMEBUFFER hFb = CrPMgrFbGetFirstEnabled();4303 hFb;4304 hFb = CrPMgrFbGetNextEnabled(hFb))4305 {4306 4640 if (!CrFbHas3DData(hFb)) 4307 4641 continue; 4308 4642 4309 uint32_t id Screen= CrFbGetScreenInfo(hFb)->u32ViewIndex;4310 CR_FB DISPLAY_INFO *pInfo = &g_CrPresenter.aDisplayInfos[idScreen];4643 uint32_t idFb = CrFbGetScreenInfo(hFb)->u32ViewIndex; 4644 CR_FB_INFO *pFbInfo = &g_CrPresenter.aFbInfos[idFb]; 4311 4645 int rc = CrFbUpdateBegin(hFb); 4312 4646 if (RT_SUCCESS(rc)) 4313 4647 { 4314 pInfo->pDpWinRootVr->RegionsChanged(hFb); 4648 for (int i = ASMBitFirstSet(pFbInfo->aTargetMap, cr_server.screenCount); 4649 i >= 0; 4650 i = ASMBitNextSet(pFbInfo->aTargetMap, cr_server.screenCount, i)) 4651 { 4652 CR_FBDISPLAY_INFO *pDpInfo = &g_CrPresenter.aDisplayInfos[i]; 4653 Assert(pDpInfo->iFb == (int32_t)idFb); 4654 4655 pDpInfo->pDpWinRootVr->RegionsChanged(hFb); 4656 } 4657 4315 4658 CrFbUpdateEnd(hFb); 4316 4659 } … … 4364 4707 } 4365 4708 4366 /*client should notify the manager about the framebuffer resize via this function */ 4367 int CrPMgrNotifyResize(HCR_FRAMEBUFFER hFb) 4709 int CrPMgrResize(const struct VBVAINFOSCREEN *pScreen, void *pvVRAM, const uint32_t *pTargetMap) 4368 4710 { 4369 4711 int rc = VINF_SUCCESS; 4370 if (CrFbIsEnabled(hFb)) 4371 { 4372 rc = CrPMgrModeModify(hFb, g_CrPresenter.u32DisplayMode, 0); 4373 if (!RT_SUCCESS(rc)) 4374 { 4375 WARN(("CrPMgrModeModify failed rc %d", rc)); 4376 return rc; 4377 } 4378 } 4379 else 4380 { 4381 rc = CrPMgrModeModify(hFb, 0, CR_PMGR_MODE_ALL); 4382 if (!RT_SUCCESS(rc)) 4383 { 4384 WARN(("CrPMgrModeModify failed rc %d", rc)); 4712 4713 if (pScreen->u32ViewIndex == 0xffffffff) 4714 { 4715 /* this is just a request to disable targets, search and disable */ 4716 for (int i = ASMBitFirstSet(pTargetMap, cr_server.screenCount); 4717 i >= 0; 4718 i = ASMBitNextSet(pTargetMap, cr_server.screenCount, i)) 4719 { 4720 CR_FBDISPLAY_INFO *pDpInfo = &g_CrPresenter.aDisplayInfos[i]; 4721 if (pDpInfo->iFb < 0) 4722 continue; 4723 4724 Assert(pDpInfo->iFb < cr_server.screenCount); 4725 HCR_FRAMEBUFFER hAssignedFb = CrPMgrFbGet(pDpInfo->iFb); 4726 4727 rc = crPMgrFbDisconnectTarget(hAssignedFb, (uint32_t)i); 4728 if (RT_FAILURE(rc)) 4729 { 4730 WARN(("crPMgrFbDisconnectTarget failed %d", rc)); 4731 return rc; 4732 } 4733 } 4734 4735 return VINF_SUCCESS; 4736 } 4737 4738 HCR_FRAMEBUFFER hFb = CrPMgrFbGet(pScreen->u32ViewIndex); 4739 if (!hFb) 4740 { 4741 WARN(("CrPMgrFbGet failed")); 4742 return VERR_INVALID_PARAMETER; 4743 } 4744 4745 const VBVAINFOSCREEN *pFbScreen = CrFbGetScreenInfo(hFb); 4746 bool fFbInfoChanged = true; 4747 4748 if (!memcmp(pFbScreen, pScreen, sizeof (*pScreen))) 4749 { 4750 if (!pvVRAM || pvVRAM == CrFbGetVRAM(hFb)) 4751 fFbInfoChanged = false; 4752 } 4753 4754 CR_FB_INFO *pFbInfo = &g_CrPresenter.aFbInfos[pScreen->u32ViewIndex]; 4755 4756 VBOXCMDVBVA_SCREENMAP_DECL(uint32_t, aRemovedTargetMap); 4757 bool fDisplaysAdded = false, fDisplaysRemoved = false; 4758 4759 memcpy(aRemovedTargetMap, pFbInfo->aTargetMap, sizeof (aRemovedTargetMap)); 4760 for (int i = 0; i < RT_ELEMENTS(aRemovedTargetMap); ++i) 4761 { 4762 aRemovedTargetMap[i] = (aRemovedTargetMap[i] & ~pTargetMap[i]); 4763 if (aRemovedTargetMap[i]) 4764 fDisplaysRemoved = true; 4765 } 4766 4767 VBOXCMDVBVA_SCREENMAP_DECL(uint32_t, aAddedTargetMap); 4768 4769 memcpy(aAddedTargetMap, pFbInfo->aTargetMap, sizeof (aAddedTargetMap)); 4770 for (int i = 0; i < RT_ELEMENTS(aAddedTargetMap); ++i) 4771 { 4772 aAddedTargetMap[i] = (pTargetMap[i] & ~aAddedTargetMap[i]); 4773 if (aAddedTargetMap[i]) 4774 fDisplaysAdded = true; 4775 } 4776 4777 if (!fFbInfoChanged && !fDisplaysRemoved && !fDisplaysAdded) 4778 { 4779 crDebug("resize: no changes"); 4780 return VINF_SUCCESS; 4781 } 4782 4783 if (fDisplaysRemoved) 4784 { 4785 rc = crPMgrFbDisconnect(hFb, aRemovedTargetMap); 4786 if (RT_FAILURE(rc)) 4787 { 4788 WARN(("crPMgrFbDisconnect failed %d", rc)); 4789 return rc; 4790 } 4791 } 4792 4793 if (fFbInfoChanged) 4794 { 4795 rc = CrFbUpdateBegin(hFb); 4796 if (!RT_SUCCESS(rc)) 4797 { 4798 WARN(("CrFbUpdateBegin failed %d", rc)); 4799 return rc; 4800 } 4801 4802 crVBoxServerMuralFbResizeBegin(hFb); 4803 4804 rc = CrFbResize(hFb, pScreen, pvVRAM); 4805 if (!RT_SUCCESS(rc)) 4806 { 4807 WARN(("CrFbResize failed %d", rc)); 4808 } 4809 4810 crVBoxServerMuralFbResizeEnd(hFb); 4811 4812 CrFbUpdateEnd(hFb); 4813 } 4814 4815 if (fDisplaysAdded) 4816 { 4817 rc = crPMgrFbConnect(hFb, aAddedTargetMap); 4818 if (RT_FAILURE(rc)) 4819 { 4820 WARN(("crPMgrFbConnect failed %d", rc)); 4385 4821 return rc; 4386 4822 } … … 4517 4953 AssertRCReturn(rc, rc); 4518 4954 4519 rc = SSMR3PutU32(pSSM, (uint32_t)(((uintptr_t)CrFbGetVRAM(hFb)) - ((uintptr_t)g_pvVRamBase)));4955 rc = SSMR3PutU32(pSSM, 0xffffffff); 4520 4956 AssertRCReturn(rc, rc); 4521 4957 4522 4958 rc = CrFbSaveState(hFb, pSSM); 4959 AssertRCReturn(rc, rc); 4960 4961 CR_FB_INFO *pFbInfo = &g_CrPresenter.aFbInfos[hFb->ScreenInfo.u32ViewIndex]; 4962 rc = SSMR3PutMem(pSSM, pFbInfo->aTargetMap, sizeof (pFbInfo->aTargetMap)); 4523 4963 AssertRCReturn(rc, rc); 4524 4964 } … … 4663 5103 4664 5104 VBVAINFOSCREEN Screen; 4665 void *pvVRAM;4666 5105 4667 5106 Screen.u32ViewIndex = iScreen; 5107 5108 VBOXCMDVBVA_SCREENMAP_DECL(uint32_t, aTargetMap); 5109 5110 memset(aTargetMap, 0, sizeof (aTargetMap)); 5111 ASMBitSet(aTargetMap, iScreen); 4668 5112 4669 5113 if (version < SHCROGL_SSM_VERSION_WITH_FB_INFO) … … 4675 5119 Screen.u16BitsPerPixel = 4; 4676 5120 Screen.u16Flags = VBVA_SCREEN_F_ACTIVE; 4677 4678 pvVRAM = g_pvVRamBase;4679 5121 } 4680 5122 else … … 4707 5149 rc = SSMR3GetU32(pSSM, &offVram); 4708 5150 AssertRCReturn(rc, rc); 4709 4710 pvVRAM = (void*)(((uintptr_t)g_pvVRamBase) + offVram);4711 }4712 4713 crVBoxServerMuralFbResizeBegin(pFb);4714 4715 rc = CrFbResize(pFb, &Screen, pvVRAM);4716 if (!RT_SUCCESS(rc))4717 {4718 WARN(("CrFbResize failed %d", rc));4719 return rc;4720 } 4721 4722 rc = Cr FbLoadState(pFb, pSSM, version);5151 if (offVram != 0xffffffff) 5152 { 5153 WARN(("not expected offVram")); 5154 Screen.u32StartOffset = offVram; 5155 } 5156 5157 if (version >= SHCROGL_SSM_VERSION_WITH_SCREEN_MAP) 5158 { 5159 rc = SSMR3GetMem(pSSM, aTargetMap, sizeof (aTargetMap)); 5160 AssertRCReturn(rc, rc); 5161 } 5162 } 5163 5164 rc = CrPMgrResize(&Screen, cr_server.fCrCmdEnabled ? NULL : CrFbGetVRAM(pFb), aTargetMap); 4723 5165 AssertRCReturn(rc, rc); 4724 4725 crVBoxServerMuralFbResizeEnd(pFb);4726 4727 CrFbUpdateEnd(pFb);4728 4729 CrPMgrNotifyResize(pFb);4730 5166 } 4731 5167 … … 4747 5183 if (!hFb) 4748 5184 { 4749 LOG(("request to present on disabled framebuffer, ignore"));5185 WARN(("request to present on disabled framebuffer, ignore")); 4750 5186 return; 4751 5187 } … … 4948 5384 if (!hFb) 4949 5385 { 4950 LOG(("request to present on disabled framebuffer, ignore"));5386 WARN(("request to present on disabled framebuffer, ignore")); 4951 5387 return 0; 4952 5388 } … … 5328 5764 } 5329 5765 5330 static int8_t crVBoxServerCrCmdBltPrimaryGenericBGRAProcess(const VBOXCMDVBVA_BLT_PRIMARY_GENERIC_A8R8G8B8 *pCmd, uint32_t cbCmd)5331 {5332 uint32_t u32PrimaryID = pCmd->Hdr.Hdr.u.u8PrimaryID;5333 HCR_FRAMEBUFFER hFb = CrPMgrFbGetEnabled(u32PrimaryID);5334 if (!hFb)5335 {5336 WARN(("request to present on disabled framebuffer, ignore"));5337 return 0;5338 }5339 5340 uint32_t cRects;5341 const VBOXCMDVBVA_RECT *pPRects = pCmd->aRects;5342 if ((cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_PRIMARY_GENERIC_A8R8G8B8, aRects)) % sizeof (VBOXCMDVBVA_RECT))5343 {5344 WARN(("invalid argument size"));5345 return -1;5346 }5347 5348 cRects = (cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_PRIMARY_GENERIC_A8R8G8B8, aRects)) / sizeof (VBOXCMDVBVA_RECT);5349 5350 RTRECT *pRects = crVBoxServerCrCmdBltRecsUnpack(pPRects, cRects);5351 if (!pRects)5352 {5353 WARN(("crVBoxServerCrCmdBltRecsUnpack failed"));5354 return -1;5355 }5356 5357 uint8_t u8Flags = pCmd->Hdr.Hdr.u8Flags;5358 5359 if (u8Flags & VBOXCMDVBVA_OPF_OPERAND2_ISID)5360 {5361 WARN(("blit tex-primary generic is somewhat unexpected"));5362 5363 uint32_t texId = pCmd->alloc.Info.u.id;5364 if (!texId)5365 {5366 WARN(("texId is NULL!\n"));5367 return -1;5368 }5369 5370 if (u8Flags & VBOXCMDVBVA_OPF_BLT_DIR_IN_2)5371 {5372 WARN(("blit from primary to texture not implemented"));5373 return -1;5374 }5375 5376 crServerDispatchVBoxTexPresent(texId, u32PrimaryID, pCmd->Hdr.Pos.x, pCmd->Hdr.Pos.y, cRects, (const GLint*)pRects);5377 5378 return 0;5379 }5380 else5381 {5382 bool fToPrymary = !(u8Flags & VBOXCMDVBVA_OPF_BLT_DIR_IN_2);5383 uint32_t width, height;5384 if (fToPrymary)5385 {5386 width = pCmd->alloc.u16Width;5387 height = pCmd->alloc.u16Height;5388 }5389 else5390 {5391 const VBVAINFOSCREEN *pScreen = CrFbGetScreenInfo(hFb);5392 width = pScreen->u32Width;5393 height = pScreen->u32Height;5394 }5395 5396 VBOXCMDVBVAOFFSET offVRAM = pCmd->alloc.Info.u.offVRAM;5397 RTPOINT Pos = {pCmd->Hdr.Pos.x, pCmd->Hdr.Pos.y};5398 int8_t i8Result = crVBoxServerCrCmdBltPrimaryVramGenericProcess(u32PrimaryID, offVRAM, width, height, &Pos, cRects, pRects, fToPrymary);5399 if (i8Result < 0)5400 {5401 WARN(("crVBoxServerCrCmdBltPrimaryVramGenericProcess failed"));5402 return i8Result;5403 }5404 5405 if (!fToPrymary)5406 return 0;5407 }5408 5409 crVBoxServerCrCmdBltPrimaryUpdate(CrFbGetScreenInfo(hFb), cRects, pRects);5410 5411 return 0;5412 }5413 5414 5766 static int8_t crVBoxServerCrCmdBltGenericBGRAProcess(const VBOXCMDVBVA_BLT_GENERIC_A8R8G8B8 *pCmd, uint32_t cbCmd) 5415 5767 { … … 5473 5825 } 5474 5826 5475 static int8_t crVBoxServerCrCmdBltPrimaryPrimaryProcess(const VBOXCMDVBVA_BLT_PRIMARY *pCmd, uint32_t cbCmd)5476 {5477 uint8_t u8PrimaryID = pCmd->Hdr.Hdr.u.u8PrimaryID;5478 HCR_FRAMEBUFFER hFb = CrPMgrFbGetEnabled(u8PrimaryID);5479 if (!hFb)5480 {5481 WARN(("request to present on disabled framebuffer, ignore"));5482 return -1;5483 }5484 5485 uint32_t cRects;5486 const VBOXCMDVBVA_RECT *pPRects = pCmd->aRects;5487 if ((cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_PRIMARY, aRects)) % sizeof (VBOXCMDVBVA_RECT))5488 {5489 WARN(("invalid argument size"));5490 return -1;5491 }5492 5493 cRects = (cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_PRIMARY, aRects)) / sizeof (VBOXCMDVBVA_RECT);5494 5495 RTRECT *pRects = crVBoxServerCrCmdBltRecsUnpack(pPRects, cRects);5496 if (!pRects)5497 {5498 WARN(("crVBoxServerCrCmdBltRecsUnpack failed"));5499 return -1;5500 }5501 5502 uint8_t u8Flags = pCmd->Hdr.Hdr.u8Flags;5503 5504 WARN(("crVBoxServerCrCmdBltPrimaryPrimaryProcess: not supported"));5505 return -1;5506 }5507 5508 5827 static int8_t crVBoxServerCrCmdClrFillPrimaryGenericProcess(uint32_t u32PrimaryID, const RTRECT *pRects, uint32_t cRects, uint32_t u32Color) 5509 5828 { … … 5511 5830 if (!hFb) 5512 5831 { 5513 LOG(("request to present on disabled framebuffer, ignore"));5832 WARN(("request to present on disabled framebuffer, ignore")); 5514 5833 return 0; 5515 5834 } … … 5536 5855 5537 5856 CrMClrFillImg(&Img, cRects, pRects, u32Color); 5538 5539 return 0;5540 }5541 5542 static int8_t crVBoxServerCrCmdClrFillPrimaryProcess(const VBOXCMDVBVA_CLRFILL_PRIMARY *pCmd, uint32_t cbCmd)5543 {5544 uint32_t u32PrimaryID = (uint32_t)pCmd->Hdr.Hdr.u.u8PrimaryID;5545 HCR_FRAMEBUFFER hFb = CrPMgrFbGetEnabled(u32PrimaryID);5546 if (!hFb)5547 {5548 LOG(("request to present on disabled framebuffer, ignore"));5549 return 0;5550 }5551 5552 uint32_t cRects;5553 const VBOXCMDVBVA_RECT *pPRects = pCmd->aRects;5554 if ((cbCmd - RT_OFFSETOF(VBOXCMDVBVA_CLRFILL_PRIMARY, aRects)) % sizeof (VBOXCMDVBVA_RECT))5555 {5556 WARN(("invalid argument size"));5557 return -1;5558 }5559 5560 cRects = (cbCmd - RT_OFFSETOF(VBOXCMDVBVA_CLRFILL_PRIMARY, aRects)) / sizeof (VBOXCMDVBVA_RECT);5561 5562 RTRECT *pRects = crVBoxServerCrCmdBltRecsUnpack(pPRects, cRects);5563 if (!pRects)5564 {5565 WARN(("crVBoxServerCrCmdBltRecsUnpack failed"));5566 return -1;5567 }5568 5569 // uint8_t u8Flags = pCmd->Hdr.Hdr.u8Flags;5570 int8_t i8Result = crVBoxServerCrCmdClrFillPrimaryGenericProcess(u32PrimaryID, pRects, cRects, pCmd->Hdr.u32Color);5571 if (i8Result < 0)5572 {5573 WARN(("crVBoxServerCrCmdClrFillPrimaryGenericProcess failed"));5574 return i8Result;5575 }5576 5577 crVBoxServerCrCmdBltPrimaryUpdate(CrFbGetScreenInfo(hFb), cRects, pRects);5578 5857 5579 5858 return 0; … … 5699 5978 if (!hFb) 5700 5979 { 5701 LOG(("request to present on disabled framebuffer, ignore"));5980 WARN(("request to present on disabled framebuffer, ignore")); 5702 5981 return 0; 5703 5982 }
Note:
See TracChangeset
for help on using the changeset viewer.