Changeset 24924 in vbox for trunk/src/VBox/Main/DisplayImpl.cpp
- Timestamp:
- Nov 24, 2009 8:11:58 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 55209
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/DisplayImpl.cpp
r24890 r24924 106 106 int rc = RTCritSectInit (&mVBVALock); 107 107 AssertRC (rc); 108 mfu32PendingVideoAccelDisable = false; 108 109 #endif /* VBOX_WITH_OLD_VBVA_LOCK */ 109 110 … … 419 420 420 421 /* SSM code is executed on EMT(0), therefore no need to use VMR3ReqCallWait. */ 422 #ifdef VBOX_WITH_OLD_VBVA_LOCK 423 int rc = Display::displayTakeScreenshotEMT(that, &pu8Data, &cbData, &cx, &cy); 424 #else 421 425 int rc = that->mpDrv->pUpPort->pfnTakeScreenshot (that->mpDrv->pUpPort, &pu8Data, &cbData, &cx, &cy); 426 #endif /* !VBOX_WITH_OLD_VBVA_LOCK */ 422 427 423 428 if (RT_SUCCESS(rc)) … … 978 983 * @thread EMT 979 984 */ 985 void Display::handleDisplayUpdate (int x, int y, int w, int h) 986 { 980 987 #ifdef VBOX_WITH_OLD_VBVA_LOCK 981 /* 982 * Always runs under VBVA or DevVGA lock. 983 * Safe to use VBVA vars and take the framebuffer lock. 984 */ 988 /* 989 * Always runs under VBVA or DevVGA lock. 990 * Safe to use VBVA vars and take the framebuffer lock. 991 */ 992 #ifdef DEBUG_sunlover 993 /* This assert is here for testing only. */ 994 Assert(RTCritSectIsOwner(&mVBVALock)); 995 #endif /* DEBUG_sunlover */ 985 996 #endif /* VBOX_WITH_OLD_VBVA_LOCK */ 986 void Display::handleDisplayUpdate (int x, int y, int w, int h) 987 { 997 988 998 #ifdef DEBUG_sunlover 989 999 LogFlowFunc (("%d,%d %dx%d (%d,%d)\n", … … 1181 1191 } 1182 1192 1193 #ifdef VBOX_WITH_OLD_VBVA_LOCK 1194 int Display::vbvaLock(void) 1195 { 1196 return RTCritSectEnter(&mVBVALock); 1197 } 1198 1199 void Display::vbvaUnlock(void) 1200 { 1201 RTCritSectLeave(&mVBVALock); 1202 } 1203 #endif /* VBOX_WITH_OLD_VBVA_LOCK */ 1204 1183 1205 /** 1184 1206 * @thread EMT … … 1188 1210 { 1189 1211 int rc; 1190 RTCritSectEnter(&mVBVALock);1212 vbvaLock(); 1191 1213 rc = videoAccelEnable (fEnable, pVbvaMemory); 1192 RTCritSectLeave(&mVBVALock);1214 vbvaUnlock(); 1193 1215 return rc; 1194 1216 } … … 1317 1339 void Display::VideoAccelVRDP (bool fEnable) 1318 1340 { 1341 #ifdef VBOX_WITH_OLD_VBVA_LOCK 1342 vbvaLock(); 1343 #endif /* VBOX_WITH_OLD_VBVA_LOCK */ 1344 1319 1345 int c = fEnable? 1320 1346 ASMAtomicIncS32 (&mcVideoAccelVRDPRefs): … … 1359 1385 Assert (mfVideoAccelVRDP == true); 1360 1386 } 1387 #ifdef VBOX_WITH_OLD_VBVA_LOCK 1388 vbvaUnlock(); 1389 #endif /* VBOX_WITH_OLD_VBVA_LOCK */ 1361 1390 } 1362 1391 #endif /* VBOX_WITH_VRDP */ … … 1636 1665 void Display::VideoAccelFlush (void) 1637 1666 { 1638 RTCritSectEnter(&mVBVALock);1667 vbvaLock(); 1639 1668 videoAccelFlush(); 1640 RTCritSectLeave(&mVBVALock);1669 vbvaUnlock(); 1641 1670 } 1642 1671 #endif /* VBOX_WITH_OLD_VBVA_LOCK */ … … 1783 1812 } 1784 1813 1814 #ifdef VBOX_WITH_OLD_VBVA_LOCK 1815 int Display::videoAccelRefreshProcess(void) 1816 { 1817 int rc = VWRN_INVALID_STATE; /* Default is to do a display update in VGA device. */ 1818 1819 #ifdef DEBUG_sunlover 1820 LogFlowFunc(("\n")); 1821 #endif 1822 1823 vbvaLock(); 1824 1825 if (ASMAtomicCmpXchgU32(&mfu32PendingVideoAccelDisable, false, true)) 1826 { 1827 videoAccelEnable (false, NULL); 1828 } 1829 else if (mfPendingVideoAccelEnable) 1830 { 1831 /* Acceleration was enabled while machine was not yet running 1832 * due to restoring from saved state. Update entire display and 1833 * actually enable acceleration. 1834 */ 1835 Assert(mpPendingVbvaMemory); 1836 1837 /* Acceleration can not be yet enabled.*/ 1838 Assert(mpVbvaMemory == NULL); 1839 Assert(!mfVideoAccelEnabled); 1840 1841 if (mfMachineRunning) 1842 { 1843 videoAccelEnable (mfPendingVideoAccelEnable, 1844 mpPendingVbvaMemory); 1845 1846 /* Reset the pending state. */ 1847 mfPendingVideoAccelEnable = false; 1848 mpPendingVbvaMemory = NULL; 1849 } 1850 1851 rc = VINF_TRY_AGAIN; 1852 } 1853 else 1854 { 1855 Assert(mpPendingVbvaMemory == NULL); 1856 1857 if (mfVideoAccelEnabled) 1858 { 1859 Assert(mpVbvaMemory); 1860 videoAccelFlush (); 1861 1862 rc = VINF_SUCCESS; /* VBVA processed, no need to a display update. */ 1863 } 1864 } 1865 1866 vbvaUnlock(); 1867 1868 #ifdef DEBUG_sunlover 1869 LogFlowFunc(("rc = %d\n")); 1870 #endif 1871 1872 return rc; 1873 } 1874 #endif /* VBOX_WITH_OLD_VBVA_LOCK */ 1875 1785 1876 1786 1877 // IDisplay properties … … 1992 2083 } 1993 2084 2085 #ifdef VBOX_WITH_OLD_VBVA_LOCK 2086 int Display::displayTakeScreenshotEMT(Display *pDisplay, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height) 2087 { 2088 int rc; 2089 pDisplay->vbvaLock(); 2090 rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort, ppu8Data, pcbData, pu32Width, pu32Height); 2091 pDisplay->vbvaUnlock(); 2092 return rc; 2093 } 2094 #endif /* VBOX_WITH_OLD_VBVA_LOCK */ 2095 2096 #ifdef VBOX_WITH_OLD_VBVA_LOCK 2097 static int displayTakeScreenshot(PVM pVM, Display *pDisplay, struct DRVMAINDISPLAY *pDrv, BYTE *address, ULONG width, ULONG height) 2098 #else 1994 2099 static int displayTakeScreenshot(PVM pVM, struct DRVMAINDISPLAY *pDrv, BYTE *address, ULONG width, ULONG height) 2100 #endif /* !VBOX_WITH_OLD_VBVA_LOCK */ 1995 2101 { 1996 2102 uint8_t *pu8Data = NULL; … … 1999 2105 uint32_t cy = 0; 2000 2106 2107 #ifdef VBOX_WITH_OLD_VBVA_LOCK 2108 int vrc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)Display::displayTakeScreenshotEMT, 5, 2109 pDisplay, &pu8Data, &cbData, &cx, &cy); 2110 #else 2001 2111 /* @todo pfnTakeScreenshot is probably callable from any thread, because it uses the VGA device lock. */ 2002 2112 int vrc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)pDrv->pUpPort->pfnTakeScreenshot, 5, 2003 2113 pDrv->pUpPort, &pu8Data, &cbData, &cx, &cy); 2114 #endif /* !VBOX_WITH_OLD_VBVA_LOCK */ 2004 2115 2005 2116 if (RT_SUCCESS(vrc)) … … 2076 2187 alock.leave(); 2077 2188 2189 #ifdef VBOX_WITH_OLD_VBVA_LOCK 2190 int vrc = displayTakeScreenshot(pVM, this, mpDrv, address, width, height); 2191 #else 2078 2192 int vrc = displayTakeScreenshot(pVM, mpDrv, address, width, height); 2193 #endif /* !VBOX_WITH_OLD_VBVA_LOCK */ 2079 2194 2080 2195 if (vrc == VERR_NOT_IMPLEMENTED) … … 2128 2243 return E_OUTOFMEMORY; 2129 2244 2245 #ifdef VBOX_WITH_OLD_VBVA_LOCK 2246 int vrc = displayTakeScreenshot(pVM, this, mpDrv, pu8Data, width, height); 2247 #else 2130 2248 int vrc = displayTakeScreenshot(pVM, mpDrv, pu8Data, width, height); 2249 #endif /* !VBOX_WITH_OLD_VBVA_LOCK */ 2131 2250 2132 2251 if (RT_SUCCESS(vrc)) … … 2194 2313 * dirty conversion work. 2195 2314 */ 2315 #ifdef VBOX_WITH_OLD_VBVA_LOCK 2316 int rcVBox = 0; 2317 // @todo vbva int rcVBox = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)Display::DrawToScreenEMT, 6, 2318 // this, address, x, y, width, height); 2319 #else 2196 2320 int rcVBox = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)mpDrv->pUpPort->pfnDisplayBlt, 6, 2197 2321 mpDrv->pUpPort, address, x, y, width, height); 2322 #endif /* !VBOX_WITH_OLD_VBVA_LOCK */ 2198 2323 2199 2324 /* … … 2250 2375 2251 2376 /* pdm.h says that this has to be called from the EMT thread */ 2377 #ifdef VBOX_WITH_OLD_VBVA_LOCK 2378 int rcVBox = 0; 2379 // #todo vbva int rcVBox = VMR3ReqCallVoidWait(pVM, VMCPUID_ANY, (PFNRT)Display::InvalidateAndUpdateEMT, 2380 // 1, this); 2381 #else 2252 2382 int rcVBox = VMR3ReqCallVoidWait(pVM, VMCPUID_ANY, 2253 2383 (PFNRT)mpDrv->pUpPort->pfnUpdateDisplayAll, 1, mpDrv->pUpPort); 2384 #endif /* !VBOX_WITH_OLD_VBVA_LOCK */ 2254 2385 alock.enter (); 2255 2386 … … 2547 2678 /* Repaint the display because VM continued to run during the framebuffer resize. */ 2548 2679 if (!pFBInfo->pFramebuffer.isNull()) 2680 #ifdef VBOX_WITH_OLD_VBVA_LOCK 2681 { 2682 pDisplay->vbvaLock(); 2683 #endif /* VBOX_WITH_OLD_VBVA_LOCK */ 2549 2684 pDrv->pUpPort->pfnUpdateDisplayAll(pDrv->pUpPort); 2685 #ifdef VBOX_WITH_OLD_VBVA_LOCK 2686 pDisplay->vbvaUnlock(); 2687 } 2688 #endif /* VBOX_WITH_OLD_VBVA_LOCK */ 2550 2689 } 2551 2690 } … … 2561 2700 if (!fNoUpdate) 2562 2701 { 2702 #ifdef VBOX_WITH_OLD_VBVA_LOCK 2703 int rc = pDisplay->videoAccelRefreshProcess(); 2704 2705 if (rc != VINF_TRY_AGAIN) /* Means 'do nothing' here. */ 2706 { 2707 if (rc == VWRN_INVALID_STATE) 2708 { 2709 /* No VBVA do a display update. */ 2710 DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN]; 2711 if (!pFBInfo->pFramebuffer.isNull()) 2712 { 2713 Assert(pDrv->Connector.pu8Data); 2714 Assert(pFBInfo->u32ResizeStatus == ResizeStatus_Void); 2715 pDrv->pUpPort->pfnUpdateDisplay(pDrv->pUpPort); 2716 } 2717 } 2718 2719 /* Inform the VRDP server that the current display update sequence is 2720 * completed. At this moment the framebuffer memory contains a definite 2721 * image, that is synchronized with the orders already sent to VRDP client. 2722 * The server can now process redraw requests from clients or initial 2723 * fullscreen updates for new clients. 2724 */ 2725 for (uScreenId = 0; uScreenId < pDisplay->mcMonitors; uScreenId++) 2726 { 2727 DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[uScreenId]; 2728 2729 if (!pFBInfo->pFramebuffer.isNull() && pFBInfo->u32ResizeStatus == ResizeStatus_Void) 2730 { 2731 Assert (pDisplay->mParent && pDisplay->mParent->consoleVRDPServer()); 2732 pDisplay->mParent->consoleVRDPServer()->SendUpdate (uScreenId, NULL, 0); 2733 } 2734 } 2735 } 2736 #else 2563 2737 if (pDisplay->mfPendingVideoAccelEnable) 2564 2738 { … … 2620 2794 } 2621 2795 } 2796 #endif /* !VBOX_WITH_OLD_VBVA_LOCK */ 2622 2797 } 2623 2798 … … 2660 2835 /* Disable VBVA mode in any case. The guest driver reenables VBVA mode if necessary. */ 2661 2836 #ifdef VBOX_WITH_OLD_VBVA_LOCK 2662 /* This is called under DevVGA lock. Postpone disabling VBVA . */2663 /* @todo vbva */2837 /* This is called under DevVGA lock. Postpone disabling VBVA, do it in the refresh timer. */ 2838 ASMAtomicWriteU32(&pDrv->pDisplay->mfu32PendingVideoAccelDisable, true); 2664 2839 #else 2665 2840 pDrv->pDisplay->VideoAccelEnable (false, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.