Changeset 19817 in vbox for trunk/src/VBox/Main/DisplayImpl.cpp
- Timestamp:
- May 19, 2009 12:16:28 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/DisplayImpl.cpp
r19798 r19817 23 23 24 24 #include "DisplayImpl.h" 25 #include "FramebufferImpl.h"26 25 #include "ConsoleImpl.h" 27 26 #include "ConsoleVRDPServer.h" … … 86 85 mpVMMDev = NULL; 87 86 mfVMMDevInited = false; 88 RTSemEventMultiCreate(&mUpdateSem);89 87 90 88 mLastAddress = NULL; … … 124 122 unconst (mParent) = aParent; 125 123 126 /* reset the event sems */127 RTSemEventMultiReset (mUpdateSem);128 129 124 // by default, we have an internal framebuffer which is 130 125 // NULL, i.e. a black hole for no display output 131 mInternalFramebuffer = true;132 126 mFramebufferOpened = false; 133 mSupportedAccelOps = 0;134 127 135 128 ULONG ul; … … 185 178 for (ul = 0; ul < mcMonitors; ul++) 186 179 maFramebuffers[ul].pFramebuffer = NULL; 187 188 RTSemEventMultiDestroy (mUpdateSem);189 180 190 181 if (mParent) … … 507 498 pFramebuffer->Lock(); 508 499 509 /* special processing for the internal framebuffer */ 510 if (mInternalFramebuffer) 511 { 512 pFramebuffer->Unlock(); 513 } else 514 { 515 /* callback into the framebuffer to notify it */ 516 BOOL finished = FALSE; 517 518 RTSemEventMultiReset(mUpdateSem); 519 520 checkCoordBounds (&x, &y, &w, &h, mpDrv->Connector.cx, mpDrv->Connector.cy); 521 522 if (w == 0 || h == 0) 523 { 524 /* Nothing to be updated. */ 525 finished = TRUE; 526 } 527 else 528 { 529 pFramebuffer->NotifyUpdate(x, y, w, h, &finished); 530 } 531 532 if (!finished) 533 { 534 /* 535 * the framebuffer needs more time to process 536 * the event so we have to halt the VM until it's done 537 */ 538 pFramebuffer->Unlock(); 539 RTSemEventMultiWait(mUpdateSem, RT_INDEFINITE_WAIT); 540 } else 541 { 542 pFramebuffer->Unlock(); 543 } 544 545 if (!mfVideoAccelEnabled) 546 { 547 /* When VBVA is enabled, the VRDP server is informed in the VideoAccelFlush. 548 * Inform the server here only if VBVA is disabled. 549 */ 550 if (maFramebuffers[uScreenId].u32ResizeStatus == ResizeStatus_Void) 551 { 552 mParent->consoleVRDPServer()->SendUpdateBitmap(uScreenId, x, y, w, h); 553 } 554 } 555 } 556 return; 500 checkCoordBounds (&x, &y, &w, &h, mpDrv->Connector.cx, mpDrv->Connector.cy); 501 502 if (w != 0 && h != 0) 503 pFramebuffer->NotifyUpdate(x, y, w, h); 504 505 pFramebuffer->Unlock(); 506 507 if (!mfVideoAccelEnabled) 508 { 509 /* When VBVA is enabled, the VRDP server is informed in the VideoAccelFlush. 510 * Inform the server here only if VBVA is disabled. 511 */ 512 if (maFramebuffers[uScreenId].u32ResizeStatus == ResizeStatus_Void) 513 mParent->consoleVRDPServer()->SendUpdateBitmap(uScreenId, x, y, w, h); 514 } 557 515 } 558 516 … … 1344 1302 ///////////////////////////////////////////////////////////////////////////// 1345 1303 1346 STDMETHODIMP Display::SetupInternalFramebuffer (ULONG depth) 1304 STDMETHODIMP Display::SetFramebuffer (ULONG aScreenId, 1305 IFramebuffer *aFramebuffer) 1347 1306 { 1348 1307 LogFlowFunc (("\n")); 1308 1309 if (aFramebuffer != NULL) 1310 CheckComArgOutPointerValid(aFramebuffer); 1349 1311 1350 1312 AutoCaller autoCaller (this); … … 1353 1315 AutoWriteLock alock (this); 1354 1316 1355 /*1356 * Create an internal framebuffer only if depth is not zero. Otherwise, we1357 * reset back to the "black hole" state as it was at Display construction.1358 */1359 ComPtr <IFramebuffer> frameBuf;1360 if (depth)1361 {1362 ComObjPtr <InternalFramebuffer> internal;1363 internal.createObject();1364 internal->init (640, 480, depth);1365 frameBuf = internal; // query interface1366 }1367 1368 1317 Console::SafeVMPtrQuiet pVM (mParent); 1369 1318 if (pVM.isOk()) 1370 1319 { 1371 /* Must leave the lock here because the changeFramebuffer will also obtain it. */ 1320 /* Must leave the lock here because the changeFramebuffer will 1321 * also obtain it. */ 1372 1322 alock.leave (); 1373 1323 … … 1375 1325 PVMREQ pReq = NULL; 1376 1326 int vrc = VMR3ReqCall (pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, 1377 (PFNRT) changeFramebuffer, 4, 1378 this, static_cast <IFramebuffer *> (frameBuf), 1379 true /* aInternal */, VBOX_VIDEO_PRIMARY_SCREEN); 1327 (PFNRT) changeFramebuffer, 3, this, aFramebuffer, aScreenId); 1380 1328 if (RT_SUCCESS (vrc)) 1381 1329 vrc = pReq->iStatus; … … 1389 1337 { 1390 1338 /* No VM is created (VM is powered off), do a direct call */ 1391 int vrc = changeFramebuffer (this, frameBuf, true /* aInternal */, VBOX_VIDEO_PRIMARY_SCREEN); 1392 ComAssertRCRet (vrc, E_FAIL); 1393 } 1394 1395 return S_OK; 1396 } 1397 1398 STDMETHODIMP Display::LockFramebuffer (BYTE **address) 1399 { 1400 CheckComArgOutPointerValid(address); 1401 1402 AutoCaller autoCaller (this); 1403 CheckComRCReturnRC (autoCaller.rc()); 1404 1405 AutoWriteLock alock (this); 1406 1407 /* only allowed for internal framebuffers */ 1408 if (mInternalFramebuffer && !mFramebufferOpened 1409 && !maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer.isNull()) 1410 { 1411 CHECK_CONSOLE_DRV (mpDrv); 1412 1413 maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer->Lock(); 1414 mFramebufferOpened = true; 1415 *address = mpDrv->Connector.pu8Data; 1416 return S_OK; 1417 } 1418 1419 return setError (VBOX_E_NOT_SUPPORTED, 1420 tr ("Framebuffer locking is allowed only for the internal framebuffer")); 1421 } 1422 1423 STDMETHODIMP Display::UnlockFramebuffer() 1424 { 1425 AutoCaller autoCaller (this); 1426 CheckComRCReturnRC (autoCaller.rc()); 1427 1428 AutoWriteLock alock (this); 1429 1430 if (mFramebufferOpened) 1431 { 1432 CHECK_CONSOLE_DRV (mpDrv); 1433 1434 maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer->Unlock(); 1435 mFramebufferOpened = false; 1436 return S_OK; 1437 } 1438 1439 return setError (VBOX_E_NOT_SUPPORTED, 1440 tr ("Framebuffer locking is allowed only for the internal framebuffer")); 1441 } 1442 1443 STDMETHODIMP Display::RegisterExternalFramebuffer (IFramebuffer *frameBuf) 1444 { 1445 LogFlowFunc (("\n")); 1446 1447 CheckComArgNotNull(frameBuf); 1448 1449 AutoCaller autoCaller (this); 1450 CheckComRCReturnRC (autoCaller.rc()); 1451 1452 AutoWriteLock alock (this); 1453 1454 Console::SafeVMPtrQuiet pVM (mParent); 1455 if (pVM.isOk()) 1456 { 1457 /* Must leave the lock here because the changeFramebuffer will 1458 * also obtain it. */ 1459 alock.leave (); 1460 1461 /* send request to the EMT thread */ 1462 PVMREQ pReq = NULL; 1463 int vrc = VMR3ReqCall (pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, 1464 (PFNRT) changeFramebuffer, 4, this, frameBuf, false /* aInternal */, 1465 VBOX_VIDEO_PRIMARY_SCREEN); 1466 if (RT_SUCCESS (vrc)) 1467 vrc = pReq->iStatus; 1468 VMR3ReqFree (pReq); 1469 1470 alock.enter (); 1471 1472 ComAssertRCRet (vrc, E_FAIL); 1473 } 1474 else 1475 { 1476 /* No VM is created (VM is powered off), do a direct call */ 1477 int vrc = changeFramebuffer (this, frameBuf, false /* aInternal */, 1478 VBOX_VIDEO_PRIMARY_SCREEN); 1479 ComAssertRCRet (vrc, E_FAIL); 1480 } 1481 1482 return S_OK; 1483 } 1484 1485 STDMETHODIMP Display::SetFramebuffer (ULONG aScreenId, 1486 IFramebuffer *aFramebuffer) 1487 { 1488 LogFlowFunc (("\n")); 1489 1490 CheckComArgOutPointerValid(aFramebuffer); 1491 1492 AutoCaller autoCaller (this); 1493 CheckComRCReturnRC (autoCaller.rc()); 1494 1495 AutoWriteLock alock (this); 1496 1497 Console::SafeVMPtrQuiet pVM (mParent); 1498 if (pVM.isOk()) 1499 { 1500 /* Must leave the lock here because the changeFramebuffer will 1501 * also obtain it. */ 1502 alock.leave (); 1503 1504 /* send request to the EMT thread */ 1505 PVMREQ pReq = NULL; 1506 int vrc = VMR3ReqCall (pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, 1507 (PFNRT) changeFramebuffer, 4, this, aFramebuffer, false /* aInternal */, 1508 aScreenId); 1509 if (RT_SUCCESS (vrc)) 1510 vrc = pReq->iStatus; 1511 VMR3ReqFree (pReq); 1512 1513 alock.enter (); 1514 1515 ComAssertRCRet (vrc, E_FAIL); 1516 } 1517 else 1518 { 1519 /* No VM is created (VM is powered off), do a direct call */ 1520 int vrc = changeFramebuffer (this, aFramebuffer, false /* aInternal */, 1521 aScreenId); 1339 int vrc = changeFramebuffer (this, aFramebuffer, aScreenId); 1522 1340 ComAssertRCRet (vrc, E_FAIL); 1523 1341 } … … 1823 1641 1824 1642 /* this is only valid for external framebuffers */ 1825 if (m InternalFramebuffer)1643 if (maFramebuffers[aScreenId].pFramebuffer == NULL) 1826 1644 return setError (VBOX_E_NOT_SUPPORTED, 1827 1645 tr ("Resize completed notification is valid only " … … 1859 1677 1860 1678 /* this is only valid for external framebuffers */ 1861 if (m InternalFramebuffer)1679 if (maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer == NULL) 1862 1680 return setError (VBOX_E_NOT_SUPPORTED, 1863 1681 tr ("Resize completed notification is valid only " 1864 1682 "for external framebuffers")); 1865 1866 maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer->Lock();1867 /* signal our semaphore */1868 RTSemEventMultiSignal(mUpdateSem);1869 maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer->Unlock();1870 1683 1871 1684 return S_OK; … … 1972 1785 /* static */ 1973 1786 DECLCALLBACK(int) Display::changeFramebuffer (Display *that, IFramebuffer *aFB, 1974 bool aInternal,unsigned uScreenId)1787 unsigned uScreenId) 1975 1788 { 1976 1789 LogFlowFunc (("uScreenId = %d\n", uScreenId)); 1977 1790 1978 1791 AssertReturn (that, VERR_INVALID_PARAMETER); 1979 AssertReturn (aFB || aInternal, VERR_INVALID_PARAMETER);1980 1792 AssertReturn (uScreenId < that->mcMonitors, VERR_INVALID_PARAMETER); 1981 1793 … … 1987 1799 DISPLAYFBINFO *pDisplayFBInfo = &that->maFramebuffers[uScreenId]; 1988 1800 pDisplayFBInfo->pFramebuffer = aFB; 1989 1990 that->mInternalFramebuffer = aInternal;1991 that->mSupportedAccelOps = 0;1992 1801 1993 1802 that->mParent->consoleVRDPServer()->SendResize ();
Note:
See TracChangeset
for help on using the changeset viewer.