VirtualBox

Changeset 53599 in vbox


Ignore:
Timestamp:
Dec 22, 2014 11:50:11 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97362
Message:

cleanups.

Location:
trunk/src/VBox/Devices/Graphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.h

    r53206 r53599  
    2424RT_C_DECLS_BEGIN
    2525
     26#ifndef ___renderspu_cocoa_helper_h
    2627ADD_COCOA_NATIVE_REF(NSView);
    2728ADD_COCOA_NATIVE_REF(NSOpenGLContext);
     29#endif
    2830
    29 __attribute__ ((visibility("default"))) void vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pShareCtx);
    30 __attribute__ ((visibility("default"))) void vmsvga3dCocoaDestroyContext(NativeNSOpenGLContextRef pCtrx);
    31 __attribute__ ((visibility("default"))) void vmsvga3dCocoaCreateView(NativeNSViewRef *ppView, NativeNSViewRef pParentView);
    32 __attribute__ ((visibility("default"))) void vmsvga3dCocoaDestroyView(NativeNSViewRef pView);
    33 __attribute__ ((visibility("default"))) void vmsvga3dCocoaViewSetPosition(NativeNSViewRef pView, NativeNSViewRef pParentView, int x, int y);
    34 __attribute__ ((visibility("default"))) void vmsvga3dCocoaViewSetSize(NativeNSViewRef pView, int w, int h);
    35 __attribute__ ((visibility("default"))) void vmsvga3dCocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx);
    36 __attribute__ ((visibility("default"))) void vmsvga3dCocoaSwapBuffers(NativeNSOpenGLContextRef pCtx);
     31#ifdef IN_VMSVGA3D
     32# define VMSVGA3D_DECL(type)  DECLEXPORT(type)
     33#else
     34# define VMSVGA3D_DECL(type)  DECLIMPORT(type)
     35#endif
     36
     37VMSVGA3D_DECL(void) vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pSharedCtx);
     38VMSVGA3D_DECL(void) vmsvga3dCocoaDestroyContext(NativeNSOpenGLContextRef pCtx);
     39VMSVGA3D_DECL(void) vmsvga3dCocoaCreateView(NativeNSViewRef *ppView, NativeNSViewRef pParentView);
     40VMSVGA3D_DECL(void) vmsvga3dCocoaDestroyView(NativeNSViewRef pView);
     41VMSVGA3D_DECL(void) vmsvga3dCocoaViewSetPosition(NativeNSViewRef pView, NativeNSViewRef pParentView, int x, int y);
     42VMSVGA3D_DECL(void) vmsvga3dCocoaViewSetSize(NativeNSViewRef pView, int w, int h);
     43VMSVGA3D_DECL(void) vmsvga3dCocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx);
     44VMSVGA3D_DECL(void) vmsvga3dCocoaSwapBuffers(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx);
    3745
    3846RT_C_DECLS_END
    3947
    4048#endif /* !__DevVGA_SVGA3d_cocoa_h */
     49
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.m

    r53594 r53599  
    11/** @file
    2  * VirtualBox OpenGL Cocoa Window System Helper Implementation.
     2 * VirtualBox OpenGL Cocoa Window System Helper Implementation.
     3 * 
     4 * @remarks Inspired by HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m.
    35 */
    46
     
    2123#include <iprt/thread.h>
    2224
     25/* Debug macros */
     26#if 0 /*def DEBUG_VERBOSE*/
     27/*# error "should be disabled!"*/
     28# define DEBUG_INFO(text) do { \
     29        crWarning text ; \
     30        Assert(0); \
     31    } while (0)
     32
     33# define DEBUG_MSG(text) \
     34    printf text
     35
     36# define DEBUG_WARN(text) do { \
     37        crWarning text ; \
     38        Assert(0); \
     39    } while (0)
     40
     41# define DEBUG_MSG_1(text) \
     42    DEBUG_MSG(text)
     43
     44# define DEBUG_FUNC_ENTER() \
     45    int cchDebugFuncEnter = printf("==>%s\n", __PRETTY_FUNCTION__)
     46
     47#define DEBUG_FUNC_LEAVE() do { \
     48        DEBUG_MSG(("<==%s\n", __PRETTY_FUNCTION__)); \
     49    } while (0)
     50
     51#define DEBUG_FUNC_RET(valuefmtnl) do { \
     52        DEBUG_MSG(("<==%s returns", __PRETTY_FUNCTION__)); \
     53        DEBUG_MSG(valuefmtnl); \
     54    } while (0)
     55
     56#else
     57
     58# define DEBUG_INFO(text) do { \
     59        crInfo text ; \
     60    } while (0)
     61
    2362# define DEBUG_MSG(text) \
    2463    do {} while (0)
    25 #ifdef DEBUG_VERBOSE
    26 # define DEBUG_MSG_1(text) \
    27     DEBUG_MSG(text)
    28 #else
     64
     65# define DEBUG_WARN(text) do { \
     66        crWarning text ; \
     67    } while (0)
     68
    2969# define DEBUG_MSG_1(text) \
    3070    do {} while (0)
     71
     72# define DEBUG_FUNC_ENTER() int cchDebugFuncEnter = 0
     73# define DEBUG_FUNC_LEAVE() NOREF(cchDebugFuncEnter)
     74# define DEBUG_FUNC_RET(valuefmtnl) DEBUG_FUNC_LEAVE()
     75
    3176#endif
    3277
    3378# define CHECK_GL_ERROR()\
    3479    do {} while (0)
     80
    3581
    3682/** Custom OpenGL context class.
     
    56102    NSOpenGLContext *m_pGLCtx;
    57103   
    58     /* position/size */
     104    /* Position/Size tracking */
    59105    NSPoint          m_Pos;
    60106    NSSize           m_Size;
     
    122168-(id)initWithFormat:(NSOpenGLPixelFormat*)format shareContext:(NSOpenGLContext*)share
    123169{
     170    DEBUG_FUNC_ENTER();
     171
    124172    m_pPixelFormat = NULL;
    125173    m_pView = NULL;
     
    130178
    131179    DEBUG_MSG(("OCTX(%p): init VMSVGA3DOpenGLContext\n", (void*)self));
    132 
     180    DEBUG_FUNC_RET(("%p\n", (void *)self));
    133181    return self;
    134182}
     
    136184- (void)dealloc
    137185{
     186    DEBUG_FUNC_ENTER();
    138187    DEBUG_MSG(("OCTX(%p): dealloc VMSVGA3DOpenGLContext\n", (void*)self));
    139188
    140189    [m_pPixelFormat release];
    141190
     191m_pPixelFormat = NULL;
     192m_pView = NULL;
     193
    142194    [super dealloc];
     195    DEBUG_FUNC_LEAVE();
    143196}
    144197
    145198-(bool)isDoubleBuffer
    146199{
     200    DEBUG_FUNC_ENTER();
    147201    GLint val;
    148202    [m_pPixelFormat getValues:&val forAttribute:NSOpenGLPFADoubleBuffer forVirtualScreen:0];
     203    DEBUG_FUNC_RET(("%d\n", val == 1 ? YES : NO));
    149204    return val == 1 ? YES : NO;
    150205}
     
    152207-(void)setView:(NSView*)view
    153208{
     209    DEBUG_FUNC_ENTER();
    154210    DEBUG_MSG(("OCTX(%p): setView: new view: %p\n", (void*)self, (void*)view));
    155211
    156212    m_pView = view;
     213
     214    DEBUG_FUNC_LEAVE();
    157215}
    158216
    159217-(NSView*)view
    160218{
     219    DEBUG_FUNC_ENTER();
     220    DEBUG_FUNC_RET(("%p\n", (void *)m_pView));
    161221    return m_pView;
    162222}
     
    164224-(void)clearDrawable
    165225{
     226    DEBUG_FUNC_ENTER();
    166227    DEBUG_MSG(("OCTX(%p): clearDrawable\n", (void*)self));
    167228
    168     m_pView = NULL;;
     229    m_pView = NULL;
    169230    [super clearDrawable];
     231
     232    DEBUG_FUNC_LEAVE();
    170233}
    171234
    172235-(NSOpenGLPixelFormat*)openGLPixelFormat
    173236{
     237    DEBUG_FUNC_ENTER();
     238    DEBUG_FUNC_RET(("%p\n", (void *)m_pPixelFormat));
    174239    return m_pPixelFormat;
    175240}
     
    178243
    179244
    180 
    181 @implementation VMSVGA3DOverlayView
    182 
    183 - (id)initWithFrame:(NSRect) frame parentView:(NSView*)pParentView
    184 {
    185     m_pParentView    = pParentView;
    186     m_pGLCtx         = nil;
    187     m_Pos            = NSZeroPoint;
    188     m_Size           = NSMakeSize(1, 1);
    189     m_RootRect       = NSMakeRect(0, 0, m_Size.width, m_Size.height);
    190     m_yInvRootOffset = 0;
    191    
    192     self = [super initWithFrame: frame];
    193    
    194     return self;
    195 }
    196 
    197 - (void)setGLCtx:(NSOpenGLContext*)pCtx
    198 {
    199     if (m_pGLCtx == pCtx)
    200         return;
    201     if (m_pGLCtx)
    202         [m_pGLCtx clearDrawable];
    203     m_pGLCtx = pCtx;
    204 }
    205 
    206 - (NSOpenGLContext*)glCtx
    207 {
    208     return m_pGLCtx;
    209 }
    210 
    211 - (void)setOverlayWin:(NSWindow*)pWin
    212 {
    213     m_pOverlayWin = pWin;
    214 }
    215 
    216 - (NSWindow*)overlayWin
    217 {
    218     return m_pOverlayWin;
    219 }
    220 
    221 - (void)setPos:(NSPoint)pos
    222 {
    223     m_Pos = pos;
    224     [self reshape];
    225 }
    226 
    227 - (NSPoint)pos
    228 {
    229     return m_Pos;
    230 }
    231 
    232 - (void)setSize:(NSSize)size
    233 {
    234     m_Size = size;
    235     [self reshape];
    236 }
    237 
    238 - (NSSize)size
    239 {
    240     return m_Size;
    241 }
    242 
    243 - (void)updateViewportCS
    244 {
    245     DEBUG_MSG(("OVIW(%p): updateViewport\n", (void*)self));
    246 
    247     /* Update the viewport for our OpenGL view */
    248 /*    [m_pSharedGLCtx update]; */
    249        
    250     /* Clear background to transparent */
    251 //    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    252 }
    253 
    254 - (void)reshape
    255 {
    256     NSRect parentFrame = NSZeroRect;
    257     NSPoint parentPos  = NSZeroPoint;
    258     NSPoint childPos   = NSZeroPoint;
    259     NSRect childFrame  = NSZeroRect;
    260     NSRect newFrame    = NSZeroRect;
    261 
    262     DEBUG_MSG(("OVIW(%p): reshape\n", (void*)self));
    263 
    264     /* Getting the right screen coordinates of the parents frame is a little bit
    265      * complicated. */
    266     parentFrame = [m_pParentView frame];
    267     parentPos = [[m_pParentView window] convertBaseToScreen:[[m_pParentView superview] convertPointToBase:NSMakePoint(parentFrame.origin.x, parentFrame.origin.y + parentFrame.size.height)]];
    268     parentFrame.origin.x = parentPos.x;
    269     parentFrame.origin.y = parentPos.y;
    270 
    271     /* Calculate the new screen coordinates of the overlay window. */
    272     childPos = NSMakePoint(m_Pos.x, m_Pos.y + m_Size.height);
    273     childPos = [[m_pParentView window] convertBaseToScreen:[[m_pParentView superview] convertPointToBase:childPos]];
    274 
    275     /* Make a frame out of it. */
    276     childFrame = NSMakeRect(childPos.x, childPos.y, m_Size.width, m_Size.height);
    277 
    278     /* We have to make sure that the overlay window will not be displayed out
    279      * of the parent window. So intersect both frames & use the result as the new
    280      * frame for the window. */
    281     newFrame = NSIntersectionRect(parentFrame, childFrame);
    282 
    283     DEBUG_MSG(("[%#p]: parentFrame pos[%f : %f] size[%f : %f]\n",
    284           (void*)self,
    285          parentFrame.origin.x, parentFrame.origin.y,
    286          parentFrame.size.width, parentFrame.size.height));
    287     DEBUG_MSG(("[%#p]: childFrame pos[%f : %f] size[%f : %f]\n",
    288           (void*)self,
    289          childFrame.origin.x, childFrame.origin.y,
    290          childFrame.size.width, childFrame.size.height));
    291          
    292     DEBUG_MSG(("[%#p]: newFrame pos[%f : %f] size[%f : %f]\n",
    293           (void*)self,
    294          newFrame.origin.x, newFrame.origin.y,
    295          newFrame.size.width, newFrame.size.height));
    296    
    297     /* Later we have to correct the texture position in the case the window is
    298      * out of the parents window frame. So save the shift values for later use. */
    299     m_RootRect.origin.x = newFrame.origin.x - childFrame.origin.x;
    300     m_RootRect.origin.y =  childFrame.size.height + childFrame.origin.y - (newFrame.size.height + newFrame.origin.y);
    301     m_RootRect.size = newFrame.size;
    302     m_yInvRootOffset = newFrame.origin.y - childFrame.origin.y;
    303    
    304     DEBUG_MSG(("[%#p]: m_RootRect pos[%f : %f] size[%f : %f]\n",
    305          (void*)self,
    306          m_RootRect.origin.x, m_RootRect.origin.y,
    307          m_RootRect.size.width, m_RootRect.size.height));
    308 
    309     /* Set the new frame. */
    310     [[self window] setFrame:newFrame display:YES];
    311 
    312 #if 0
    313     /* Make sure the context is updated according */
    314     /* [self updateViewport]; */
    315     if (m_pSharedGLCtx)
    316     {
    317         VBOX_CR_RENDER_CTX_INFO CtxInfo;
    318         vboxCtxEnter(m_pSharedGLCtx, &CtxInfo);
    319    
    320         [self updateViewportCS];
    321    
    322         vboxCtxLeave(&CtxInfo);
    323     }
    324 #endif
    325 }
    326 
    327 @end
    328245
    329246/********************************************************************************
     
    336253-(id)initWithOverlayWindow:(VMSVGA3DOverlayWindow*)pOverlayWindow
    337254{
     255    DEBUG_FUNC_ENTER();
     256
    338257    self = [super initWithFrame:NSZeroRect];
    339258
    340259    m_pOverlayWindow = pOverlayWindow;
    341260
     261    DEBUG_MSG(("OHVW(%p): init OverlayHelperView\n", (void*)self));
     262    DEBUG_FUNC_RET(("%p\n", (void *)self));
    342263    return self;
    343264}
     
    345266-(void)viewDidMoveToWindow
    346267{
     268    DEBUG_FUNC_ENTER();
    347269    DEBUG_MSG(("OHVW(%p): viewDidMoveToWindow: new win: %p\n", (void*)self, (void*)[self window]));
    348270
    349271    [m_pOverlayWindow parentWindowChanged:[self window]];
     272
     273    DEBUG_FUNC_LEAVE();
    350274}
    351275
    352276@end
    353 
    354277
    355278/********************************************************************************
     
    362285- (id)initWithParentView:(NSView*)pParentView overlayView:(VMSVGA3DOverlayView*)pOverlayView
    363286{
     287    DEBUG_FUNC_ENTER();
    364288    NSWindow *pParentWin = nil;
    365289
     
    404328    }
    405329    DEBUG_MSG(("OWIN(%p): init OverlayWindow\n", (void*)self));
    406 
     330    DEBUG_FUNC_RET(("%p\n", (void *)self));
    407331    return self;
    408332}
     
    410334- (void)dealloc
    411335{
     336    DEBUG_FUNC_ENTER();
    412337    DEBUG_MSG(("OWIN(%p): dealloc OverlayWindow\n", (void*)self));
    413338
     
    418343
    419344    [super dealloc];
     345    DEBUG_FUNC_LEAVE();
    420346}
    421347
    422348- (void)parentWindowFrameChanged:(NSNotification*)pNote
    423349{
     350    DEBUG_FUNC_ENTER();
    424351    DEBUG_MSG(("OWIN(%p): parentWindowFrameChanged\n", (void*)self));
    425352
    426353    [m_pOverlayView reshape];
     354
     355    DEBUG_FUNC_LEAVE();
    427356}
    428357
    429358- (void)parentWindowChanged:(NSWindow*)pWindow
    430359{
     360    DEBUG_FUNC_ENTER();
    431361    DEBUG_MSG(("OWIN(%p): parentWindowChanged\n", (void*)self));
    432362
     
    445375        [m_pOverlayView reshape];
    446376    }
     377
     378    DEBUG_FUNC_LEAVE();
    447379}
    448380
    449381@end
    450382
     383/********************************************************************************
     384*
     385* VMSVGA3DOverlayView class implementation
     386*
     387********************************************************************************/
     388@implementation VMSVGA3DOverlayView
     389
     390- (id)initWithFrame:(NSRect) frame parentView:(NSView*)pParentView
     391{
     392    DEBUG_FUNC_ENTER();
     393
     394    m_pParentView    = pParentView;
     395    /* Make some reasonable defaults */
     396    m_pGLCtx         = nil;
     397    m_Pos            = NSZeroPoint;
     398    m_Size           = NSMakeSize(1, 1);
     399    m_RootRect       = NSMakeRect(0, 0, m_Size.width, m_Size.height);
     400    m_yInvRootOffset = 0;
     401   
     402    self = [super initWithFrame: frame];
     403   
     404    DEBUG_MSG(("OVIW(%p): init VMSVGA3DOverlayView\n", (void*)self));
     405    DEBUG_FUNC_RET(("%p\n", (void *)self));
     406    return self;
     407}
     408
     409- (void)cleanupData
     410{
     411    DEBUG_FUNC_ENTER();
     412
     413    /*[self deleteDockTile];*/
     414   
     415    [self setGLCtx:nil];
     416   
     417#if 0
     418    if (m_pSharedGLCtx)
     419    {
     420        if ([m_pSharedGLCtx view] == self)
     421            [m_pSharedGLCtx clearDrawable];
     422
     423        [m_pSharedGLCtx release];
     424
     425        m_pSharedGLCtx = nil;
     426       
     427        CrBltTerm(m_pBlitter);
     428       
     429        RTMemFree(m_pBlitter);
     430       
     431        m_pBlitter = nil;
     432    }
     433#endif
     434
     435    /*[self clearVisibleRegions];*/
     436   
     437    DEBUG_FUNC_LEAVE();
     438}
     439
     440- (void)dealloc
     441{
     442    DEBUG_FUNC_ENTER();
     443    DEBUG_MSG(("OVIW(%p): dealloc OverlayView\n", (void*)self));
     444
     445    [self cleanupData];
     446
     447    [super dealloc];
     448
     449    DEBUG_FUNC_LEAVE();
     450}
     451
     452
     453- (void)setGLCtx:(NSOpenGLContext*)pCtx
     454{
     455    DEBUG_FUNC_ENTER();
     456
     457    DEBUG_MSG(("OVIW(%p): setGLCtx: new ctx: %p (old: %p)\n", (void*)self, (void*)pCtx, (void *)m_pGLCtx));
     458    if (m_pGLCtx == pCtx)
     459    {
     460        DEBUG_FUNC_LEAVE();
     461        return;
     462    }
     463
     464    /* ensure the context drawable is cleared to avoid holding a reference to inexistent view */
     465    if (m_pGLCtx)
     466    {
     467        [m_pGLCtx clearDrawable];
     468        [m_pGLCtx release];
     469        /*[m_pGLCtx performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];*/
     470    }
     471    m_pGLCtx = pCtx;
     472    if (pCtx)
     473        [pCtx retain];
     474
     475    DEBUG_FUNC_LEAVE();
     476}
     477
     478- (NSOpenGLContext*)glCtx
     479{
     480    DEBUG_FUNC_ENTER();
     481    DEBUG_FUNC_RET(("%p\n", (void *)m_pGLCtx));
     482    return m_pGLCtx;
     483}
     484
     485- (void)setOverlayWin:(NSWindow*)pWin
     486{
     487    DEBUG_FUNC_ENTER();
     488    DEBUG_MSG(("OVIW(%p): setOverlayWin: new win: %p\n", (void*)self, (void*)pWin));
     489    m_pOverlayWin = pWin;
     490    DEBUG_FUNC_LEAVE();
     491}
     492
     493- (NSWindow*)overlayWin
     494{
     495    DEBUG_FUNC_ENTER();
     496    DEBUG_FUNC_RET(("%p\n", (void *)m_pOverlayWin));
     497    return m_pOverlayWin;
     498}
     499
     500- (void)setPos:(NSPoint)pos
     501{
     502    DEBUG_FUNC_ENTER();
     503
     504    m_Pos = pos;
     505    [self reshape];
     506    DEBUG_FUNC_LEAVE();
     507}
     508
     509- (NSPoint)pos
     510{
     511    DEBUG_FUNC_ENTER();
     512    DEBUG_FUNC_RET(("%f,%f\n", m_Pos.x, m_Pos.y));
     513    return m_Pos;
     514}
     515
     516- (void)setSize:(NSSize)size
     517{
     518    DEBUG_FUNC_ENTER();
     519    m_Size = size;
     520    [self reshape];
     521    DEBUG_FUNC_LEAVE();
     522}
     523
     524- (NSSize)size
     525{
     526    DEBUG_FUNC_ENTER();
     527    DEBUG_FUNC_RET(("%f,%f\n", m_Size.width, m_Size.height));
     528    return m_Size;
     529}
     530
     531- (void)updateViewportCS
     532{
     533    DEBUG_FUNC_ENTER();
     534    DEBUG_MSG(("OVIW(%p): updateViewport\n", (void*)self));
     535
     536    /* Update the viewport for our OpenGL view */
     537/*    [m_pSharedGLCtx update]; */
     538       
     539    /* Clear background to transparent */
     540/*    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);*/
     541    DEBUG_FUNC_LEAVE();
     542}
     543
     544- (void)reshape
     545{
     546    DEBUG_FUNC_ENTER();
     547    NSRect parentFrame = NSZeroRect;
     548    NSPoint parentPos  = NSZeroPoint;
     549    NSPoint childPos   = NSZeroPoint;
     550    NSRect childFrame  = NSZeroRect;
     551    NSRect newFrame    = NSZeroRect;
     552
     553    DEBUG_MSG(("OVIW(%p): reshape\n", (void*)self));
     554
     555    /* Getting the right screen coordinates of the parents frame is a little bit
     556     * complicated. */
     557    parentFrame = [m_pParentView frame];
     558    DEBUG_MSG(("FIXED parentFrame [%f:%f], [%f:%f]\n", parentFrame.origin.x, parentFrame.origin.y, parentFrame.size.width, parentFrame.size.height));   
     559    parentPos = [[m_pParentView window] convertBaseToScreen:[[m_pParentView superview] convertPointToBase:NSMakePoint(parentFrame.origin.x, parentFrame.origin.y + parentFrame.size.height)]];
     560    parentFrame.origin.x = parentPos.x;
     561    parentFrame.origin.y = parentPos.y;
     562
     563    /* Calculate the new screen coordinates of the overlay window. */
     564    childPos = NSMakePoint(m_Pos.x, m_Pos.y + m_Size.height);
     565    childPos = [[m_pParentView window] convertBaseToScreen:[[m_pParentView superview] convertPointToBase:childPos]];
     566    DEBUG_MSG(("FIXED childPos(screen) [%f:%f]\n", childPos.x, childPos.y));
     567
     568    /* Make a frame out of it. */
     569    childFrame = NSMakeRect(childPos.x, childPos.y, m_Size.width, m_Size.height);
     570    DEBUG_MSG(("FIXED childFrame [%f:%f], [%f:%f]\n", childFrame.origin.x, childFrame.origin.y, childFrame.size.width, childFrame.size.height));
     571
     572    /* We have to make sure that the overlay window will not be displayed out
     573     * of the parent window. So intersect both frames & use the result as the new
     574     * frame for the window. */
     575    newFrame = NSIntersectionRect(parentFrame, childFrame);
     576
     577    DEBUG_MSG(("[%p]: parentFrame pos[%f : %f] size[%f : %f]\n",
     578          (void*)self,
     579         parentFrame.origin.x, parentFrame.origin.y,
     580         parentFrame.size.width, parentFrame.size.height));
     581    DEBUG_MSG(("[%p]: childFrame pos[%f : %f] size[%f : %f]\n",
     582          (void*)self,
     583         childFrame.origin.x, childFrame.origin.y,
     584         childFrame.size.width, childFrame.size.height));
     585         
     586    DEBUG_MSG(("[%p]: newFrame pos[%f : %f] size[%f : %f]\n",
     587          (void*)self,
     588         newFrame.origin.x, newFrame.origin.y,
     589         newFrame.size.width, newFrame.size.height));
     590   
     591    /* Later we have to correct the texture position in the case the window is
     592     * out of the parents window frame. So save the shift values for later use. */
     593    m_RootRect.origin.x = newFrame.origin.x - childFrame.origin.x;
     594    m_RootRect.origin.y =  childFrame.size.height + childFrame.origin.y - (newFrame.size.height + newFrame.origin.y);
     595    m_RootRect.size = newFrame.size;
     596    m_yInvRootOffset = newFrame.origin.y - childFrame.origin.y;
     597   
     598    DEBUG_MSG(("[%p]: m_RootRect pos[%f : %f] size[%f : %f]\n",
     599         (void*)self,
     600         m_RootRect.origin.x, m_RootRect.origin.y,
     601         m_RootRect.size.width, m_RootRect.size.height));
     602
     603    /* Set the new frame. */
     604    [[self window] setFrame:newFrame display:YES];
     605
     606#if 0
     607    /* Make sure the context is updated according */
     608    /* [self updateViewport]; */
     609    if (m_pSharedGLCtx)
     610    {
     611        VBOX_CR_RENDER_CTX_INFO CtxInfo;
     612        vboxCtxEnter(m_pSharedGLCtx, &CtxInfo);
     613   
     614        [self updateViewportCS];
     615   
     616        vboxCtxLeave(&CtxInfo);
     617    }
     618#endif
     619    DEBUG_FUNC_LEAVE();
     620}
     621
     622@end
     623
    451624
    452625void vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pShareCtx)
    453626{
     627    DEBUG_FUNC_ENTER();
    454628    NSOpenGLPixelFormat *pFmt = nil;
    455 
    456629    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    457630
     
    487660    {
    488661        *ppCtx = [[VMSVGA3DOpenGLContext alloc] initWithFormat:pFmt shareContext:pShareCtx];
    489         DEBUG_MSG(("New context %X\n", (uint)*ppCtx));
     662        DEBUG_MSG(("New context %p\n", (void *)*ppCtx));
    490663    }
    491664
    492665    [pPool release];
     666
     667    DEBUG_FUNC_LEAVE();
    493668}
    494669
    495670void vmsvga3dCocoaDestroyContext(NativeNSOpenGLContextRef pCtx)
    496671{
     672    DEBUG_FUNC_ENTER();
    497673    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    498674    [pCtx release];
    499675    [pPool release];
     676    DEBUG_FUNC_LEAVE();
    500677}
    501678
    502679void vmsvga3dCocoaCreateView(NativeNSViewRef *ppView, NativeNSViewRef pParentView)
    503680{
     681    DEBUG_FUNC_ENTER();
    504682    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    505683   
     
    516694   
    517695    [pPool release];
     696    DEBUG_FUNC_LEAVE();
    518697}
    519698
    520699void vmsvga3dCocoaDestroyView(NativeNSViewRef pView)
    521700{
     701    DEBUG_FUNC_ENTER();
    522702    NSWindow *pWin = nil;
    523703   
     
    527707    [pWin release];
    528708    [pView release];
     709
    529710    [pPool release];
     711    DEBUG_FUNC_LEAVE();
    530712}
    531713
    532714void vmsvga3dCocoaViewSetPosition(NativeNSViewRef pView, NativeNSViewRef pParentView, int x, int y)
    533715{
     716    DEBUG_FUNC_ENTER();
    534717    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    535718
     
    541724void vmsvga3dCocoaViewSetSize(NativeNSViewRef pView, int w, int h)
    542725{
     726    DEBUG_FUNC_ENTER();
    543727    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    544728
     
    546730
    547731    [pPool release];
     732    DEBUG_FUNC_LEAVE();
    548733}
    549734
    550735void vmsvga3dCocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx)
    551736{
     737    DEBUG_FUNC_ENTER();
    552738    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    553739
     
    557743    {
    558744        [(VMSVGA3DOverlayView*)pView setGLCtx:pCtx];
    559 //        [(VMSVGA3DOverlayView*)pView makeCurrentFBO];
     745/*        [(VMSVGA3DOverlayView*)pView makeCurrentFBO];*/
    560746        [pCtx makeCurrentContext];
    561747    }
     
    566752
    567753    [pPool release];
    568 }
    569 
    570 void vmsvga3dCocoaSwapBuffers(NativeNSOpenGLContextRef pCtx)
    571 {
     754    DEBUG_FUNC_LEAVE();
     755}
     756
     757void vmsvga3dCocoaSwapBuffers(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx)
     758{
     759    DEBUG_FUNC_ENTER();
    572760    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    573761   
     
    575763   
    576764    [pPool release];
    577 }
     765    DEBUG_FUNC_LEAVE();
     766}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette