Index: /trunk/src/VBox/Devices/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Devices/Makefile.kmk	(revision 54766)
+++ /trunk/src/VBox/Devices/Makefile.kmk	(revision 54767)
@@ -1505,7 +1505,5 @@
  VBoxSVGA3DObjC_SOURCES.darwin += \
  	../HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m \
- 	../GuestHost/OpenGL/util/vreg.cpp \
  	../GuestHost/OpenGL/util/blitter.cpp \
- 	../GuestHost/OpenGL/util/compositor.cpp \
  	../HostServices/SharedOpenGL/OpenGLTest/OpenGLTestDarwin.cpp
  endif
Index: /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 54766)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 54767)
@@ -213,4 +213,5 @@
 #define VBOX_WITH_CONFIGURABLE_HIDPI_SCALING    1
 
+
 #ifdef IN_VMSVGA3D
 
@@ -218,4 +219,5 @@
  * VMSVGA3D compatibility glue.
  */
+typedef struct WindowInfo WindowInfo;
 
 # define CR_RGB_BIT             RT_BIT_32(0)
@@ -233,74 +235,4 @@
 # define VMSVGA3D_NON_DEFAULT_PROFILE_BIT RT_BIT_32(31)
 # define CR_ALL_BITS            UINT32_C(0x800003ff)
-
-typedef struct WindowInfo
-{
-    uint32_t volatile           cRefs;
-    RTCRITSECT                  CompositorLock;
-    PCVBOXVR_SCR_COMPOSITOR     pCompositor;
-
-    //NativeNSViewRef window;
-    //NativeNSViewRef nativeWindow; /**< for render_to_app_window */
-    NativeNSOpenGLContextRef   *currentCtx;
-} WindowInfo;
-
-static void vmsvga3DWinInfoDestroy(WindowInfo *pWinInfo)
-{
-    /** @todo */
-}
-
-DECLINLINE(void) renderspuWinRetain(WindowInfo *pWinInfo)
-{
-    ASMAtomicIncU32(&pWinInfo->cRefs);
-}
-
-DECLINLINE(void) renderspuWinRelease(WindowInfo *pWinInfo)
-{
-    uint32_t cRefs = ASMAtomicDecU32(&pWinInfo->cRefs);
-    if (!cRefs)
-        vmsvga3DWinInfoDestroy(pWinInfo);
-}      
-
-static int renderspuVBoxCompositorLock(WindowInfo *pWinInfo, PCVBOXVR_SCR_COMPOSITOR *ppCompositor)
-{
-    int rc = RTCritSectEnter(&pWinInfo->CompositorLock);
-    AssertRCReturn(rc, rc);
-    if (ppCompositor)
-        *ppCompositor = pWinInfo->pCompositor;
-    return VINF_SUCCESS;
-}
-
-static int renderspuVBoxCompositorUnlock(WindowInfo *pWinInfo)
-{
-    int rc = RTCritSectLeave(&pWinInfo->CompositorLock);
-    AssertRC(rc);
-    return rc;
-}
-
-static PCVBOXVR_SCR_COMPOSITOR renderspuVBoxCompositorAcquire(WindowInfo *pWinInfo)
-{
-    int rc = RTCritSectEnter(&pWinInfo->CompositorLock);
-    AssertRCReturn(rc, NULL);
-
-    PCVBOXVR_SCR_COMPOSITOR pCompositor = pWinInfo->pCompositor;
-    if (pCompositor)
-    {
-        Assert(!CrVrScrCompositorIsEmpty(pWinInfo->pCompositor));
-        return pCompositor;
-    }
-
-    /* if no compositor is set, release the lock and return */
-    RTCritSectLeave(&pWinInfo->CompositorLock);
-    return NULL;
-}
-
-static void renderspuVBoxCompositorRelease(WindowInfo *pWinInfo)
-{
-    Assert(pWinInfo->pCompositor);
-    Assert(!CrVrScrCompositorIsEmpty(pWinInfo->pCompositor));
-    int rc = RTCritSectLeave(&pWinInfo->CompositorLock);
-    AssertRC(rc);
-}
-
 
 #endif /* IN_VMSVGA3D */
@@ -862,5 +794,7 @@
     
     CR_BLITTER         *m_pBlitter;
+#ifndef IN_VMSVGA3D
     WindowInfo         *m_pWinInfo;
+#endif
     bool                m_fNeedViewportUpdate;
     bool                m_fNeedCtxUpdate;
@@ -912,5 +846,7 @@
 - (void)vboxPresent:(const VBOXVR_SCR_COMPOSITOR *)pCompositor;
 - (void)vboxPresentCS:(const VBOXVR_SCR_COMPOSITOR *)pCompositor;
+#ifndef IN_VMSVGA3D
 - (void)vboxPresentToDockTileCS:(const VBOXVR_SCR_COMPOSITOR *)pCompositor;
+#endif
 - (void)vboxPresentToViewCS:(const VBOXVR_SCR_COMPOSITOR *)pCompositor;
 - (void)presentComposition:(const VBOXVR_SCR_COMPOSITOR_ENTRY *)pChangedEntry;
@@ -1418,5 +1354,7 @@
     m_yInvRootOffset          = 0;
     m_pBlitter                = nil;
+#ifndef IN_VMSVGA3D
     m_pWinInfo                = pWinInfo;
+#endif
     m_fNeedViewportUpdate     = true;
     m_fNeedCtxUpdate          = true;
@@ -1636,5 +1574,7 @@
     }
     
+#ifndef IN_VMSVGA3D
     renderspuWinRelease(m_pWinInfo);
+#endif
     
     COCOA_LOG_FLOW(("%s: returns\n", __PRETTY_FUNCTION__));
@@ -2220,5 +2160,6 @@
 #endif
     
-    const VBOXVR_SCR_COMPOSITOR *pCompositor;
+    const VBOXVR_SCR_COMPOSITOR *pCompositor = NULL;
+#ifndef IN_VMSVGA3D
     int rc = renderspuVBoxCompositorLock(m_pWinInfo, &pCompositor);
     if (RT_FAILURE(rc))
@@ -2228,5 +2169,4 @@
     }
 
-#ifndef IN_VMSVGA3D
     if (!pCompositor && !m_fCleanupNeeded)
     {
@@ -2235,8 +2175,6 @@
         return;
     }
-#endif
 
     VBOXVR_SCR_COMPOSITOR TmpCompositor;
-    
     if (pCompositor)
     {
@@ -2267,10 +2205,10 @@
     {
         DEBUG_MSG(("%s: NeedCleanup\n", __PRETTY_FUNCTION__));
-#ifndef IN_VMSVGA3D /** @todo VMSVGA3 */
         Assert(m_fCleanupNeeded);
-#endif
         CrVrScrCompositorInit(&TmpCompositor, NULL);
         pCompositor = &TmpCompositor;
     }
+#endif /* !IN_VMSVGA3D */
+
     
     if ([self lockFocusIfCanDraw])
@@ -2293,5 +2231,7 @@
     }
     
+#ifndef IN_VMSVGA3D
     renderspuVBoxCompositorUnlock(m_pWinInfo);
+#endif
     COCOA_LOG_FLOW(("%s: returns\n", __PRETTY_FUNCTION__));
 }
@@ -2308,5 +2248,7 @@
     COCOA_LOG_FLOW(("%s: self=%p pCompositor=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)pCompositor));
     /*DEBUG_MSG(("OVIW(%p): renderFBOToView\n", (void *)self));*/
+#ifndef IN_VMSVGA3D
     AssertPtr(pCompositor);
+#endif
 
     VBOX_CR_RENDER_CTX_INFO CtxInfo;    
@@ -2338,6 +2280,8 @@
     m_fCleanupNeeded = false;
     
+#ifndef IN_VMSVGA3D
     /* Render FBO content to the dock tile when necessary. */
     [self vboxPresentToDockTileCS:pCompositor];
+#endif
 
     /* change to #if 0 to see thumbnail image */            
@@ -2383,11 +2327,6 @@
 
 #if 1 /* Set to 0 to see the docktile instead of the real output */
-    VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter;
-    const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry;
-
-    CrVrScrCompositorConstIterInit(pCompositor, &CIter);
-
     float backingStretchFactor = 1.;
-#if defined(VBOX_WITH_CONFIGURABLE_HIDPI_SCALING) && !defined(IN_VMSVGA3D)
+#  if defined(VBOX_WITH_CONFIGURABLE_HIDPI_SCALING) && !defined(IN_VMSVGA3D)
     /* Adjust viewport according to current NSView's backing store parameters. */
     if (render_spu.fUnscaledHiDPI)
@@ -2403,5 +2342,5 @@
     crDebug("HiDPI: vboxPresentToViewCS: up-scaling is %s (backingStretchFactor=%d).",
         render_spu.fUnscaledHiDPI ? "OFF" : "ON", (int)backingStretchFactor);
-#endif
+#  endif
 
     glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
@@ -2413,8 +2352,13 @@
     m_fDataVisible = false;
     
+# ifndef IN_VMSVGA3D
     float xStretch;
     float yStretch;
     CrVrScrCompositorGetStretching(pCompositor, &xStretch, &yStretch);
         
+    VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter;
+    const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry;
+    CrVrScrCompositorConstIterInit(pCompositor, &CIter);
+
     while ((pEntry = CrVrScrCompositorConstIterNext(&CIter)) != NULL)
     {
@@ -2468,7 +2412,7 @@
             {
                 DEBUG_WARN(("CrBltEnter failed rc %d", rc));
-# ifndef DEBUG_VERBOSE
+#  ifndef DEBUG_VERBOSE
                 AssertMsgFailed(("CrBltEnter failed rc %Rrc", rc));
-# endif
+#  endif
             }
         }
@@ -2479,4 +2423,5 @@
         }
     }
+# endif /* !IN_VMSVGA3D */
 #endif
 
@@ -2520,7 +2465,8 @@
 }
 
-#ifdef VBOX_WITH_CRDUMPER_THUMBNAIL
+#ifndef IN_VMSVGA3D
+# ifdef VBOX_WITH_CRDUMPER_THUMBNAIL
 static int g_cVBoxTgaCtr = 0;
-#endif
+# endif
 - (void)vboxPresentToDockTileCS:(PCVBOXVR_SCR_COMPOSITOR)pCompositor
 {
@@ -2545,5 +2491,5 @@
         {
             m_msDockUpdateTS = msTS;
-#if 0
+# if 0
             /* todo: check this for optimization */
             glBindTexture(GL_TEXTURE_RECTANGLE_ARB, myTextureName);
@@ -2560,5 +2506,5 @@
             glGetTexImage(GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
                           GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
-#endif
+# endif
             glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
             glDrawBuffer(GL_BACK);
@@ -2624,7 +2570,7 @@
                     {
                         DEBUG_WARN(("CrBltEnter failed rc %d", rc));
-#ifndef DEBUG_VERBOSE
+# ifndef DEBUG_VERBOSE
                         AssertMsgFailed(("CrBltEnter failed rc %Rrc", rc));
-#endif
+# endif
                     }
                 }
@@ -2651,9 +2597,9 @@
             [m_DockTileView unlock];
             
-#ifdef VBOX_WITH_CRDUMPER_THUMBNAIL
+# ifdef VBOX_WITH_CRDUMPER_THUMBNAIL
             ++g_cVBoxTgaCtr;
             crDumpNamedTGAF((GLint)rr.size.width, (GLint)rr.size.height, 
                 [[m_DockTileView thumbBitmap] bitmapData], "/Users/leo/vboxdumps/dump%d.tga", g_cVBoxTgaCtr);
-#endif                
+# endif                
 
             pDT = [[NSApplication sharedApplication] dockTile];
@@ -2665,4 +2611,5 @@
     }
 }
+#endif /* !IN_VMSVGA3D */
 
 - (void)clearVisibleRegions
@@ -2945,7 +2892,7 @@
     [pRunner runTasksSyncIfPossible];
     
+#ifndef IN_VMSVGA3D
     renderspuWinRetain(pWinInfo);
 
-#ifndef IN_VMSVGA3D
     if (renderspuCalloutAvailable())
     {
@@ -2971,6 +2918,8 @@
     }
     
+#ifndef IN_VMSVGA3D
     if (!*ppView)
         renderspuWinRelease(pWinInfo);
+#endif
     
     [pPool release];
@@ -3212,11 +3161,5 @@
 VMSVGA3D_DECL(void) vmsvga3dCocoaCreateView(NativeNSViewRef *ppView, NativeNSViewRef pParentView)
 {
-    /** @todo share WinInfo with caller and maintain it better. */
-    WindowInfo *pWinInfo = (WindowInfo *)RTMemAllocZ(sizeof(WindowInfo));
-    AssertLogRelReturnVoid(pWinInfo);
-    pWinInfo->cRefs = 1;
-    RTCritSectInit(&pWinInfo->CompositorLock);
-
-    cocoaViewCreate(ppView, pWinInfo, pParentView, 0 /* fVisParams - ignored */);
+    cocoaViewCreate(ppView, NULL, pParentView, 0 /* fVisParams - ignored */);
 }
 
