Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 50041)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 50095)
@@ -766,5 +766,5 @@
 
 static void RENDER_APIENTRY
-renderspuVBoxPresentComposition( GLint win, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
+renderspuVBoxPresentComposition( GLint win, const struct VBOXVR_SCR_COMPOSITOR * pCompositor, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
 {
     WindowInfo *window;
@@ -789,10 +789,10 @@
 }
 
-void renderspuVBoxCompositorBlitStretched ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter, GLfloat scaleX, GLfloat scaleY)
-{
-    VBOXVR_SCR_COMPOSITOR_ITERATOR CIter;
-    PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
-    CrVrScrCompositorIterInit(pCompositor, &CIter);
-    while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL)
+void renderspuVBoxCompositorBlitStretched ( const struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter, GLfloat scaleX, GLfloat scaleY)
+{
+    VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter;
+    const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry;
+    CrVrScrCompositorConstIterInit(pCompositor, &CIter);
+    while ((pEntry = CrVrScrCompositorConstIterNext(&CIter)) != NULL)
     {
         uint32_t cRegions;
@@ -806,9 +806,10 @@
             {
                 RTRECT DstRect;
+                const CR_TEXDATA *pTexData = CrVrScrCompositorEntryTexGet(pEntry);
                 DstRect.xLeft = paDstRegions[i].xLeft * scaleX;
                 DstRect.yTop = paDstRegions[i].yTop * scaleY;
                 DstRect.xRight = paDstRegions[i].xRight * scaleX;
                 DstRect.yBottom = paDstRegions[i].yBottom * scaleY;
-                CrBltBlitTexMural(pBlitter, true, &pEntry->Tex, &paSrcRegions[i], &DstRect, 1, fFlags);
+                CrBltBlitTexMural(pBlitter, true, CrTdTexGet(pTexData), &paSrcRegions[i], &DstRect, 1, fFlags);
             }
         }
@@ -820,10 +821,10 @@
 }
 
-void renderspuVBoxCompositorBlit ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter)
-{
-    VBOXVR_SCR_COMPOSITOR_ITERATOR CIter;
-    PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
-    CrVrScrCompositorIterInit(pCompositor, &CIter);
-    while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL)
+void renderspuVBoxCompositorBlit ( const struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter)
+{
+    VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter;
+    const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry;
+    CrVrScrCompositorConstIterInit(pCompositor, &CIter);
+    while ((pEntry = CrVrScrCompositorConstIterNext(&CIter)) != NULL)
     {
         uint32_t cRegions;
@@ -833,5 +834,6 @@
         if (RT_SUCCESS(rc))
         {
-            CrBltBlitTexMural(pBlitter, true, &pEntry->Tex, paSrcRegions, paDstRegions, cRegions, fFlags);
+            const CR_TEXDATA *pTexData = CrVrScrCompositorEntryTexGet(pEntry);
+            CrBltBlitTexMural(pBlitter, true, CrTdTexGet(pTexData), paSrcRegions, paDstRegions, cRegions, fFlags);
         }
         else
@@ -850,7 +852,7 @@
     {
         const CR_BLITTER_WINDOW * pBltInfo = CrBltMuralGetCurrentInfo(window->pBlitter);
-        if (pBltInfo->Base.id == window->BltInfo.Base.id)
-        {
-            CrBltMuralSetCurrent(window->pBlitter, NULL);
+        if (pBltInfo && pBltInfo->Base.id == window->BltInfo.Base.id)
+        {
+            CrBltMuralSetCurrentInfo(window->pBlitter, NULL);
         }
     }
@@ -858,5 +860,5 @@
     {
         CRASSERT(CrBltMuralGetCurrentInfo(window->pBlitter)->Base.id == window->BltInfo.Base.id);
-        CrBltMuralSetCurrent(window->pBlitter, NULL);
+        CrBltMuralSetCurrentInfo(window->pBlitter, NULL);
         CrBltTerm(window->pBlitter);
     }
@@ -895,5 +897,5 @@
             }
 
-            rc = CrBltInit(pBlitter, &pDefaultCtxInfo->BltInfo, true, true, NULL, render_spu.blitterDispatch);
+            rc = CrBltInit(pBlitter, &pDefaultCtxInfo->BltInfo, true, true, NULL, &render_spu.blitterDispatch);
 
             /* we can release it either way, since it will be retained when used as a shared context */
@@ -920,5 +922,5 @@
     }
 
-    CrBltMuralSetCurrent(pBlitter, &window->BltInfo);
+    CrBltMuralSetCurrentInfo(pBlitter, &window->BltInfo);
     return pBlitter;
 }
@@ -927,20 +929,8 @@
 {
     int rc;
-    PCR_BLITTER_CONTEXT pCtxInfo = NULL;
-    PCR_BLITTER_WINDOW pWindowInfo = NULL;
-    GET_CONTEXT(pCtx);
-
-    if (pCtx)
-    {
-        if (pCtx->currentWindow)
-        {
-            pCtxInfo = &pCtx->BltInfo;
-            pWindowInfo =  &pCtx->currentWindow->BltInfo;
-        }
-    }
 
     CrBltSetMakeCurrentUserData(pBlitter, i32MakeCurrentUserData);
 
-    rc = CrBltEnter(pBlitter, pCtxInfo, pWindowInfo);
+    rc = CrBltEnter(pBlitter);
     if (!RT_SUCCESS(rc))
     {
@@ -969,5 +959,5 @@
     if (!window->pBlitter)
     {
-        struct VBOXVR_SCR_COMPOSITOR * pTmpCompositor;
+        const struct VBOXVR_SCR_COMPOSITOR * pTmpCompositor;
         /* just use compositor lock to synchronize */
         pTmpCompositor = renderspuVBoxCompositorAcquire(window);
@@ -1006,5 +996,5 @@
 }
 
-void renderspuVBoxPresentCompositionGeneric( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry, int32_t i32MakeCurrentUserData )
+void renderspuVBoxPresentCompositionGeneric( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR * pCompositor, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry, int32_t i32MakeCurrentUserData )
 {
     PCR_BLITTER pBlitter = renderspuVBoxPresentBlitterGetAndEnter(window, i32MakeCurrentUserData);
@@ -1019,5 +1009,5 @@
 }
 
-void renderspuVBoxCompositorSet( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor)
+void renderspuVBoxCompositorSet( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR * pCompositor)
 {
     int rc;
@@ -1056,10 +1046,10 @@
 }
 
-struct VBOXVR_SCR_COMPOSITOR * renderspuVBoxCompositorAcquire( WindowInfo *window)
+const struct VBOXVR_SCR_COMPOSITOR * renderspuVBoxCompositorAcquire( WindowInfo *window)
 {
     int rc = RTCritSectEnter(&window->CompositorLock);
     if (RT_SUCCESS(rc))
     {
-        VBOXVR_SCR_COMPOSITOR * pCompositor = window->pCompositor;
+        const VBOXVR_SCR_COMPOSITOR * pCompositor = window->pCompositor;
         if (pCompositor)
             return pCompositor;
@@ -1089,5 +1079,5 @@
 }
 
-int renderspuVBoxCompositorTryAcquire(WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR **ppCompositor)
+int renderspuVBoxCompositorTryAcquire(WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR **ppCompositor)
 {
     int rc = RTCritSectTryEnter(&window->CompositorLock);
@@ -1551,4 +1541,11 @@
         break;
 
+    case GL_HH_SET_TMPCTX_MAKE_CURRENT:
+    	if (type == GL_BYTE && count == sizeof (void*))
+    		memcpy(&render_spu.blitterDispatch.MakeCurrent, values, count);
+    	else
+    		crWarning("unexpected type(%#x) - count(%d) pair", type, count);
+    	break;
+
     default:
 #if 0
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 50041)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 50095)
@@ -29,4 +29,5 @@
 #include "cr_server.h"
 #include "cr_blitter.h"
+#include "cr_compositor.h"
 
 #include <iprt/cdefs.h>
@@ -103,5 +104,5 @@
     char *title;
 
-    PVBOXVR_SCR_COMPOSITOR pCompositor;
+    const VBOXVR_SCR_COMPOSITOR *pCompositor;
     /* the composotor lock is used to synchronize the current compositor access,
      * i.e. the compositor can be accessed by a gui refraw thread,
@@ -285,5 +286,5 @@
     CRConnection **swap_conns;
 
-    SPUDispatchTable *blitterDispatch;
+    SPUDispatchTable blitterDispatch;
     CRHashTable *blitterTable;
 
@@ -406,16 +407,16 @@
 extern void renderspu_SystemSwapBuffers( WindowInfo *window, GLint flags );
 extern void renderspu_SystemReparentWindow(WindowInfo *window);
-extern void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry );
+extern void renderspu_SystemVBoxPresentComposition( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry );
 uint32_t renderspu_SystemPostprocessFunctions(SPUNamedFunctionTable *aFunctions, uint32_t cFunctions, uint32_t cTable);
 extern void renderspu_GCWindow(void);
 extern int renderspuCreateFunctions( SPUNamedFunctionTable table[] );
-extern void renderspuVBoxCompositorSet( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor);
+extern void renderspuVBoxCompositorSet( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR * pCompositor);
 extern void renderspuVBoxCompositorClearAll();
 extern int renderspuVBoxCompositorLock(WindowInfo *window);
 extern int renderspuVBoxCompositorUnlock(WindowInfo *window);
-extern struct VBOXVR_SCR_COMPOSITOR * renderspuVBoxCompositorAcquire( WindowInfo *window);
-extern int renderspuVBoxCompositorTryAcquire(WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR **ppCompositor);
+extern const struct VBOXVR_SCR_COMPOSITOR * renderspuVBoxCompositorAcquire( WindowInfo *window);
+extern int renderspuVBoxCompositorTryAcquire(WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR **ppCompositor);
 extern void renderspuVBoxCompositorRelease( WindowInfo *window);
-extern void renderspuVBoxPresentCompositionGeneric( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry, int32_t i32MakeCurrentUserData );
+extern void renderspuVBoxPresentCompositionGeneric( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR * pCompositor, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry, int32_t i32MakeCurrentUserData );
 extern PCR_BLITTER renderspuVBoxPresentBlitterGet( WindowInfo *window );
 void renderspuVBoxPresentBlitterCleanup( WindowInfo *window );
@@ -429,6 +430,6 @@
 extern GLboolean renderspuWindowInitWithVisual( WindowInfo *window, VisualInfo *visual, GLboolean showIt, GLint id );
 extern GLboolean renderspuInitVisual(VisualInfo *pVisInfo, const char *displayName, GLbitfield visAttribs);
-extern void renderspuVBoxCompositorBlit ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter);
-extern void renderspuVBoxCompositorBlitStretched ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter, GLfloat scaleX, GLfloat scaleY);
+extern void renderspuVBoxCompositorBlit ( const struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter);
+extern void renderspuVBoxCompositorBlitStretched ( const struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter, GLfloat scaleX, GLfloat scaleY);
 extern GLint renderspuCreateContextEx(const char *dpyName, GLint visBits, GLint id, GLint shareCtx);
 extern GLint renderspuWindowCreateEx( const char *dpyName, GLint visBits, GLint id );
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c	(revision 50041)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c	(revision 50095)
@@ -608,5 +608,5 @@
 }
 
-void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
+void renderspu_SystemVBoxPresentComposition( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR * pCompositor, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
 {
     renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry, 0);
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c	(revision 50041)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c	(revision 50095)
@@ -155,5 +155,5 @@
 }
 
-void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
+void renderspu_SystemVBoxPresentComposition( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
 {
     cocoaViewPresentComposition(window->window, pChangedEntry);
@@ -271,5 +271,5 @@
     if (!CrGlslIsInited(&render_spu.GlobalShaders))
     {
-        CrGlslInit(&render_spu.GlobalShaders, render_spu.blitterDispatch);
+        CrGlslInit(&render_spu.GlobalShaders, &render_spu.blitterDispatch);
     }
 
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.h
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.h	(revision 50041)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.h	(revision 50095)
@@ -23,4 +23,6 @@
 #include <OpenGL/OpenGL.h>
 #include <cr_vreg.h>
+#include <cr_compositor.h>
+
 
 RT_C_DECLS_BEGIN
@@ -47,5 +49,5 @@
 void cocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx);
 void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, const GLint* paRects);
-void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry);
+void cocoaViewPresentComposition(NativeNSViewRef pView, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry);
 
 RT_C_DECLS_END
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 50041)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 50095)
@@ -373,9 +373,9 @@
 - (void)vboxTryDraw;
 - (void)vboxTryDrawUI;
-- (void)vboxPresent:(PVBOXVR_SCR_COMPOSITOR)pCompositor;
-- (void)vboxPresentCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor;
-- (void)vboxPresentToDockTileCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor;
-- (void)vboxPresentToViewCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor;
-- (void)presentComposition:(PVBOXVR_SCR_COMPOSITOR_ENTRY)pChangedEntry;
+- (void)vboxPresent:(const VBOXVR_SCR_COMPOSITOR*)pCompositor;
+- (void)vboxPresentCS:(const VBOXVR_SCR_COMPOSITOR*)pCompositor;
+- (void)vboxPresentToDockTileCS:(const VBOXVR_SCR_COMPOSITOR*)pCompositor;
+- (void)vboxPresentToViewCS:(const VBOXVR_SCR_COMPOSITOR*)pCompositor;
+- (void)presentComposition:(const VBOXVR_SCR_COMPOSITOR_ENTRY*)pChangedEntry;
 - (void)vboxBlitterSyncWindow;
 
@@ -790,11 +790,6 @@
     [self deleteDockTile];
     
-    if (m_pGLCtx)
-    {
-        if ([m_pGLCtx view] == self)
-            [m_pGLCtx clearDrawable];
-
-        m_pGLCtx = nil;
-    }
+    [self setGLCtx:nil];
+    
     if (m_pSharedGLCtx)
     {
@@ -808,4 +803,6 @@
         CrBltTerm(m_pBlitter);
         
+        RTMemFree(m_pBlitter);
+        
         m_pBlitter = nil;
     }
@@ -836,7 +833,13 @@
     /* ensure the context drawable is cleared to avoid holding a reference to inexistent view */
     if (m_pGLCtx)
+    {
         [m_pGLCtx clearDrawable];
+        [m_pGLCtx release];
+        /*[m_pGLCtx performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];*/
+    }
 
     m_pGLCtx = pCtx;
+    if (pCtx)
+        [pCtx retain];
 }
 
@@ -1113,5 +1116,5 @@
     if ([self lockFocusIfCanDraw])
     {
-        VBOXVR_SCR_COMPOSITOR *pCompositor = NULL;
+        const const VBOXVR_SCR_COMPOSITOR *pCompositor = NULL;
         if (!m_pSharedGLCtx)
 	    {
@@ -1123,5 +1126,5 @@
                 if (m_pBlitter)
                 {
-                    int rc = CrBltInit(m_pBlitter, NULL, false, false, &render_spu.GlobalShaders, render_spu.blitterDispatch);
+                    int rc = CrBltInit(m_pBlitter, NULL, false, false, &render_spu.GlobalShaders, &render_spu.blitterDispatch);
                     if (RT_SUCCESS(rc))
                     {
@@ -1218,5 +1221,5 @@
              * while here we do a reverse order: acquire compositor lock being in gui thread.
              * this is why we do only try acquire and re-submit repaint event if compositor lock is busy */
-             VBOXVR_SCR_COMPOSITOR *pCompositor = NULL;
+            const VBOXVR_SCR_COMPOSITOR *pCompositor = NULL;
             int rc = renderspuVBoxCompositorTryAcquire(m_pWinInfo, &pCompositor);
             if (RT_SUCCESS(rc))
@@ -1228,4 +1231,5 @@
             else if (rc == VERR_SEM_BUSY)
             {
+                Assert(!pCompositor);
                 /* re-issue to the gui thread */
 # ifdef DEBUG_misha
@@ -1234,11 +1238,12 @@
                 [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(vboxTryDrawUI) userInfo:nil repeats:NO];
             }
-            else
+            else if (rc != VERR_INVALID_STATE) /* VERR_INVALID_STATE means no compositor, which is ok */
             {
+                Assert(!pCompositor);
                 /* this is somewhat we do not expect */
                 DEBUG_WARN(("renderspuVBoxCompositorTryAcquire failed rc %d", rc));
             }
 #else
-	    	VBOXVR_SCR_COMPOSITOR *pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo);
+	    	const VBOXVR_SCR_COMPOSITOR *pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo);
 	    	if (pCompositor)
 	    	{
@@ -1261,5 +1266,5 @@
 }
 
-- (void)vboxPresent:(PVBOXVR_SCR_COMPOSITOR)pCompositor
+- (void)vboxPresent:(const VBOXVR_SCR_COMPOSITOR*)pCompositor
 {
     VBOX_CR_RENDER_CTX_INFO CtxInfo;    
@@ -1285,5 +1290,5 @@
 }
 
-- (void)vboxPresentCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor
+- (void)vboxPresentCS:(const VBOXVR_SCR_COMPOSITOR*)pCompositor
 {
         {
@@ -1338,5 +1343,5 @@
 }
 
-- (void)vboxPresentToViewCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor
+- (void)vboxPresentToViewCS:(const VBOXVR_SCR_COMPOSITOR*)pCompositor
 {
     NSRect r = [self frame];
@@ -1345,8 +1350,8 @@
 
 #if 1 /* Set to 0 to see the docktile instead of the real output */
-    VBOXVR_SCR_COMPOSITOR_ITERATOR CIter;
-    PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
+    VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter;
+    const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry;
         
-    CrVrScrCompositorIterInit(pCompositor, &CIter);
+    CrVrScrCompositorConstIterInit(pCompositor, &CIter);
         
     glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
@@ -1358,5 +1363,5 @@
     CrVrScrCompositorGetStretching(pCompositor, &xStretch, &yStretch);
         
-    while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL)
+    while ((pEntry = CrVrScrCompositorConstIterNext(&CIter)) != NULL)
     {
         uint32_t cRegions;
@@ -1367,5 +1372,5 @@
         {
             uint32_t i;
-            int rc = CrBltEnter(m_pBlitter, NULL, NULL);
+            int rc = CrBltEnter(m_pBlitter);
             if (RT_SUCCESS(rc))
             {                   
@@ -1374,6 +1379,7 @@
                     const RTRECT * pSrcRect = &paSrcRegions[i];
                     const RTRECT * pDstRect = &paDstRegions[i];
-                    RTRECT SrcRect, DstRect, RestrictSrcRect, RestrictDstRect;
-                    
+                    RTRECT DstRect, RestrictDstRect;
+                    RTRECT SrcRect, RestrictSrcRect;
+
                     vboxNSRectToRect(&m_RootRect, &RestrictDstRect);
                     VBoxRectIntersected(&RestrictDstRect, pDstRect, &DstRect);
@@ -1383,6 +1389,7 @@
 
                     VBoxRectTranslate(&DstRect, -RestrictDstRect.xLeft, -RestrictDstRect.yTop);
-                        
+
                     vboxNSRectToRectUnstretched(&m_RootRect, &RestrictSrcRect, xStretch, yStretch);
+                    VBoxRectTranslate(&RestrictSrcRect, -CrVrScrCompositorEntryRectGet(pEntry)->xLeft, -CrVrScrCompositorEntryRectGet(pEntry)->yTop);
                     VBoxRectIntersected(&RestrictSrcRect, pSrcRect, &SrcRect);
                     
@@ -1393,5 +1400,7 @@
                     pDstRect = &DstRect;
                     
-                    CrBltBlitTexMural(m_pBlitter, true, &pEntry->Tex, pSrcRect, pDstRect, 1, fFlags | CRBLT_F_NOALPHA);
+                    const CR_TEXDATA *pTexData = CrVrScrCompositorEntryTexGet(pEntry);
+                    
+                    CrBltBlitTexMural(m_pBlitter, true, CrTdTexGet(pTexData), pSrcRect, pDstRect, 1, fFlags | CRBLT_F_NOALPHA);
                 }
                 CrBltLeave(m_pBlitter);
@@ -1416,5 +1425,5 @@
 }
 
-- (void)presentComposition:(PVBOXVR_SCR_COMPOSITOR_ENTRY)pChangedEntry
+- (void)presentComposition:(const VBOXVR_SCR_COMPOSITOR_ENTRY*)pChangedEntry
 {
     [self vboxTryDraw];
@@ -1438,7 +1447,7 @@
     Assert(WinInfo.height = m_RootRect.size.height);
 
-    /*CrBltMuralSetCurrent(m_pBlitter, NULL);*/
-    
-    CrBltMuralSetCurrent(m_pBlitter, &WinInfo);
+    /*CrBltMuralSetCurrentInfo(m_pBlitter, NULL);*/
+    
+    CrBltMuralSetCurrentInfo(m_pBlitter, &WinInfo);
     CrBltCheckUpdateViewport(m_pBlitter);
 }
@@ -1447,5 +1456,5 @@
 static int g_cVBoxTgaCtr = 0;
 #endif
-- (void)vboxPresentToDockTileCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor
+- (void)vboxPresentToDockTileCS:(const VBOXVR_SCR_COMPOSITOR*)pCompositor
 {
     NSRect r        = [self frame];
@@ -1460,6 +1469,6 @@
          * heavy performance wise. */
         uint64_t uiNewTime = RTTimeMilliTS();
-        VBOXVR_SCR_COMPOSITOR_ITERATOR CIter;
-        PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
+        VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter;
+        const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry;
         
         if (uiNewTime - m_uiDockUpdateTime > 200)
@@ -1492,6 +1501,6 @@
             CrVrScrCompositorGetStretching(pCompositor, &xStretch, &yStretch);
             
-            CrVrScrCompositorIterInit(pCompositor, &CIter);
-            while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL)
+            CrVrScrCompositorConstIterInit(pCompositor, &CIter);
+            while ((pEntry = CrVrScrCompositorConstIterNext(&CIter)) != NULL)
             {
                 uint32_t cRegions;
@@ -1502,5 +1511,5 @@
                 {
                     uint32_t i;
-                    int rc = CrBltEnter(m_pBlitter, NULL, NULL);
+                    int rc = CrBltEnter(m_pBlitter);
                     if (RT_SUCCESS(rc))
                     {                   
@@ -1522,4 +1531,5 @@
                         
                             vboxNSRectToRectUnstretched(&m_RootRect, &RestrictSrcRect, xStretch, yStretch);
+                            VBoxRectTranslate(&RestrictSrcRect, -CrVrScrCompositorEntryRectGet(pEntry)->xLeft, -CrVrScrCompositorEntryRectGet(pEntry)->yTop);
                             VBoxRectIntersected(&RestrictSrcRect, pSrcRect, &SrcRect);
                     
@@ -1530,5 +1540,7 @@
                             pDstRect = &DstRect;
                             
-                            CrBltBlitTexMural(m_pBlitter, true, &pEntry->Tex, pSrcRect, pDstRect, 1, fFlags);
+                            const CR_TEXDATA *pTexData = CrVrScrCompositorEntryTexGet(pEntry);
+                            
+                            CrBltBlitTexMural(m_pBlitter, true, CrTdTexGet(pTexData), pSrcRect, pDstRect, 1, fFlags);
                         }
                         CrBltLeave(m_pBlitter);
@@ -1747,7 +1759,6 @@
     NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
 
-    /*
     [pCtx release];
-    */
+    /*[pCtx performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];*/
 
     [pPool release];
@@ -1906,5 +1917,5 @@
 }
 
-void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry)
+void cocoaViewPresentComposition(NativeNSViewRef pView, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry)
 {
     NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c	(revision 50041)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c	(revision 50095)
@@ -579,5 +579,5 @@
                     if (pWindow)
                     {
-                        struct VBOXVR_SCR_COMPOSITOR * pCompositor;
+                        const struct VBOXVR_SCR_COMPOSITOR * pCompositor;
 
                         pCompositor = renderspuVBoxCompositorAcquire(pWindow);
@@ -1969,5 +1969,5 @@
 }
 
-void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
+void renderspu_SystemVBoxPresentComposition( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
 {
     /* the CR_RENDER_FORCE_PRESENT_MAIN_THREAD is actually inherited from cocoa backend impl,
@@ -1976,5 +1976,5 @@
      * @todo: change to some more generic macro name */
 #ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD
-    struct VBOXVR_SCR_COMPOSITOR *pCompositor;
+    const struct VBOXVR_SCR_COMPOSITOR *pCompositor;
     /* we do not want to be blocked with the GUI thread here, so only draw her eif we are really able to do that w/o bllocking */
     int rc = renderspuVBoxCompositorTryAcquire(window, &pCompositor);
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c	(revision 50041)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c	(revision 50095)
@@ -386,5 +386,6 @@
     crSPUCopyDispatchTable( &(render_spu.self), self );
 
-    render_spu.blitterDispatch = &(render_spu.self);
+    crSPUInitDispatchTable( &(render_spu.blitterDispatch) );
+    crSPUCopyDispatchTable( &(render_spu.blitterDispatch), self );
 
     render_spu.server = (CRServer *)(self->server);
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c	(revision 50041)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c	(revision 50095)
@@ -431,5 +431,5 @@
             if (pWindow)
             {
-                struct VBOXVR_SCR_COMPOSITOR * pCompositor;
+                const struct VBOXVR_SCR_COMPOSITOR * pCompositor;
 
                 pCompositor = renderspuVBoxCompositorAcquire(pWindow);
@@ -1252,5 +1252,5 @@
 }
 
-void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
+void renderspu_SystemVBoxPresentComposition( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
 {
     /* the CR_RENDER_FORCE_PRESENT_MAIN_THREAD is actually inherited from cocoa backend impl,
@@ -1259,5 +1259,5 @@
      * @todo: change to some more generic macro name */
 #ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD
-    struct VBOXVR_SCR_COMPOSITOR *pCompositor;
+    const struct VBOXVR_SCR_COMPOSITOR *pCompositor;
     /* we do not want to be blocked with the GUI thread here, so only draw her eif we are really able to do that w/o bllocking */
     int rc = renderspuVBoxCompositorTryAcquire(window, &pCompositor);
