renderspu_cocoa_helper.m revision 7074f3e946d7b357b16868ba5f9fd656ec1f158f
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * VirtualBox OpenGL Cocoa Window System Helper implementation
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * available from http://www.virtualbox.org. This file is free software;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * you can redistribute it and/or modify it under the terms of the GNU
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * General Public License (GPL) as published by the Free Software
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * additional information or have any questions.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "chromium.h" /* For the visual bits of chromium */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/* Debug macros */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define FBO 1 /* Disable this to see how the output is without the FBO in the middle of the processing chain. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync//#define SHOW_WINDOW_BACKGROUND 1 /* Define this to see the window background even if the window is clipped */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync//#define DEBUG_VERBOSE /* Define this could get some debug info about the messages flow. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync do {} while (0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync do {} while (0)
if (g != GL_NO_ERROR)
char *errStr;
glPushMatrix(); \
glPushMatrix(); \
glPushMatrix(); \
glPushMatrix(); \
glPopMatrix(); \
glPopMatrix(); \
glPopMatrix(); \
glPopMatrix(); \
glPopClientAttrib(); \
glPopAttrib(); \
@end
@class DockOverlayView;
- (void)updateViewport;
- (void)reshape;
- (void)createFBO;
- (void)deleteFBO;
- (void)updateFBO;
- (void)makeCurrentFBO;
- (void)swapFBO;
- (void)flushFBO;
- (void)finishFBO;
- (void)bindFBO;
- (void)renderFBOToView;
- (void)clearVisibleRegions;
- (void)reshapeDockTile;
@end
* fullscreen/seamless entry/exit) the overlay window is informed & can add
@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;
@end;
return self;
-(void)viewDidMoveToWindow
@end
if(self = [super initWithContentRect:NSZeroRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO])
return self;
- (void)dealloc
[super dealloc];
// [m_pOverlayView performSelector:@selector(reshape) onThread:m_Thread withObject:nil waitUntilDone:YES];
// [NSTimer scheduledTimerWithTimeInterval:0.2 target:m_pOverlayView selector:@selector(reshape) userInfo:nil repeats:NO];
@end
return self;
- (void)dealloc
if (m_pGLCtx)
if (m_pSharedGLCtx)
[super dealloc];
return m_pGLCtx;
return m_pParentView;
return m_pOverlayWin;
return m_Pos;
return m_Size;
- (void)updateViewport
if (m_pSharedGLCtx)
- (void)reshape
NSPoint parentPos = [[m_pParentView window] convertBaseToScreen:[[m_pParentView superview] convertPointToBase:NSMakePoint(parentFrame.origin.x, parentFrame.origin.y + parentFrame.size.height)]];
childPos = [[m_pParentView window] convertBaseToScreen:[[m_pParentView superview] convertPointToBase:childPos]];
// 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);
- (void)createFBO
if (!m_FBOId)
if (!isFBO)
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, m_FBOTexSize.width, m_FBOTexSize.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, m_FBOTexId, 0);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL_EXT, m_FBOTexSize.width, m_FBOTexSize.height);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_FBODepthStencilPackedId);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_FBODepthStencilPackedId);
if (dockScreen)
if (!m_FBOThumbId)
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, m_FBOTexSize.width * m_FBOThumbScaleX, m_FBOTexSize.height * m_FBOThumbScaleY, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, m_FBOThumbTexId, 0);
- (void)deleteFBO
- (void)updateFBO
if (m_pGLCtx)
- (void)makeCurrentFBO
if (m_pGLCtx)
glFlush();
- (void)swapFBO
glFlush();
- (void)flushFBO
glFlush();
- (void)finishFBO
glFinish();
- (void)bindFBO
- (void)renderFBOToView
if (!m_pSharedGLCtx)
m_pSharedGLCtx = [[NSOpenGLContext alloc] initWithFormat:[(OverlayOpenGLContext*)m_pGLCtx openGLPixelFormat] shareContext:m_pGLCtx];
if (m_pSharedGLCtx)
glFlush();
GLint i;
glEnd();
glFinish();
[[[NSApplication sharedApplication] dockTile] performSelectorOnMainThread:@selector(display) withObject:nil waitUntilDone:NO];
GLint i;
glEnd();
glFinish();
- (void)clearVisibleRegions
if(m_paClipRects)
screenContent = [contentView performSelector:@selector(screenContentWithParentView:) withObject:(id)m_pParentView];
return screenContent;
- (void)reshapeDockTile
NSRect newFrame = NSMakeRect ((int)(m_Pos.x * m_FBOThumbScaleX), (int)(dockFrame.size.height - (m_Pos.y + m_Size.height - m_RootShift.y) * m_FBOThumbScaleY), (int)(m_Size.width * m_FBOThumbScaleX), (int)(m_Size.height * m_FBOThumbScaleY));
// 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);
@end
if (pFmt)
OverlayView* pView = [[OverlayView alloc] initWithFrame:NSZeroRect thread:RTThreadSelf() parentView:pParentView];
if (pView)
if (pOView)
void cocoaFlush()
if (pCtx)
if (pView)
glFlush();
void cocoaFinish()
if (pCtx)
if (pView)
glFinish();
if (pCtx)
if (pView)