Changeset 48084 in vbox for trunk/src/VBox
- Timestamp:
- Aug 27, 2013 2:43:29 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
r48079 r48084 177 177 178 178 179 static NSOpenGLContext * vboxCtxGetCurrent() 180 { 181 GET_CONTEXT(pCtxInfo); 182 if (pCtxInfo) 183 { 184 #ifdef DEBUG 185 NSOpenGLContext *pDbgCur = [NSOpenGLContext currentContext]; 186 Assert(pCtxInfo->context == pDbgCur); 187 if (pDbgCur) 188 { 189 NSView *pDbgView = [pDbgCur view]; 190 Assert(pCtxInfo->currentWindow->window == pDbgView); 191 } 192 #endif 193 return pCtxInfo->context; 194 } 195 196 #ifdef DEBUG 197 { 198 NSOpenGLContext *pDbgCur = [NSOpenGLContext currentContext]; 199 Assert(!pDbgCur); 200 } 201 #endif 202 return nil; 179 static bool vboxCtxSyncCurrentInfo() 180 { 181 GET_CONTEXT(pCtxInfo); 182 NSOpenGLContext *pCtx = [NSOpenGLContext currentContext]; 183 NSView *pView = pCtx ? [pCtx view] : nil; 184 bool fAdjusted = false; 185 if (pCtxInfo) 186 { 187 WindowInfo *pWinInfo = pCtxInfo->currentWindow; 188 Assert(pWinInfo); 189 if (pCtxInfo->context != pCtx 190 || pWinInfo->window != pView) 191 { 192 renderspu_SystemMakeCurrent(pWinInfo, 0, pCtxInfo); 193 fAdjusted = true; 194 } 195 } 196 else 197 { 198 if (pCtx) 199 { 200 [NSOpenGLContext clearCurrentContext]; 201 fAdjusted = true; 202 } 203 } 204 205 return fAdjusted; 203 206 } 204 207 … … 212 215 static void vboxCtxEnter(NSOpenGLContext*pCtx, PVBOX_CR_RENDER_CTX_INFO pCtxInfo) 213 216 { 214 NSOpenGLContext *pOldCtx = vboxCtxGetCurrent();217 NSOpenGLContext *pOldCtx = [NSOpenGLContext currentContext]; 215 218 NSView *pOldView = (pOldCtx ? [pOldCtx view] : nil); 216 219 NSView *pView = [pCtx view]; … … 883 886 /* have to rebind GL_TEXTURE_RECTANGLE_ARB as m_FBOTexId could be changed in updateFBO call */ 884 887 m_fNeedViewportUpdate = true; 885 pCurCtx = vboxCtxGetCurrent();888 pCurCtx = [NSOpenGLContext currentContext]; 886 889 if (pCurCtx && pCurCtx == m_pGLCtx && (pCurView = [pCurCtx view]) == self) 887 890 { … … 994 997 995 998 vboxCtxLeave(&CtxInfo); 999 1000 vboxCtxSyncCurrentInfo(); 996 1001 } 997 1002 } … … 1162 1167 [self unlockFocus]; 1163 1168 } 1169 else 1170 { 1171 [self setNeedsDisplay:YES]; 1172 } 1164 1173 } 1165 1174 … … 1170 1179 if (m_pSharedGLCtx) 1171 1180 { 1181 #if 0 1182 /* tmp workaround to prevent potential deadlock: 1183 * crOpenGL service thread does compositor lock acquire and calls cocoa NS methods that could synchronize on the GUI thread 1184 * while here we do a reverse order: acquire compositor lock being in gui thread. 1185 * this is why we do only try acquire and re-submit repaint event if compositor lock is busy */ 1186 VBOXVR_SCR_COMPOSITOR *pCompositor = NULL; 1187 int rc = renderspuVBoxCompositorTryAcquire(m_pWinInfo, &pCompositor); 1188 if (RT_SUCCESS(rc)) 1189 { 1190 Assert(pCompositor); 1191 [self vboxPresent:pCompositor]; 1192 renderspuVBoxCompositorRelease(m_pWinInfo); 1193 } 1194 else if (rc == VERR_SEM_BUSY) 1195 { 1196 /* re-issue to the gui thread */ 1197 [self setNeedsDisplay:YES]; 1198 } 1199 else 1200 { 1201 /* this is somewhat we do not expect */ 1202 DEBUG_MSG(("renderspuVBoxCompositorTryAcquire failed rc %d", rc)); 1203 } 1204 #else 1172 1205 VBOXVR_SCR_COMPOSITOR *pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo); 1173 1206 if (pCompositor) … … 1176 1209 renderspuVBoxCompositorRelease(m_pWinInfo); 1177 1210 } 1211 #endif 1178 1212 } 1179 1213 [self unlockFocus]; 1214 } 1215 else 1216 { 1217 [self setNeedsDisplay:YES]; 1180 1218 } 1181 1219 } … … 1208 1246 1209 1247 vboxCtxLeave(&CtxInfo); 1248 1249 vboxCtxSyncCurrentInfo(); 1210 1250 } 1211 1251 … … 1781 1821 { 1782 1822 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1783 1784 /* view should not necesserily have a context set 1785 * @todo: check and set default shared one */ 1786 1823 NSOpenGLContext *pCtx; 1824 1825 /* view should not necesserily have a context set */ 1826 pCtx = [(OverlayView*)pView glCtx]; 1827 if (!pCtx) 1828 { 1829 ContextInfo * pCtxInfo = renderspuDefaultSharedContextAcquire(); 1830 if (!pCtxInfo) 1831 { 1832 DEBUG_WARN(("renderspuDefaultSharedContextAcquire returned NULL")); 1833 1834 [pPool release]; 1835 return; 1836 } 1837 1838 pCtx = pCtxInfo->context; 1839 1840 [(OverlayView*)pView setGLCtx:pCtx]; 1841 } 1842 1787 1843 [(OverlayView*)pView presentComposition:pChangedEntry]; 1788 1844
Note:
See TracChangeset
for help on using the changeset viewer.