renderspu_cocoa_helper.m revision b9473064e26edc9a65150b4206ea1e52f3ca600a
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * VirtualBox OpenGL Cocoa Window System Helper Implementation.
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * This source file is shared between the SharedOpenGL HGCM service and the
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * SVGA3d emulation.
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * Copyright (C) 2009-2014 Oracle Corporation
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * available from http://www.virtualbox.org. This file is free software;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * you can redistribute it and/or modify it under the terms of the GNU
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * General Public License (GPL) as published by the Free Software
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync/** @page pg_opengl_cocoa OpenGL - Cocoa Window System Helper
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * How this works:
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * In general it is not so easy like on the other platforms, cause Cocoa
da957c069c2a3c582fe265ff88170ce4c42b499dvboxsync * doesn't support any clipping of already painted stuff. In Mac OS X there is
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * the concept of translucent canvas's e.g. windows and there it is just
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * painted what should be visible to the user. Unfortunately this isn't the
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * concept of chromium. Therefor I reroute all OpenGL operation from the guest
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * to a frame buffer object (FBO). This is a OpenGL extension, which is
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * supported by all OS X versions we support (AFAIC tell). Of course the guest
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * doesn't know that and we have to make sure that the OpenGL state always is
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * in the right state to paint into the FBO and not to the front/back buffer.
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * Several functions below (like cocoaBindFramebufferEXT, cocoaGetIntegerv,
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * ...) doing this. When a swap or finish is triggered by the guest, the
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * content (which is already bound to an texture) is painted on the screen
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * within a separate OpenGL context. This allows the usage of the same
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * resources (texture ids, buffers ...) but at the same time having an
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * different internal OpenGL state. Another advantage is that we can paint a
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * thumbnail of the current output in a much more smaller (GPU accelerated
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * scale) version on a third context and use glReadPixels to get the actual
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * data. glReadPixels is a very slow operation, but as we just use a much more
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * smaller image, we can handle it (anyway this is only done 5 times per
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * Other things to know:
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * - If the guest request double buffering, we have to make sure there are two
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * buffers. We use the same FBO with 2 color attachments. Also glDrawBuffer
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * and glReadBuffer is intercepted to make sure it is painted/read to/from
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * the correct buffers. On swap our buffers are swapped and not the
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * - If the guest request a depth/stencil buffer, a combined render buffer for
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * this is created.
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * - If the size of the guest OpenGL window changes, all FBO's, textures, ...
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * need to be recreated.
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * - We need to track any changes to the parent window
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * (create/destroy/move/resize). The various classes like OverlayHelperView,
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * OverlayWindow, ... are there for.
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync * - The HGCM service runs on a other thread than the Main GUI. Keeps this
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * always in mind (see e.g. performSelectorOnMainThread in renderFBOToView)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * - We make heavy use of late binding. We can not be sure that the GUI (or any
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * other third party GUI), overwrite our NSOpenGLContext. So we always ask if
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * this is our own one, before use. Really neat concept of Objective-C/Cocoa
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync/*******************************************************************************
fe96bc0e43d9c137304462ef8c2d79cbff22446fvboxsync* Header Files *
fe96bc0e43d9c137304462ef8c2d79cbff22446fvboxsync*******************************************************************************/
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync#undef PVM /* sys/param.h (included via Cocoa.h) pollutes the namespace with this define. */
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync# include "chromium.h" /* For the visual bits of chromium */
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync/*******************************************************************************
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync* Defined Constants And Macros *
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync*******************************************************************************/
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync/* Debug macros */
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync/** @def FBO
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * Disable this to see how the output is without the FBO in the middle of the processing chain. */
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync/** @def CR_RENDER_FORCE_PRESENT_MAIN_THREAD
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * Force present schedule to main thread. */
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync/** @def SHOW_WINDOW_BACKGROUND
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * Define this to see the window background even if the window is clipped. */
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync/** @def DEBUG_VERBOSE
fe96bc0e43d9c137304462ef8c2d79cbff22446fvboxsync * Define this to get some debug info about the messages flow. */
e3f5c51715cbf77ae2d2e9d05bafd00d69b1bec9vboxsync# define DEBUG_INFO(text) do { LogRel(text); AssertFailed(); } while (0)
aa32d4906f2f685992091893d5abdf27a2352a85vboxsync# define DEBUG_WARN(text) do { LogRel(text); AssertFailed(); } while (0)
aa32d4906f2f685992091893d5abdf27a2352a85vboxsync# define DEBUG_INFO(text) do { crWarning text; AssertFailed(); } while (0)
aa32d4906f2f685992091893d5abdf27a2352a85vboxsync# define DEBUG_WARN(text) do { crWarning text; AssertFailed(); } while (0)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync# define DEBUG_MSG(text) do { printf text; } while (0)
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync# define DEBUG_MSG_1(text) do { printf text; } while (0)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync# define DEBUG_INFO(text) do { LogRel(text); } while (0)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync# define DEBUG_WARN(text) do { LogRel(text); } while (0)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync# define DEBUG_INFO(text) do { crInfo text; } while (0)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync# define DEBUG_WARN(text) do { crWarning text; } while (0)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync# define DEBUG_MSG_NOT_VMSVGA3D(a_TextArgs) do {} while (0)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync# define COCOA_LOG_FLOW(a_TextArgs) LogFlow(a_TextArgs)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync# define DEBUG_MSG_NOT_VMSVGA3D(a_TextArgs) DEBUG_MSG(a_TextArgs)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync# define COCOA_LOG_FLOW(a_TextArgs) DEBUG_MSG(a_TextArgs)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync#define DEBUG_FUNC_ENTER() DEBUG_MSG(("==>%s\n", __PRETTY_FUNCTION__))
b514c03a427443a7ad18c1202d2ee7acc47cf9afvboxsync#define DEBUG_FUNC_LEAVE() DEBUG_MSG(("<==%s\n", __PRETTY_FUNCTION__))
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync } while (0)
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync } while (0)
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync# define DEBUG_CHECK_GL_ERROR() do { checkGLError(__FILE__, __LINE__); } while (0);
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync const char *errStr;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync case GL_INVALID_ENUM: errStr = "GL_INVALID_ENUM"; break;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync case GL_INVALID_VALUE: errStr = "GL_INVALID_VALUE"; break;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync case GL_INVALID_OPERATION: errStr = "GL_INVALID_OPERATION"; break;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync case GL_STACK_OVERFLOW: errStr = "GL_STACK_OVERFLOW"; break;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync case GL_STACK_UNDERFLOW: errStr = "GL_STACK_UNDERFLOW"; break;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync case GL_OUT_OF_MEMORY: errStr = "GL_OUT_OF_MEMORY"; break;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync case GL_TABLE_TOO_LARGE: errStr = "GL_TABLE_TOO_LARGE"; break;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync DEBUG_MSG(("%s:%d: glError %d (%s)\n", pszFile, iLine, uGlErr, errStr));
c6958b923ed12aadcf58ebbdbc80aadebbd9493evboxsync * VMSVGA3D compatability glue.
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync //NativeNSViewRef window;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync //NativeNSViewRef nativeWindow; /**< for render_to_app_window */
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsyncstatic void vmsvga3DWinInfoDestroy(WindowInfo *pWinInfo)
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync /** @todo */
b1cc88518a7578ee20491f3d97b9792c24c6428dvboxsyncDECLINLINE(void) renderspuWinRetain(WindowInfo *pWinInfo)
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsyncDECLINLINE(void) renderspuWinRelease(WindowInfo *pWinInfo)
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync uint32_t cRefs = ASMAtomicDecU32(&pWinInfo->cRefs);
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsyncstatic int renderspuVBoxCompositorLock(WindowInfo *pWinInfo, PCVBOXVR_SCR_COMPOSITOR *ppCompositor)
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync int rc = RTCritSectEnter(&pWinInfo->CompositorLock);
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsyncstatic int renderspuVBoxCompositorUnlock(WindowInfo *pWinInfo)
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync int rc = RTCritSectLeave(&pWinInfo->CompositorLock);
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsyncstatic PCVBOXVR_SCR_COMPOSITOR renderspuVBoxCompositorAcquire(WindowInfo *pWinInfo)
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync int rc = RTCritSectEnter(&pWinInfo->CompositorLock);
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync PCVBOXVR_SCR_COMPOSITOR pCompositor = pWinInfo->pCompositor;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync Assert(!CrVrScrCompositorIsEmpty(pWinInfo->pCompositor));
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync /* if no compositor is set, release the lock and return */
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsyncstatic void renderspuVBoxCompositorRelease(WindowInfo *pWinInfo)
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync Assert(!CrVrScrCompositorIsEmpty(pWinInfo->pCompositor));
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync int rc = RTCritSectLeave(&pWinInfo->CompositorLock);
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync NSOpenGLContext *pCtx = [NSOpenGLContext currentContext];
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync renderspu_SystemMakeCurrent(pWinInfo, 0, pCtxInfo);
914d33aebb63d8c288dfd1b7e74f8e2acf3eaa66vboxsync * State carrying structure for use with vboxCtxEnter and vboxCtxLeave
97dc0e92bcc0cddf896cbf620b689b095c7346davboxsync/** Pointer to render context info for use with vboxCtxEnter/Leave. */
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsynctypedef VBOX_CR_RENDER_CTX_INFO *PVBOX_CR_RENDER_CTX_INFO;
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsyncstatic void vboxCtxEnter(NSOpenGLContext *pNewCtx, PVBOX_CR_RENDER_CTX_INFO pCtxInfo)
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync /** @todo r=bird: Why do we save the NEW VIEW here? vboxCtxLeave calls it 'pOldView'. Bug? */
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync /* No context switch necessary. */
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsyncstatic void vboxCtxLeave(PVBOX_CR_RENDER_CTX_INFO pCtxInfo)
5b1d6bab9f4cf5dacf1883e7c4a40c84349f597fvboxsync /* vboxCtxEnter saves the new view, not the old. So, what we actually
@end
- (void)run;
@end
- (void)run
@end
- (void)run;
- (void)dealloc;
@end
if (self)
return self;
- (void)run
- (void)dealloc
[super dealloc];
@end
- (void)run;
- (void)dealloc;
@end
if (self)
return nil;
return self;
- (void)run
++m_CurIndex;
- (void)dealloc
[super dealloc];
@end
- (void)runTasks;
- (void)dealloc;
@end
if (self)
return self;
return s_pRunner;
VBoxTaskPerformSelector *pSelTask = [[VBoxTaskPerformSelector alloc] initWithObject:aObject selector:aSelector arg:aArg];
- (void)runTasks
AssertFailed();
if (renderspuCalloutAvailable())
- (void)dealloc
[super dealloc];
@end
@class DockOverlayView;
float m_yInvRootOffset;
- (id)initWithFrame:(NSRect)frame thread:(RTTHREAD)aThread parentView:(NSView *)pParentView winInfo:(WindowInfo *)pWinInfo;
- (void)vboxDestroy;
- (void)updateViewportCS;
- (void)vboxReshapePerform;
- (void)vboxReshapeOnResizePerform;
- (void)vboxReshapeOnReparentPerform;
- (void)createDockTile;
- (void)deleteDockTile;
- (void)makeCurrentFBO;
- (void)swapFBO;
- (void)vboxTryDraw;
- (void)vboxTryDrawUI;
- (void)vboxBlitterSyncWindow;
- (void)clearVisibleRegions;
- (void)reshapeDockTile;
- (void)cleanupData;
@end
* (which happens on fullscreen/seamless entry/exit) the overlay
@class OverlayWindow;
@end
@end
- (void)dealloc;
- (void)cleanup;
- (void)lock;
- (void)unlock;
@end
if (self)
return self;
- (void)dealloc
[super dealloc];
- (void)cleanup
- (void)lock
- (void)unlock
return YES;
[m_ThumbImage drawAtPoint:NSMakePoint(0, 0) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
return m_ThumbBitmap;
return m_ThumbImage;
@end
if (self)
return self;
- (void)dealloc
[super dealloc];
return m_pView;
return [super view];
-(void)clearDrawable
[super clearDrawable];
return m_pPixelFormat;
return self;
-(void)viewDidMoveToWindow
@end
self = [super initWithContentRect:NSZeroRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
if (self)
return self;
- (void)dealloc
[super dealloc];
[m_pOverlayView performSelector:@selector(vboxReshapePerform) onThread:m_Thread withObject:nil waitUntilDone:YES];
[NSTimer scheduledTimerWithTimeInterval:0.2 target:m_pOverlayView selector:@selector(vboxReshapePerform) userInfo:nil repeats:NO];
- (id)initWithFrame:(NSRect)frame thread:(RTTHREAD)aThread parentView:(NSView *)pParentView winInfo:(WindowInfo *)pWinInfo
COCOA_LOG_FLOW(("%s: self=%p aThread=%p pParentView=%p pWinInfo=%p\n", __PRETTY_FUNCTION__, (void *)self,
m_fNeedViewportUpdate = true;
m_fNeedCtxUpdate = true;
m_fDataVisible = false;
m_fCleanupNeeded = false;
m_fEverSized = false;
return self;
- (void)cleanupData
if (m_pSharedGLCtx)
- (void)dealloc
[super dealloc];
COCOA_LOG_FLOW(("%s: self=%p aRect=%d,%d %d,%d\n", __PRETTY_FUNCTION__, (void *)self, (int)aRect.origin.x, (int)aRect.origin.y,
COCOA_LOG_FLOW(("%s: self=%p pCtx=%p (old=%p)\n", __PRETTY_FUNCTION__, (void *)self, (void *)pCtx, m_pGLCtx));
if (m_pGLCtx)
if (pCtx)
return m_pGLCtx;
COCOA_LOG_FLOW(("%s: self=%p returns %p\n", __PRETTY_FUNCTION__, (void *)self, (void *)m_pParentView));
return m_pParentView;
COCOA_LOG_FLOW(("%s: self=%p pView=%p (old=%p)\n", __PRETTY_FUNCTION__, (void *)self, (void *)pView, m_pParentView));
COCOA_LOG_FLOW(("%s: self=%p pWin=%p (old=%p)\n", __PRETTY_FUNCTION__, (void *)self, (void *)pWin, m_pOverlayWin));
COCOA_LOG_FLOW(("%s: self=%p returns %p\n", __PRETTY_FUNCTION__, (void *)self, (void *)m_pOverlayWin));
return m_pOverlayWin;
COCOA_LOG_FLOW(("%s: self=%p pos=%d,%d (old pos=%d,%d)\n", __PRETTY_FUNCTION__, (void *)self, (int)pos.x, (int)pos.y,
if (m_fEverSized)
COCOA_LOG_FLOW(("%s: self=%p pPos=%p (%d,%d) (old pos=%d,%d)\n", __PRETTY_FUNCTION__, (void *)self, pPos,
COCOA_LOG_FLOW(("%s: self=%p pos=%d,%d (old pos=%d,%d)\n", __PRETTY_FUNCTION__, (void *)self, (int)pos.x, (int)pos.y,
COCOA_LOG_FLOW(("%s: self=%p returns %d,%d\n", __PRETTY_FUNCTION__, (void *)self, (int)m_Pos.x, (int)m_Pos.y));
return m_Pos;
return m_fEverSized;
- (void)vboxDestroy
if (fIsMain)
if (fIsMain)
COCOA_LOG_FLOW(("%s: self=%p size=%d,%d\n", __PRETTY_FUNCTION__, (void *)self, (int)size.width, (int)size.height));
m_fEverSized = true;
DEBUG_MSG(("OVIW(%p): vboxSetSize: new size: %dx%d\n", (void *)self, (int)m_Size.width, (int)m_Size.height));
COCOA_LOG_FLOW(("%s: self=%p size=%d,%d\n", __PRETTY_FUNCTION__, (void *)self, (int)size.width, (int)size.height));
COCOA_LOG_FLOW(("%s: self=%p returns %d,%d\n", __PRETTY_FUNCTION__, (void *)self, (int)m_Size.width, (int)m_Size.height));
return m_Size;
- (void)updateViewportCS
- (void)vboxReshapeOnResizePerform
m_fNeedViewportUpdate = true;
m_fNeedCtxUpdate = false;
m_fNeedCtxUpdate = true;
- (void)vboxReshapeOnReparentPerform
- (void)vboxReshapePerform
COCOA_LOG_FLOW(("%s: self=%p - m_DockTileView=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)m_DockTileView));
DEBUG_MSG(("FIXED parentFrame [%f:%f], [%f:%f]\n", parentFrame.origin.x, parentFrame.origin.y, parentFrame.size.width, parentFrame.size.height));
DEBUG_MSG(("FIXED childFrame [%f:%f], [%f:%f]\n", childFrame.origin.x, childFrame.origin.y, childFrame.size.width, childFrame.size.height));
(void *)self, parentFrame.origin.x, parentFrame.origin.y, parentFrame.size.width, parentFrame.size.height));
(void *)self, childFrame.origin.x, childFrame.origin.y, childFrame.size.width, childFrame.size.height));
m_RootRect.origin.y = childFrame.size.height + childFrame.origin.y - (newFrame.size.height + newFrame.origin.y);
(void *)self, m_RootRect.origin.x, m_RootRect.origin.y, m_RootRect.size.width, m_RootRect.size.height));
printf ("sc rect: %d %d %d %d\n", (int) scrollRect.origin.x,(int) scrollRect.origin.y,(int) scrollRect.size.width,(int) scrollRect.size.height);
printf ("bound rect: %d %d %d %d\n", (int) b.origin.x,(int) b.origin.y,(int) b.size.width,(int) b.size.height);
if (m_pSharedGLCtx)
- (void)createDockTile
if (pDockScreen)
- (void)deleteDockTile
COCOA_LOG_FLOW(("%s: self=%p - m_DockTileView=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)m_DockTileView));
- (void)makeCurrentFBO
if (m_pGLCtx)
glFlush();
if (m_fNeedCtxUpdate == true)
m_fNeedCtxUpdate = false;
if (!m_FBOId)
if (m_pSharedGLCtx)
COCOA_LOG_FLOW(("%s: returns true (m_pSharedGLCtx=%p)\n", __PRETTY_FUNCTION__, (void *)m_pSharedGLCtx));
COCOA_LOG_FLOW(("%s: blitter (%p) created successfully for view 0x%p\n", (void *)m_pBlitter, (void *)self));
NSOpenGLContext *pSharedGLCtx = [[NSOpenGLContext alloc] initWithFormat:pPixelFormat shareContext:m_pGLCtx];
m_fNeedViewportUpdate = true;
COCOA_LOG_FLOW(("%s: returns true - new m_pSharedGLCtx=%p\n", __PRETTY_FUNCTION__, (void *)m_pSharedGLCtx));
- (void)vboxTryDraw
glFlush();
COCOA_LOG_FLOW(("%s: self=%p pParentView=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)pParentView));
COCOA_LOG_FLOW(("%s: self=%p pParentView=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)pParentView));
- (void)vboxTryDrawUI
COCOA_LOG_FLOW(("%s: returns - renderspuVBoxCompositorLock failed (%Rrc)\n", __PRETTY_FUNCTION__, rc));
if (pCompositor)
if (!m_pSharedGLCtx)
if (!pCompositor)
m_fCleanupNeeded = false;
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(vboxTryDrawUI) userInfo:nil repeats:NO];
- (void)swapFBO
COCOA_LOG_FLOW(("%s: self=%p - m_pGLCtx=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)m_pGLCtx));
COCOA_LOG_FLOW(("%s: self=%p pCompositor=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)pCompositor));
COCOA_LOG_FLOW(("%s: self=%p pCompositor=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)pCompositor));
COCOA_LOG_FLOW(("%s: Not current view of shared ctx! Switching... (self=%p, view=%p, m_pSharedGLCtx)\n",
m_fNeedViewportUpdate = true;
m_fNeedViewportUpdate = false;
m_fCleanupNeeded = false;
DECLINLINE(void) vboxNSRectToRectUnstretched(const NSRect *pR, RTRECT *pRect, float xStretch, float yStretch)
DECLINLINE(void) vboxNSRectToRectStretched(const NSRect *pR, RTRECT *pRect, float xStretch, float yStretch)
m_fDataVisible = false;
float xStretch;
float yStretch;
int rc = CrVrScrCompositorEntryRegionsGet(pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions, NULL);
uint32_t i;
CrBltBlitTexMural(m_pBlitter, true, CrTdTexGet(pTexData), pSrcRect, pDstRect, 1, fFlags | CRBLT_F_NOALPHA);
m_fDataVisible = true;
# endif
COCOA_LOG_FLOW(("%s: self=%p pChangedEntry=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)pChangedEntry));
- (void)vboxBlitterSyncWindow
NSRect r;
if (!m_pBlitter)
COCOA_LOG_FLOW(("%s: self=%p pCompositor=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)pCompositor));
float xStretch;
float yStretch;
glFlush();
int rc = CrVrScrCompositorEntryRegionsGet(pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions, NULL);
uint32_t i;
glFinish();
[[[NSApplication sharedApplication] dockTile] performSelectorOnMainThread:@selector(display) withObject:nil
- (void)clearVisibleRegions
if (m_paClipRects)
if (m_fDataVisible)
m_fCleanupNeeded = true;
return GL_TRUE;
return GL_FALSE;
COCOA_LOG_FLOW(("%s: self=%p cRects=%d paRects=%p\n", __PRETTY_FUNCTION__, (void *)self, cRects, (void *)paRects));
DEBUG_MSG_1(("OVIW(%p): setVisibleRegions: %d - %d %d %d %d\n", (void *)self, i, paRects[i * 4], paRects[i * 4 + 1], paRects[i * 4 + 2], paRects[i * 4 + 3]));
pScreenContent = [pContentView performSelector:@selector(screenContentWithParentView:) withObject:(id)m_pParentView];
COCOA_LOG_FLOW(("%s: returns %p (pContentView=%p)\n", __PRETTY_FUNCTION__, (void *)pScreenContent, (void *)pContentView));
return pScreenContent;
- (void)reshapeDockTile
NSRect newFrame = NSMakeRect ((int)roundf(m_Pos.x * m_FBOThumbScaleX), (int)roundf(dockFrame.size.height - (m_Pos.y + m_Size.height) * m_FBOThumbScaleY), (int)roundf(m_Size.width * m_FBOThumbScaleX), (int)roundf(m_Size.height * m_FBOThumbScaleY));
NSRect newFrame = NSMakeRect ((m_Pos.x * m_FBOThumbScaleX), (dockFrame.size.height - (m_Pos.y + m_Size.height) * m_FBOThumbScaleY), (m_Size.width * m_FBOThumbScaleX), (m_Size.height * m_FBOThumbScaleY));
printf ("%f %f %f %f - %f %f\n", newFrame.origin.x, newFrame.origin.y, newFrame.size.width, newFrame.size.height, m_Size.height, m_FBOThumbScaleY);
COCOA_LOG_FLOW(("%s: returns - newFrame={%d,%d %d,%d} pView=%d\n", __PRETTY_FUNCTION__, (int)newFrame.origin.x,
void cocoaGLCtxCreate(NativeNSOpenGLContextRef *ppCtx, GLbitfield fVisParams, NativeNSOpenGLContextRef pSharedCtx)
COCOA_LOG_FLOW(("cocoaGLCtxCreate: ppCtx=%p fVisParams=%#x pSharedCtx=%p\n", (void *)ppCtx, fVisParams, (void *)pSharedCtx));
# endif
if (pFmt)
if (pView)
return pView;
return NULL;
void cocoaViewCreate(NativeNSViewRef *ppView, WindowInfo *pWinInfo, NativeNSViewRef pParentView, GLbitfield fVisParams)
if (renderspuCalloutAvailable())
if (!*ppView)
COCOA_LOG_FLOW(("cocoaViewReparent: pView=%p pParentView=%p\n", (void *)pView, (void *)pParentView));
if (pOView)
COCOA_LOG_FLOW(("cocoaViewSetPosition: pView=%p pParentView=%p x=%d y=%d\n", (void *)pView, (void *)pParentView, x, y));
COCOA_LOG_FLOW(("vboxRcdGetGeomerty: (x,y)=(%d,%d) (cx,cy)=(%d,%d)\n", pGetGeometry->rect.origin.x, pGetGeometry->rect.origin.y,
if (renderspuCalloutAvailable())
COCOA_LOG_FLOW(("cocoaViewGetGeometry: returns *px=%d, *py=%d, *pcx=%d, *pcy=%d\n", *px, *py, *pcx, *pcy));
void cocoaViewPresentComposition(NativeNSViewRef pView, PCVBOXVR_SCR_COMPOSITOR_ENTRY pChangedEntry)
COCOA_LOG_FLOW(("cocoaViewPresentComposition: pView=%p pChangedEntry=%p\n", (void *)pView, (void *)pChangedEntry));
if (!pCtx)
if (!pCtxInfo)
if (pView)
return fNeedsPresent;
COCOA_LOG_FLOW(("cocoaViewSetVisibleRegion: pView=%p cRects=%d paRects=%p)\n", (void *)pView, cRects, (void const *)paRects));
VMSVGA3D_DECL(void) vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pSharedCtx)
VMSVGA3D_DECL(void) vmsvga3dCocoaViewSetPosition(NativeNSViewRef pView, NativeNSViewRef pParentView, int x, int y)
VMSVGA3D_DECL(void) vmsvga3dCocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx)
# endif