Changeset 54767 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Mar 15, 2015 11:49:44 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
r54638 r54767 213 213 #define VBOX_WITH_CONFIGURABLE_HIDPI_SCALING 1 214 214 215 215 216 #ifdef IN_VMSVGA3D 216 217 … … 218 219 * VMSVGA3D compatibility glue. 219 220 */ 221 typedef struct WindowInfo WindowInfo; 220 222 221 223 # define CR_RGB_BIT RT_BIT_32(0) … … 233 235 # define VMSVGA3D_NON_DEFAULT_PROFILE_BIT RT_BIT_32(31) 234 236 # define CR_ALL_BITS UINT32_C(0x800003ff) 235 236 typedef struct WindowInfo237 {238 uint32_t volatile cRefs;239 RTCRITSECT CompositorLock;240 PCVBOXVR_SCR_COMPOSITOR pCompositor;241 242 //NativeNSViewRef window;243 //NativeNSViewRef nativeWindow; /**< for render_to_app_window */244 NativeNSOpenGLContextRef *currentCtx;245 } WindowInfo;246 247 static void vmsvga3DWinInfoDestroy(WindowInfo *pWinInfo)248 {249 /** @todo */250 }251 252 DECLINLINE(void) renderspuWinRetain(WindowInfo *pWinInfo)253 {254 ASMAtomicIncU32(&pWinInfo->cRefs);255 }256 257 DECLINLINE(void) renderspuWinRelease(WindowInfo *pWinInfo)258 {259 uint32_t cRefs = ASMAtomicDecU32(&pWinInfo->cRefs);260 if (!cRefs)261 vmsvga3DWinInfoDestroy(pWinInfo);262 }263 264 static int renderspuVBoxCompositorLock(WindowInfo *pWinInfo, PCVBOXVR_SCR_COMPOSITOR *ppCompositor)265 {266 int rc = RTCritSectEnter(&pWinInfo->CompositorLock);267 AssertRCReturn(rc, rc);268 if (ppCompositor)269 *ppCompositor = pWinInfo->pCompositor;270 return VINF_SUCCESS;271 }272 273 static int renderspuVBoxCompositorUnlock(WindowInfo *pWinInfo)274 {275 int rc = RTCritSectLeave(&pWinInfo->CompositorLock);276 AssertRC(rc);277 return rc;278 }279 280 static PCVBOXVR_SCR_COMPOSITOR renderspuVBoxCompositorAcquire(WindowInfo *pWinInfo)281 {282 int rc = RTCritSectEnter(&pWinInfo->CompositorLock);283 AssertRCReturn(rc, NULL);284 285 PCVBOXVR_SCR_COMPOSITOR pCompositor = pWinInfo->pCompositor;286 if (pCompositor)287 {288 Assert(!CrVrScrCompositorIsEmpty(pWinInfo->pCompositor));289 return pCompositor;290 }291 292 /* if no compositor is set, release the lock and return */293 RTCritSectLeave(&pWinInfo->CompositorLock);294 return NULL;295 }296 297 static void renderspuVBoxCompositorRelease(WindowInfo *pWinInfo)298 {299 Assert(pWinInfo->pCompositor);300 Assert(!CrVrScrCompositorIsEmpty(pWinInfo->pCompositor));301 int rc = RTCritSectLeave(&pWinInfo->CompositorLock);302 AssertRC(rc);303 }304 305 237 306 238 #endif /* IN_VMSVGA3D */ … … 862 794 863 795 CR_BLITTER *m_pBlitter; 796 #ifndef IN_VMSVGA3D 864 797 WindowInfo *m_pWinInfo; 798 #endif 865 799 bool m_fNeedViewportUpdate; 866 800 bool m_fNeedCtxUpdate; … … 912 846 - (void)vboxPresent:(const VBOXVR_SCR_COMPOSITOR *)pCompositor; 913 847 - (void)vboxPresentCS:(const VBOXVR_SCR_COMPOSITOR *)pCompositor; 848 #ifndef IN_VMSVGA3D 914 849 - (void)vboxPresentToDockTileCS:(const VBOXVR_SCR_COMPOSITOR *)pCompositor; 850 #endif 915 851 - (void)vboxPresentToViewCS:(const VBOXVR_SCR_COMPOSITOR *)pCompositor; 916 852 - (void)presentComposition:(const VBOXVR_SCR_COMPOSITOR_ENTRY *)pChangedEntry; … … 1418 1354 m_yInvRootOffset = 0; 1419 1355 m_pBlitter = nil; 1356 #ifndef IN_VMSVGA3D 1420 1357 m_pWinInfo = pWinInfo; 1358 #endif 1421 1359 m_fNeedViewportUpdate = true; 1422 1360 m_fNeedCtxUpdate = true; … … 1636 1574 } 1637 1575 1576 #ifndef IN_VMSVGA3D 1638 1577 renderspuWinRelease(m_pWinInfo); 1578 #endif 1639 1579 1640 1580 COCOA_LOG_FLOW(("%s: returns\n", __PRETTY_FUNCTION__)); … … 2220 2160 #endif 2221 2161 2222 const VBOXVR_SCR_COMPOSITOR *pCompositor; 2162 const VBOXVR_SCR_COMPOSITOR *pCompositor = NULL; 2163 #ifndef IN_VMSVGA3D 2223 2164 int rc = renderspuVBoxCompositorLock(m_pWinInfo, &pCompositor); 2224 2165 if (RT_FAILURE(rc)) … … 2228 2169 } 2229 2170 2230 #ifndef IN_VMSVGA3D2231 2171 if (!pCompositor && !m_fCleanupNeeded) 2232 2172 { … … 2235 2175 return; 2236 2176 } 2237 #endif2238 2177 2239 2178 VBOXVR_SCR_COMPOSITOR TmpCompositor; 2240 2241 2179 if (pCompositor) 2242 2180 { … … 2267 2205 { 2268 2206 DEBUG_MSG(("%s: NeedCleanup\n", __PRETTY_FUNCTION__)); 2269 #ifndef IN_VMSVGA3D /** @todo VMSVGA3 */2270 2207 Assert(m_fCleanupNeeded); 2271 #endif2272 2208 CrVrScrCompositorInit(&TmpCompositor, NULL); 2273 2209 pCompositor = &TmpCompositor; 2274 2210 } 2211 #endif /* !IN_VMSVGA3D */ 2212 2275 2213 2276 2214 if ([self lockFocusIfCanDraw]) … … 2293 2231 } 2294 2232 2233 #ifndef IN_VMSVGA3D 2295 2234 renderspuVBoxCompositorUnlock(m_pWinInfo); 2235 #endif 2296 2236 COCOA_LOG_FLOW(("%s: returns\n", __PRETTY_FUNCTION__)); 2297 2237 } … … 2308 2248 COCOA_LOG_FLOW(("%s: self=%p pCompositor=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)pCompositor)); 2309 2249 /*DEBUG_MSG(("OVIW(%p): renderFBOToView\n", (void *)self));*/ 2250 #ifndef IN_VMSVGA3D 2310 2251 AssertPtr(pCompositor); 2252 #endif 2311 2253 2312 2254 VBOX_CR_RENDER_CTX_INFO CtxInfo; … … 2338 2280 m_fCleanupNeeded = false; 2339 2281 2282 #ifndef IN_VMSVGA3D 2340 2283 /* Render FBO content to the dock tile when necessary. */ 2341 2284 [self vboxPresentToDockTileCS:pCompositor]; 2285 #endif 2342 2286 2343 2287 /* change to #if 0 to see thumbnail image */ … … 2383 2327 2384 2328 #if 1 /* Set to 0 to see the docktile instead of the real output */ 2385 VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter;2386 const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry;2387 2388 CrVrScrCompositorConstIterInit(pCompositor, &CIter);2389 2390 2329 float backingStretchFactor = 1.; 2391 # if defined(VBOX_WITH_CONFIGURABLE_HIDPI_SCALING) && !defined(IN_VMSVGA3D)2330 # if defined(VBOX_WITH_CONFIGURABLE_HIDPI_SCALING) && !defined(IN_VMSVGA3D) 2392 2331 /* Adjust viewport according to current NSView's backing store parameters. */ 2393 2332 if (render_spu.fUnscaledHiDPI) … … 2403 2342 crDebug("HiDPI: vboxPresentToViewCS: up-scaling is %s (backingStretchFactor=%d).", 2404 2343 render_spu.fUnscaledHiDPI ? "OFF" : "ON", (int)backingStretchFactor); 2405 # endif2344 # endif 2406 2345 2407 2346 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); … … 2413 2352 m_fDataVisible = false; 2414 2353 2354 # ifndef IN_VMSVGA3D 2415 2355 float xStretch; 2416 2356 float yStretch; 2417 2357 CrVrScrCompositorGetStretching(pCompositor, &xStretch, &yStretch); 2418 2358 2359 VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter; 2360 const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry; 2361 CrVrScrCompositorConstIterInit(pCompositor, &CIter); 2362 2419 2363 while ((pEntry = CrVrScrCompositorConstIterNext(&CIter)) != NULL) 2420 2364 { … … 2468 2412 { 2469 2413 DEBUG_WARN(("CrBltEnter failed rc %d", rc)); 2470 # ifndef DEBUG_VERBOSE2414 # ifndef DEBUG_VERBOSE 2471 2415 AssertMsgFailed(("CrBltEnter failed rc %Rrc", rc)); 2472 # endif2416 # endif 2473 2417 } 2474 2418 } … … 2479 2423 } 2480 2424 } 2425 # endif /* !IN_VMSVGA3D */ 2481 2426 #endif 2482 2427 … … 2520 2465 } 2521 2466 2522 #ifdef VBOX_WITH_CRDUMPER_THUMBNAIL 2467 #ifndef IN_VMSVGA3D 2468 # ifdef VBOX_WITH_CRDUMPER_THUMBNAIL 2523 2469 static int g_cVBoxTgaCtr = 0; 2524 # endif2470 # endif 2525 2471 - (void)vboxPresentToDockTileCS:(PCVBOXVR_SCR_COMPOSITOR)pCompositor 2526 2472 { … … 2545 2491 { 2546 2492 m_msDockUpdateTS = msTS; 2547 # if 02493 # if 0 2548 2494 /* todo: check this for optimization */ 2549 2495 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, myTextureName); … … 2560 2506 glGetTexImage(GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA, 2561 2507 GL_UNSIGNED_INT_8_8_8_8_REV, pixels); 2562 # endif2508 # endif 2563 2509 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); 2564 2510 glDrawBuffer(GL_BACK); … … 2624 2570 { 2625 2571 DEBUG_WARN(("CrBltEnter failed rc %d", rc)); 2626 # ifndef DEBUG_VERBOSE2572 # ifndef DEBUG_VERBOSE 2627 2573 AssertMsgFailed(("CrBltEnter failed rc %Rrc", rc)); 2628 # endif2574 # endif 2629 2575 } 2630 2576 } … … 2651 2597 [m_DockTileView unlock]; 2652 2598 2653 # ifdef VBOX_WITH_CRDUMPER_THUMBNAIL2599 # ifdef VBOX_WITH_CRDUMPER_THUMBNAIL 2654 2600 ++g_cVBoxTgaCtr; 2655 2601 crDumpNamedTGAF((GLint)rr.size.width, (GLint)rr.size.height, 2656 2602 [[m_DockTileView thumbBitmap] bitmapData], "/Users/leo/vboxdumps/dump%d.tga", g_cVBoxTgaCtr); 2657 # endif2603 # endif 2658 2604 2659 2605 pDT = [[NSApplication sharedApplication] dockTile]; … … 2665 2611 } 2666 2612 } 2613 #endif /* !IN_VMSVGA3D */ 2667 2614 2668 2615 - (void)clearVisibleRegions … … 2945 2892 [pRunner runTasksSyncIfPossible]; 2946 2893 2894 #ifndef IN_VMSVGA3D 2947 2895 renderspuWinRetain(pWinInfo); 2948 2896 2949 #ifndef IN_VMSVGA3D2950 2897 if (renderspuCalloutAvailable()) 2951 2898 { … … 2971 2918 } 2972 2919 2920 #ifndef IN_VMSVGA3D 2973 2921 if (!*ppView) 2974 2922 renderspuWinRelease(pWinInfo); 2923 #endif 2975 2924 2976 2925 [pPool release]; … … 3212 3161 VMSVGA3D_DECL(void) vmsvga3dCocoaCreateView(NativeNSViewRef *ppView, NativeNSViewRef pParentView) 3213 3162 { 3214 /** @todo share WinInfo with caller and maintain it better. */ 3215 WindowInfo *pWinInfo = (WindowInfo *)RTMemAllocZ(sizeof(WindowInfo)); 3216 AssertLogRelReturnVoid(pWinInfo); 3217 pWinInfo->cRefs = 1; 3218 RTCritSectInit(&pWinInfo->CompositorLock); 3219 3220 cocoaViewCreate(ppView, pWinInfo, pParentView, 0 /* fVisParams - ignored */); 3163 cocoaViewCreate(ppView, NULL, pParentView, 0 /* fVisParams - ignored */); 3221 3164 } 3222 3165
Note:
See TracChangeset
for help on using the changeset viewer.