VirtualBox

Ignore:
Timestamp:
Aug 20, 2014 11:58:38 AM (10 years ago)
Author:
vboxsync
Message:

crOpenGL: 1. osx: do everything we can do in the main thread 2. bugfixes

Location:
trunk/src/VBox/HostServices/SharedOpenGL/render
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c

    r52368 r52429  
    14441444}
    14451445
     1446bool renderspuCalloutAvailable()
     1447{
     1448    return render_spu.pfnClientCallout != NULL;
     1449}
     1450
     1451bool renderspuCalloutClient(PFNVCRSERVER_CLIENT_CALLOUT_CB pfnCb, void *pvCb)
     1452{
     1453    if (render_spu.pfnClientCallout)
     1454    {
     1455        pfnCb(pvCb);
     1456        return true;
     1457    }
     1458    return false;
     1459}
    14461460
    14471461static void RENDER_APIENTRY
     
    14551469
    14561470    switch (target) {
    1457 
     1471        case GL_HH_SET_CLIENT_CALLOUT:
     1472            render_spu.pfnClientCallout = (PFNVCRSERVER_CLIENT_CALLOUT)values;
     1473            break;
    14581474        case GL_GATHER_CONNECT_CR:
    14591475            if (render_spu.gather_userbuf_size)
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h

    r51442 r52429  
    219219#endif
    220220
     221typedef DECLCALLBACKPTR(void, PFNVCRSERVER_CLIENT_CALLOUT_CB)(void *pvCb);
     222typedef DECLCALLBACKPTR(void, PFNVCRSERVER_CLIENT_CALLOUT)(PFNVCRSERVER_CLIENT_CALLOUT_CB pfnCb, void*pvCb);
     223
     224
    221225/**
    222226 * Renderspu state info
     
    287291    SPUDispatchTable blitterDispatch;
    288292    CRHashTable *blitterTable;
     293
     294    PFNVCRSERVER_CLIENT_CALLOUT pfnClientCallout;
    289295
    290296#ifdef USE_OSMESA
     
    454460uint32_t renderspuContextRetain(ContextInfo *context);
    455461
     462bool renderspuCalloutAvailable();
     463bool renderspuCalloutClient(PFNVCRSERVER_CLIENT_CALLOUT_CB pfnCb, void *pvCb);
     464
     465
    456466#ifdef __cplusplus
    457467extern "C" {
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r52398 r52429  
    115115#endif
    116116
     117#define DEBUG_FUNC_ENTER() do { \
     118        DEBUG_MSG(("==>%s\n", __PRETTY_FUNCTION__)); \
     119    } while (0)
     120   
     121#define DEBUG_FUNC_LEAVE() do { \
     122        DEBUG_MSG(("<==%s\n", __PRETTY_FUNCTION__)); \
     123    } while (0)
     124
     125
    117126#ifdef DEBUG_poetzsch
    118127# define CHECK_GL_ERROR()\
     
    361370- (NSWindow*)overlayWin;
    362371
    363 - (void)setPos:(NSPoint)pos;
     372- (void)vboxSetPos:(NSPoint)pos;
     373- (void)vboxSetPosUI:(NSPoint)pos;
     374- (void)vboxSetPosUIObj:(NSValue*)pPos;
    364375- (NSPoint)pos;
    365376- (bool)isEverSized;
    366 - (void)setSize:(NSSize)size;
     377- (void)vboxDestroy;
     378- (void)vboxSetSizeUI:(NSSize)size;
     379- (void)vboxSetSizeUIObj:(NSValue*)pSize;
     380- (void)vboxSetSize:(NSSize)size;
    367381- (NSSize)size;
    368382- (void)updateViewportCS;
     
    376390- (void)makeCurrentFBO;
    377391- (void)swapFBO;
    378 - (void)vboxSubmitVisible:(GLboolean)fVisible;
    379 - (void)vboxSetVisibleUI;
    380 - (void)vboxSetHiddenUI;
     392- (void)vboxSetVisible:(GLboolean)fVisible;
     393- (void)vboxSetVisibleUIObj:(NSNumber*)pVisible;
     394- (void)vboxSetVisibleUI:(GLboolean)fVisible;
    381395- (void)vboxTryDraw;
    382396- (void)vboxTryDrawUI;
     397- (void)vboxReparent:(NSView*)pParentView;
     398- (void)vboxReparentUI:(NSView*)pParentView;
    383399- (void)vboxPresent:(const VBOXVR_SCR_COMPOSITOR*)pCompositor;
    384400- (void)vboxPresentCS:(const VBOXVR_SCR_COMPOSITOR*)pCompositor;
     
    451467- (id)init
    452468{
     469    DEBUG_FUNC_ENTER();
    453470    self = [super init];
    454471
     
    461478    }
    462479
     480    DEBUG_FUNC_LEAVE();
     481   
    463482    return self;
    464483}
     
    466485- (void)dealloc
    467486{
     487    DEBUG_FUNC_ENTER();
     488   
    468489    [self cleanup];
    469490    [m_Lock release];
    470491
    471492    [super dealloc];
     493   
     494    DEBUG_FUNC_LEAVE();
    472495}
    473496
    474497- (void)cleanup
    475498{
     499    DEBUG_FUNC_ENTER();
     500   
    476501    if (m_ThumbImage != nil)
    477502    {
     
    484509        m_ThumbBitmap = nil;
    485510    }
     511   
     512    DEBUG_FUNC_LEAVE();
    486513}
    487514
    488515- (void)lock
    489516{
     517    DEBUG_FUNC_ENTER();
    490518    [m_Lock lock];
     519    DEBUG_FUNC_LEAVE();
    491520}
    492521
    493522- (void)unlock
    494523{
     524    DEBUG_FUNC_ENTER();
    495525    [m_Lock unlock];
     526    DEBUG_FUNC_LEAVE();
    496527}
    497528
    498529- (void)setFrame:(NSRect)frame
    499530{
     531    DEBUG_FUNC_ENTER();
    500532    [super setFrame:frame];
    501533
     
    522554    }
    523555    [self unlock];
     556    DEBUG_FUNC_LEAVE();
    524557}
    525558
    526559- (BOOL)isFlipped
    527560{
     561    DEBUG_FUNC_ENTER();
     562    DEBUG_FUNC_LEAVE();
    528563    return YES;
    529564}
     
    531566- (void)drawRect:(NSRect)aRect
    532567{
     568    DEBUG_FUNC_ENTER();
    533569    NSRect frame;
    534570
     
    542578        [m_ThumbImage drawAtPoint:NSMakePoint(0, 0) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
    543579    [self unlock];
     580    DEBUG_FUNC_LEAVE();
    544581}
    545582
    546583- (NSBitmapImageRep*)thumbBitmap
    547584{
     585    DEBUG_FUNC_ENTER();
     586    DEBUG_FUNC_LEAVE();
    548587    return m_ThumbBitmap;
    549588}
     
    551590- (NSImage*)thumbImage
    552591{
     592    DEBUG_FUNC_ENTER();
     593    DEBUG_FUNC_LEAVE();
     594
    553595    return m_ThumbImage;
    554596}
     
    564606-(id)initWithFormat:(NSOpenGLPixelFormat*)format shareContext:(NSOpenGLContext*)share
    565607{
     608    DEBUG_FUNC_ENTER();
     609
    566610    m_pPixelFormat = NULL;
    567611    m_pView = NULL;
     
    573617    DEBUG_MSG(("OCTX(%p): init OverlayOpenGLContext\n", (void*)self));
    574618
     619    DEBUG_FUNC_LEAVE();
     620
    575621    return self;
    576622}
     
    578624- (void)dealloc
    579625{
     626    DEBUG_FUNC_ENTER();
     627
    580628    DEBUG_MSG(("OCTX(%p): dealloc OverlayOpenGLContext\n", (void*)self));
    581629
     
    583631
    584632    [super dealloc];
     633   
     634    DEBUG_FUNC_LEAVE();
    585635}
    586636
    587637-(bool)isDoubleBuffer
    588638{
     639    DEBUG_FUNC_ENTER();
     640
    589641    GLint val;
    590642    [m_pPixelFormat getValues:&val forAttribute:NSOpenGLPFADoubleBuffer forVirtualScreen:0];
     643   
     644    DEBUG_FUNC_LEAVE();
     645   
    591646    return val == GL_TRUE ? YES : NO;
    592647}
     
    594649-(void)setView:(NSView*)view
    595650{
     651    DEBUG_FUNC_ENTER();
     652
    596653    DEBUG_MSG(("OCTX(%p): setView: new view: %p\n", (void*)self, (void*)view));
    597654
     
    601658    [super setView: view];
    602659#endif
     660
     661    DEBUG_FUNC_LEAVE();
    603662}
    604663
    605664-(NSView*)view
    606665{
     666    DEBUG_FUNC_ENTER();
     667    DEBUG_FUNC_LEAVE();
     668
    607669#if 1 /* def FBO */
    608670    return m_pView;
     
    614676-(void)clearDrawable
    615677{
     678    DEBUG_FUNC_ENTER();
     679
    616680    DEBUG_MSG(("OCTX(%p): clearDrawable\n", (void*)self));
    617681
    618682    m_pView = NULL;;
    619683    [super clearDrawable];
     684   
     685    DEBUG_FUNC_LEAVE();
    620686}
    621687
    622688-(NSOpenGLPixelFormat*)openGLPixelFormat
    623689{
     690    DEBUG_FUNC_ENTER();
     691    DEBUG_FUNC_LEAVE();
     692
    624693    return m_pPixelFormat;
    625694}
     
    636705-(id)initWithOverlayWindow:(OverlayWindow*)pOverlayWindow
    637706{
     707    DEBUG_FUNC_ENTER();
     708
    638709    self = [super initWithFrame:NSZeroRect];
    639710
     
    642713    DEBUG_MSG(("OHVW(%p): init OverlayHelperView\n", (void*)self));
    643714
     715    DEBUG_FUNC_LEAVE();
     716
    644717    return self;
    645718}
     
    647720-(void)viewDidMoveToWindow
    648721{
     722    DEBUG_FUNC_ENTER();
     723
    649724    DEBUG_MSG(("OHVW(%p): viewDidMoveToWindow: new win: %p\n", (void*)self, (void*)[self window]));
    650725
    651726    [m_pOverlayWindow parentWindowChanged:[self window]];
     727   
     728    DEBUG_FUNC_LEAVE();
    652729}
    653730
     
    663740- (id)initWithParentView:(NSView*)pParentView overlayView:(OverlayView*)pOverlayView
    664741{
     742    DEBUG_FUNC_ENTER();
     743
    665744    NSWindow *pParentWin = nil;
    666745
     
    706785    DEBUG_MSG(("OWIN(%p): init OverlayWindow\n", (void*)self));
    707786
     787    DEBUG_FUNC_LEAVE();
     788
    708789    return self;
    709790}
     
    711792- (void)dealloc
    712793{
     794    DEBUG_FUNC_ENTER();
     795
    713796    DEBUG_MSG(("OWIN(%p): dealloc OverlayWindow\n", (void*)self));
    714797
     
    719802
    720803    [super dealloc];
     804   
     805    DEBUG_FUNC_LEAVE();
    721806}
    722807
    723808- (void)parentWindowFrameChanged:(NSNotification*)pNote
    724809{
     810    DEBUG_FUNC_ENTER();
     811
    725812    DEBUG_MSG(("OWIN(%p): parentWindowFrameChanged\n", (void*)self));
    726813
     
    738825            [self performSelectorOnMainThread:@selector(vboxReshapePerform) withObject:nil waitUntilDone:NO];
    739826    }
     827   
     828    DEBUG_FUNC_LEAVE();
    740829}
    741830
    742831- (void)parentWindowChanged:(NSWindow*)pWindow
    743832{
     833    DEBUG_FUNC_ENTER();
     834
    744835    DEBUG_MSG(("OWIN(%p): parentWindowChanged\n", (void*)self));
    745836
     
    771862        }       
    772863    }
     864   
     865    DEBUG_FUNC_LEAVE();
    773866}
    774867
     
    784877- (id)initWithFrame:(NSRect)frame thread:(RTTHREAD)aThread parentView:(NSView*)pParentView winInfo:(WindowInfo*)pWinInfo
    785878{
     879    DEBUG_FUNC_ENTER();
     880
    786881    m_pParentView             = pParentView;
    787882    /* Make some reasonable defaults */
     
    808903    DEBUG_MSG(("OVIW(%p): init OverlayView\n", (void*)self));
    809904
     905    DEBUG_FUNC_LEAVE();
     906
    810907    return self;
    811908}
     
    813910- (void)cleanupData
    814911{
     912    DEBUG_FUNC_ENTER();
     913
    815914    [self deleteDockTile];
    816915   
     
    834933
    835934    [self clearVisibleRegions];
     935   
     936    DEBUG_FUNC_LEAVE();
    836937}
    837938
    838939- (void)dealloc
    839940{
     941    DEBUG_FUNC_ENTER();
     942
    840943    DEBUG_MSG(("OVIW(%p): dealloc OverlayView\n", (void*)self));
    841944
     
    843946
    844947    [super dealloc];
     948
     949    DEBUG_FUNC_LEAVE();
    845950}
    846951
     
    852957- (void)setGLCtx:(NSOpenGLContext*)pCtx
    853958{
     959    DEBUG_FUNC_ENTER();
     960
    854961    DEBUG_MSG(("OVIW(%p): setGLCtx: new ctx: %p\n", (void*)self, (void*)pCtx));
    855962    if (m_pGLCtx == pCtx)
     963    {
     964        DEBUG_FUNC_LEAVE();
    856965        return;
     966    }
    857967
    858968    /* ensure the context drawable is cleared to avoid holding a reference to inexistent view */
     
    867977    if (pCtx)
    868978        [pCtx retain];
     979       
     980    DEBUG_FUNC_LEAVE();
    869981}
    870982
    871983- (NSOpenGLContext*)glCtx
    872984{
     985    DEBUG_FUNC_ENTER();
     986    DEBUG_FUNC_LEAVE();
     987
    873988    return m_pGLCtx;
    874989}
     
    876991- (NSView*)parentView
    877992{
     993    DEBUG_FUNC_ENTER();
     994    DEBUG_FUNC_LEAVE();
     995
    878996    return m_pParentView;
    879997}
     
    881999- (void)setParentView:(NSView*)pView
    8821000{
     1001    DEBUG_FUNC_ENTER();
     1002
    8831003    DEBUG_MSG(("OVIW(%p): setParentView: new view: %p\n", (void*)self, (void*)pView));
    8841004
    8851005    m_pParentView = pView;
     1006   
     1007    DEBUG_FUNC_LEAVE();
    8861008}
    8871009
    8881010- (void)setOverlayWin:(NSWindow*)pWin
    8891011{
     1012    DEBUG_FUNC_ENTER();
     1013
    8901014    DEBUG_MSG(("OVIW(%p): setOverlayWin: new win: %p\n", (void*)self, (void*)pWin));
    8911015
    8921016    m_pOverlayWin = pWin;
     1017   
     1018    DEBUG_FUNC_LEAVE();
    8931019}
    8941020
    8951021- (NSWindow*)overlayWin
    8961022{
     1023    DEBUG_FUNC_ENTER();
     1024    DEBUG_FUNC_LEAVE();
     1025
    8971026    return m_pOverlayWin;
    8981027}
    8991028
    900 - (void)setPos:(NSPoint)pos
    901 {
    902     DEBUG_MSG(("OVIW(%p): setPos: new pos: %d, %d\n", (void*)self, (int)pos.x, (int)pos.y));
     1029- (void)vboxSetPosUI:(NSPoint)pos
     1030{
     1031    DEBUG_FUNC_ENTER();
    9031032
    9041033    m_Pos = pos;
    9051034
    9061035    if (m_fEverSized)
    907         [self performSelectorOnMainThread:@selector(vboxReshapePerform) withObject:nil waitUntilDone:NO];
     1036        [self vboxReshapePerform];
     1037       
     1038    DEBUG_FUNC_LEAVE();
     1039}
     1040
     1041- (void)vboxSetPosUIObj:(NSValue*)pPos
     1042{
     1043    DEBUG_FUNC_ENTER();
     1044
     1045    NSPoint pos = [pPos pointValue];
     1046    [self vboxSetPosUI:pos];
     1047    [pPos release];
     1048
     1049    DEBUG_FUNC_LEAVE();
     1050}
     1051
     1052typedef struct CR_RCD_SETPOS
     1053{
     1054    OverlayView *pView;
     1055    NSPoint pos;
     1056} CR_RCD_SETPOS;
     1057
     1058static DECLCALLBACK(void) vboxRcdSetPos(void *pvCb)
     1059{
     1060    DEBUG_FUNC_ENTER();
     1061
     1062    CR_RCD_SETPOS * pReparent = (CR_RCD_SETPOS*)pvCb;
     1063    [pReparent->pView vboxSetPosUI:pReparent->pos];
     1064
     1065    DEBUG_FUNC_LEAVE();
     1066}
     1067
     1068- (void)vboxSetPos:(NSPoint)pos
     1069{
     1070    DEBUG_FUNC_ENTER();
     1071
     1072    DEBUG_MSG(("OVIW(%p): vboxSetPos: new pos: %d, %d\n", (void*)self, (int)pos.x, (int)pos.y));
     1073
     1074    if (renderspuCalloutAvailable())
     1075    {
     1076        CR_RCD_SETPOS SetPos;
     1077        SetPos.pView = self;
     1078        SetPos.pos = pos;
     1079        renderspuCalloutClient(vboxRcdSetPos, &SetPos);
     1080    }
     1081    else
     1082    {
     1083        DEBUG_MSG(("no callout available on setPos\n"));
     1084        NSValue *pPos =  [NSValue valueWithPoint:pos];
     1085        [pPos retain];
     1086        [self performSelectorOnMainThread:@selector(vboxSetPosUIObj:) withObject:pPos waitUntilDone:NO];
     1087    }
     1088
     1089    DEBUG_FUNC_LEAVE();
    9081090}
    9091091
    9101092- (NSPoint)pos
    9111093{
     1094    DEBUG_FUNC_ENTER();
     1095    DEBUG_FUNC_LEAVE();
    9121096    return m_Pos;
    9131097}
     
    9151099- (bool)isEverSized
    9161100{
     1101    DEBUG_FUNC_ENTER();
     1102    DEBUG_FUNC_LEAVE();
    9171103    return m_fEverSized;
    9181104}
    9191105
    920 - (void)setSize:(NSSize)size
    921 {
    922     NSOpenGLContext *pCurCtx;
    923     NSView *pCurView;
     1106- (void)vboxDestroy
     1107{
     1108    DEBUG_FUNC_ENTER();
     1109    BOOL fIsMain = [NSThread isMainThread];
     1110    NSWindow *pWin = nil;
     1111
     1112    /* Hide the view early */
     1113    [self setHidden: YES];
     1114
     1115    pWin = [self window];
     1116    [[NSNotificationCenter defaultCenter] removeObserver:pWin];
     1117    [pWin setContentView: nil];
     1118    [[pWin parentWindow] removeChildWindow: pWin];
     1119   
     1120    if (fIsMain)
     1121        [pWin release];
     1122    else
     1123    {
     1124        /* We can NOT run synchronously with the main thread since this may lead to a deadlock,
     1125           caused by main thread waiting xpcom thread, xpcom thread waiting to main hgcm thread,
     1126           and main hgcm thread waiting for us, this is why use waitUntilDone:NO,
     1127           which should cause no harm */
     1128        [pWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
     1129    }
     1130
     1131    [self cleanupData];
     1132
     1133    if (fIsMain)
     1134        [self release];
     1135    else
     1136    {
     1137        /* We can NOT run synchronously with the main thread since this may lead to a deadlock,
     1138           caused by main thread waiting xpcom thread, xpcom thread waiting to main hgcm thread,
     1139           and main hgcm thread waiting for us, this is why use waitUntilDone:NO.
     1140           We need to avoid concurrency though, so we cleanup some data right away via a cleanupData call */
     1141        [self performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
     1142    }
     1143    DEBUG_FUNC_LEAVE();
     1144}
     1145
     1146- (void)vboxSetSizeUIObj:(NSValue*)pSize
     1147{
     1148    DEBUG_FUNC_ENTER();
     1149    NSSize size = [pSize sizeValue];
     1150    [self vboxSetSizeUI:size];
     1151//    [pSize release];
     1152    DEBUG_FUNC_LEAVE();
     1153}
     1154
     1155- (void)vboxSetSizeUI:(NSSize)size
     1156{
     1157    DEBUG_FUNC_ENTER();
    9241158    m_Size = size;
    9251159   
    9261160    m_fEverSized = true;
    9271161
    928     DEBUG_MSG(("OVIW(%p): setSize: new size: %dx%d\n", (void*)self, (int)size.width, (int)size.height));
    929     [self performSelectorOnMainThread:@selector(vboxReshapeOnResizePerform) withObject:nil waitUntilDone:NO];
     1162    DEBUG_MSG(("OVIW(%p): vboxSetSize: new size: %dx%d\n", (void*)self, (int)m_Size.width, (int)m_Size.height));
     1163    [self vboxReshapeOnResizePerform];
    9301164
    9311165    /* ensure window contents is updated after that */
    932     [self performSelectorOnMainThread:@selector(vboxTryDrawUI) withObject:nil waitUntilDone:NO];
     1166    [self vboxTryDrawUI];
     1167    DEBUG_FUNC_LEAVE();
     1168}
     1169
     1170typedef struct CR_RCD_SETSIZE
     1171{
     1172    OverlayView *pView;
     1173    NSSize size;
     1174} CR_RCD_SETSIZE;
     1175
     1176static DECLCALLBACK(void) vboxRcdSetSize(void *pvCb)
     1177{
     1178    DEBUG_FUNC_ENTER();
     1179    CR_RCD_SETSIZE * pSetSize = (CR_RCD_SETSIZE*)pvCb;
     1180    [pSetSize->pView vboxSetSizeUI:pSetSize->size];
     1181    DEBUG_FUNC_LEAVE();
     1182}
     1183
     1184- (void)vboxSetSize:(NSSize)size
     1185{
     1186    DEBUG_FUNC_ENTER();
     1187    if (renderspuCalloutAvailable())
     1188    {
     1189        CR_RCD_SETSIZE SetSize;
     1190        SetSize.pView = self;
     1191        SetSize.size = size;
     1192        renderspuCalloutClient(vboxRcdSetSize, &SetSize);
     1193    }
     1194    else
     1195    {
     1196        NSValue *pSize = [NSValue valueWithSize:size];
     1197        [pSize retain];
     1198        DEBUG_MSG(("no callout available on setSize\n"));
     1199        [self performSelectorOnMainThread:@selector(vboxSetSizeUIObj:) withObject:pSize waitUntilDone:NO];
     1200    }
     1201    DEBUG_FUNC_LEAVE();
    9331202}
    9341203
    9351204- (NSSize)size
    9361205{
     1206    DEBUG_FUNC_ENTER();
    9371207    return m_Size;
     1208    DEBUG_FUNC_LEAVE();
    9381209}
    9391210
    9401211- (void)updateViewportCS
    9411212{
     1213    DEBUG_FUNC_ENTER();
    9421214    DEBUG_MSG(("OVIW(%p): updateViewport\n", (void*)self));
    9431215
     
    9491221    /* Clear background to transparent */
    9501222    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
     1223    DEBUG_FUNC_LEAVE();
    9511224}
    9521225
    9531226- (void)vboxReshapeOnResizePerform
    9541227{
     1228    DEBUG_FUNC_ENTER();
    9551229    [self vboxReshapePerform];
    9561230   
     
    9711245    }
    9721246#endif
     1247    DEBUG_FUNC_LEAVE();
    9731248}
    9741249
    9751250- (void)vboxReshapeOnReparentPerform
    9761251{
     1252    DEBUG_FUNC_ENTER();
    9771253    [self createDockTile];
     1254    DEBUG_FUNC_LEAVE();
    9781255}
    9791256
    9801257- (void)vboxReshapePerform
    9811258{
     1259    DEBUG_FUNC_ENTER();
    9821260    NSRect parentFrame = NSZeroRect;
    9831261    NSPoint parentPos  = NSZeroPoint;
     
    10711349        vboxCtxLeave(&CtxInfo);
    10721350    }
     1351    DEBUG_FUNC_LEAVE();
    10731352}
    10741353
    10751354- (void)createDockTile
    10761355{
     1356    DEBUG_FUNC_ENTER();
    10771357        NSView *pDockScreen      = nil;
    10781358        [self deleteDockTile];
     
    10871367        [pDockScreen addSubview:m_DockTileView];
    10881368    }
     1369    DEBUG_FUNC_LEAVE();
    10891370}
    10901371
    10911372- (void)deleteDockTile
    10921373{
     1374    DEBUG_FUNC_ENTER();
    10931375        if (m_DockTileView != nil)
    10941376    {
     
    10971379        m_DockTileView = nil;
    10981380    }
     1381    DEBUG_FUNC_LEAVE();
    10991382}
    11001383
     
    11371420- (bool)vboxSharedCtxCreate
    11381421{
     1422    DEBUG_FUNC_ENTER();
    11391423    if (m_pSharedGLCtx)
     1424    {
     1425        DEBUG_FUNC_LEAVE();
    11401426        return true;
     1427    }
    11411428       
    11421429    Assert(!m_pBlitter);
     
    11451432    {
    11461433        DEBUG_WARN(("m_pBlitter allocation failed"));
     1434        DEBUG_FUNC_LEAVE();
    11471435        return false;
    11481436    }
     
    11581446        RTMemFree(m_pBlitter);
    11591447        m_pBlitter = NULL;
     1448        DEBUG_FUNC_LEAVE();
    11601449        return false;
    11611450    }       
     
    11731462    m_pSharedGLCtx = pSharedGLCtx;
    11741463   
     1464    DEBUG_FUNC_LEAVE();
    11751465    return true;
    11761466}
     
    11851475}
    11861476
    1187 - (void)vboxSubmitVisible:(GLboolean)fVisible
    1188 {
    1189     if (fVisible)
    1190         [self performSelectorOnMainThread:@selector(vboxSetVisibleUI) withObject:nil waitUntilDone:NO];
     1477typedef struct CR_RCD_SETVISIBLE
     1478{
     1479    OverlayView *pView;
     1480    BOOL fVisible;
     1481} CR_RCD_SETVISIBLE;
     1482
     1483static DECLCALLBACK(void) vboxRcdSetVisible(void *pvCb)
     1484{
     1485    DEBUG_FUNC_ENTER();
     1486    CR_RCD_SETVISIBLE * pVisible = (CR_RCD_SETVISIBLE*)pvCb;
     1487   
     1488    [pVisible->pView vboxSetVisibleUI:pVisible->fVisible];
     1489    DEBUG_FUNC_LEAVE();
     1490}
     1491
     1492- (void)vboxSetVisible:(GLboolean)fVisible
     1493{
     1494    DEBUG_FUNC_ENTER();
     1495    if (renderspuCalloutAvailable())
     1496    {
     1497        CR_RCD_SETVISIBLE Visible;
     1498        Visible.pView = self;
     1499        Visible.fVisible = fVisible;
     1500        renderspuCalloutClient(vboxRcdSetVisible, &Visible);
     1501    }
    11911502    else
    1192         [self performSelectorOnMainThread:@selector(vboxSetHiddenUI) withObject:nil waitUntilDone:NO];
    1193 }
    1194 
    1195 - (void)vboxSetVisibleUI
    1196 {
    1197     [self setHidden: NO];
    1198 }
    1199 
    1200 - (void)vboxSetHiddenUI
    1201 {
    1202     [self setHidden: YES];
     1503    {
     1504        DEBUG_MSG(("no callout available on setVisible\n"));
     1505        NSNumber* pVisObj = [NSNumber numberWithBool:fVisible];
     1506        [pVisObj retain];
     1507        [self performSelectorOnMainThread:@selector(vboxSetVisibleUIObj:) withObject:pVisObj waitUntilDone:NO];
     1508    }
     1509    DEBUG_FUNC_LEAVE();
     1510}
     1511
     1512- (void)vboxSetVisibleUI:(GLboolean)fVisible
     1513{
     1514    DEBUG_FUNC_ENTER();
     1515    [self setHidden: !fVisible];
     1516    DEBUG_FUNC_LEAVE();
     1517}
     1518
     1519- (void)vboxSetVisibleUIObj:(NSNumber*)pVisible
     1520{
     1521    DEBUG_FUNC_ENTER();
     1522    BOOL fVisible = [pVisible boolValue];
     1523    [self vboxSetVisibleUI:fVisible];
     1524    [pVisible release];
     1525    DEBUG_FUNC_LEAVE();
     1526}
     1527
     1528typedef struct CR_RCD_REPARENT
     1529{
     1530    OverlayView *pView;
     1531    NSView *pParent;
     1532} CR_RCD_REPARENT;
     1533
     1534static DECLCALLBACK(void) vboxRcdReparent(void *pvCb)
     1535{
     1536    DEBUG_FUNC_ENTER();
     1537    CR_RCD_REPARENT * pReparent = (CR_RCD_REPARENT*)pvCb;
     1538    [pReparent->pView vboxReparentUI:pReparent->pParent];
     1539    DEBUG_FUNC_LEAVE();
     1540}
     1541
     1542- (void)vboxReparent:(NSView*)pParentView
     1543{
     1544    DEBUG_FUNC_ENTER();
     1545    [pParentView retain];
     1546    if (renderspuCalloutAvailable())
     1547    {
     1548        CR_RCD_REPARENT Reparent;
     1549        Reparent.pView = self;
     1550        Reparent.pParent = pParentView;
     1551        renderspuCalloutClient(vboxRcdReparent, &Reparent);
     1552    }
     1553    else
     1554    {
     1555        DEBUG_MSG(("no callout available on reparent %p %p\n", self, pParentView));
     1556        [self performSelectorOnMainThread:@selector(vboxReparentUI:) withObject:pParentView waitUntilDone:NO];
     1557    }
     1558    DEBUG_FUNC_LEAVE();
     1559}
     1560
     1561- (void)vboxReparentUI:(NSView*)pParentView
     1562{
     1563    DEBUG_FUNC_ENTER();
     1564    /* Make sure the window is removed from any previous parent window. */
     1565    if ([[self overlayWin] parentWindow] != nil)
     1566    {
     1567        [[[self overlayWin] parentWindow] removeChildWindow:[self overlayWin]];
     1568    }
     1569
     1570    /* Set the new parent view */
     1571    [self setParentView: pParentView];
     1572
     1573    /* Add the overlay window as a child to the new parent window */
     1574    if (pParentView != nil)
     1575    {
     1576        [[pParentView window] addChildWindow:[self overlayWin] ordered:NSWindowAbove];
     1577        if ([self isEverSized])
     1578            [self vboxReshapeOnReparentPerform];
     1579    }
     1580   
     1581    [pParentView release];
     1582   
     1583    DEBUG_FUNC_LEAVE();
    12031584}
    12041585
     
    12741655- (void)swapFBO
    12751656{
     1657    DEBUG_FUNC_ENTER();
    12761658    [m_pGLCtx flushBuffer];
     1659    DEBUG_FUNC_LEAVE();
    12771660}
    12781661
     
    15961979- (void)clearVisibleRegions
    15971980{
     1981    DEBUG_FUNC_ENTER();
    15981982    if(m_paClipRects)
    15991983    {
     
    16021986    }
    16031987    m_cClipRects = 0;
     1988    DEBUG_FUNC_LEAVE();
    16041989}
    16051990
     
    16172002- (void)setVisibleRegions:(GLint)cRects paRects:(const GLint*)paRects
    16182003{
     2004    DEBUG_FUNC_ENTER();
    16192005    GLint cOldRects = m_cClipRects;
    16202006
     
    16352021        memcpy(m_paClipRects, paRects, sizeof(GLint) * 4 * cRects);
    16362022    }
     2023   
     2024    DEBUG_FUNC_LEAVE();
    16372025}
    16382026
    16392027- (NSView*)dockTileScreen
    16402028{
     2029    DEBUG_FUNC_ENTER();
    16412030    NSView *contentView = [[[NSApplication sharedApplication] dockTile] contentView];
    16422031    NSView *screenContent = nil;
     
    16482037    else if ([contentView respondsToSelector:@selector(screenContent)])
    16492038         screenContent = [contentView performSelector:@selector(screenContent)];
     2039   
     2040    DEBUG_FUNC_LEAVE();
    16502041    return screenContent;
    16512042}
     
    16532044- (void)reshapeDockTile
    16542045{
     2046    DEBUG_FUNC_ENTER();
    16552047    NSRect newFrame = NSZeroRect;
    16562048
     
    16722064        [m_DockTileView setFrame: newFrame];
    16732065    }
     2066    DEBUG_FUNC_LEAVE();
    16742067}
    16752068
     
    16832076void cocoaGLCtxCreate(NativeNSOpenGLContextRef *ppCtx, GLbitfield fVisParams, NativeNSOpenGLContextRef pSharedCtx)
    16842077{
     2078    DEBUG_FUNC_ENTER();
    16852079    NSOpenGLPixelFormat *pFmt = nil;
    16862080
     
    17662160
    17672161    [pPool release];
     2162   
     2163    DEBUG_FUNC_LEAVE();
    17682164}
    17692165
    17702166void cocoaGLCtxDestroy(NativeNSOpenGLContextRef pCtx)
    17712167{
     2168    DEBUG_FUNC_ENTER();
    17722169    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    17732170
     
    17762173
    17772174    [pPool release];
     2175    DEBUG_FUNC_LEAVE();
    17782176}
    17792177
     
    17832181*
    17842182********************************************************************************/
    1785 void cocoaViewCreate(NativeNSViewRef *ppView, WindowInfo *pWinInfo, NativeNSViewRef pParentView, GLbitfield fVisParams)
    1786 {
    1787     NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    1788 
     2183typedef struct CR_RCD_CREATEVIEW
     2184{
     2185    WindowInfo *pWinInfo;
     2186    NSView *pParentView;
     2187    GLbitfield fVisParams;
     2188    /* out */
     2189    OverlayView *pView;
     2190} CR_RCD_CREATEVIEW;
     2191
     2192static OverlayView * vboxViewCreate(WindowInfo *pWinInfo, NativeNSViewRef pParentView, GLbitfield fVisParams)
     2193{
     2194    DEBUG_FUNC_ENTER();
    17892195    /* Create our worker view */
    17902196    OverlayView* pView = [[OverlayView alloc] initWithFrame:NSZeroRect thread:RTThreadSelf() parentView:pParentView winInfo:pWinInfo];
     
    17952201        [[OverlayWindow alloc] initWithParentView:pParentView overlayView:pView];
    17962202        /* Return the freshly created overlay view */
    1797         *ppView = pView;
    1798     }
    1799 
     2203        DEBUG_FUNC_LEAVE();
     2204        return pView;
     2205    }
     2206   
     2207    DEBUG_FUNC_LEAVE();
     2208    return NULL;
     2209}
     2210
     2211static DECLCALLBACK(void) vboxRcdCreateView(void *pvCb)
     2212{
     2213    DEBUG_FUNC_ENTER();
     2214    CR_RCD_CREATEVIEW * pCreateView = (CR_RCD_CREATEVIEW*)pvCb;
     2215    pCreateView->pView = vboxViewCreate(pCreateView->pWinInfo, pCreateView->pParentView, pCreateView->fVisParams);
     2216    DEBUG_FUNC_LEAVE();
     2217}
     2218
     2219void cocoaViewCreate(NativeNSViewRef *ppView, WindowInfo *pWinInfo, NativeNSViewRef pParentView, GLbitfield fVisParams)
     2220{
     2221    DEBUG_FUNC_ENTER();
     2222    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
     2223
     2224    if (renderspuCalloutAvailable())
     2225    {
     2226        CR_RCD_CREATEVIEW CreateView;
     2227        CreateView.pWinInfo = pWinInfo;
     2228        CreateView.pParentView = pParentView;
     2229        CreateView.fVisParams = fVisParams;
     2230        CreateView.pView = NULL;
     2231        renderspuCalloutClient(vboxRcdCreateView, &CreateView);
     2232        *ppView = CreateView.pView;
     2233    }
     2234    else
     2235    {
     2236        DEBUG_MSG(("no callout available on createWindow\n"));
     2237#if 0
     2238        dispatch_sync(dispatch_get_main_queue(), ^{
     2239#endif
     2240            *ppView = vboxViewCreate(pWinInfo, pParentView, fVisParams);
     2241#if 0
     2242        });
     2243#endif
     2244    }
     2245   
    18002246    [pPool release];
     2247   
     2248    DEBUG_FUNC_LEAVE();
    18012249}
    18022250
    18032251void cocoaViewReparent(NativeNSViewRef pView, NativeNSViewRef pParentView)
    18042252{
     2253    DEBUG_FUNC_ENTER();
    18052254    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    18062255
     
    18092258    if (pOView)
    18102259    {
    1811         /* Make sure the window is removed from any previous parent window. */
    1812         if ([[pOView overlayWin] parentWindow] != nil)
    1813         {
    1814             [[[pOView overlayWin] parentWindow] removeChildWindow:[pOView overlayWin]];
    1815         }
    1816 
    1817         /* Set the new parent view */
    1818         [pOView setParentView: pParentView];
    1819 
    1820         /* Add the overlay window as a child to the new parent window */
    1821         if (pParentView != nil)
    1822         {
    1823             [[pParentView window] addChildWindow:[pOView overlayWin] ordered:NSWindowAbove];
    1824             if ([pOView isEverSized])
    1825                 [pOView performSelectorOnMainThread:@selector(vboxReshapeOnReparentPerform) withObject:nil waitUntilDone:NO];
    1826         }
     2260        [pOView vboxReparent:pParentView];
    18272261    }
    18282262
    18292263    [pPool release];
     2264   
     2265    DEBUG_FUNC_LEAVE();
     2266}
     2267
     2268typedef struct CR_RCD_DESTROYVIEW
     2269{
     2270    OverlayView *pView;
     2271} CR_RCD_DESTROYVIEW;
     2272
     2273static DECLCALLBACK(void) vboxRcdDestroyView(void *pvCb)
     2274{
     2275    DEBUG_FUNC_ENTER();
     2276    CR_RCD_DESTROYVIEW * pDestroyView = (CR_RCD_DESTROYVIEW*)pvCb;
     2277    [pDestroyView->pView vboxDestroy];
     2278    DEBUG_FUNC_LEAVE();
    18302279}
    18312280
    18322281void cocoaViewDestroy(NativeNSViewRef pView)
    18332282{
    1834     NSWindow *pWin = nil;
    1835 
     2283    DEBUG_FUNC_ENTER();
    18362284    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    18372285
    1838     /* Hide the view early */
    1839     [pView setHidden: YES];
    1840 
    1841     pWin = [pView window];
    1842     [[NSNotificationCenter defaultCenter] removeObserver:pWin];
    1843     [pWin setContentView: nil];
    1844     [[pWin parentWindow] removeChildWindow: pWin];
    1845    
    1846     /*
    1847     a = [pWin retainCount];
    1848     for (; a > 1; --a)
    1849         [pWin performSelector:@selector(release)]
    1850     */
    1851     /* We can NOT run synchronously with the main thread since this may lead to a deadlock,
    1852        caused by main thread waiting xpcom thread, xpcom thread waiting to main hgcm thread,
    1853        and main hgcm thread waiting for us, this is why use waitUntilDone:NO,
    1854        which should cause no harm */
    1855     [pWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
    1856     /*
    1857     [pWin release];
    1858     */
    1859 
    1860     /* We can NOT run synchronously with the main thread since this may lead to a deadlock,
    1861        caused by main thread waiting xpcom thread, xpcom thread waiting to main hgcm thread,
    1862        and main hgcm thread waiting for us, this is why use waitUntilDone:NO.
    1863        We need to avoid concurrency though, so we cleanup some data right away via a cleanupData call */
    1864     [(OverlayView*)pView cleanupData];
    1865 
    1866     /* There seems to be a bug in the performSelector method which is called in
    1867      * parentWindowChanged above. The object is retained but not released. This
    1868      * results in an unbalanced reference count, which is here manually
    1869      * decremented. */
    1870     /*
    1871     a = [pView retainCount];
    1872     for (; a > 1; --a)
    1873     */
    1874     [pView performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
    1875     /*
    1876     [pView release];
    1877     */
     2286    if (renderspuCalloutAvailable())
     2287    {
     2288        CR_RCD_DESTROYVIEW DestroyView;
     2289        DestroyView.pView = (OverlayView*)pView;
     2290        renderspuCalloutClient(vboxRcdDestroyView, &DestroyView);
     2291    }
     2292    else
     2293    {
     2294        DEBUG_MSG(("no callout available on destroyView\n"));
     2295        [(OverlayView*)pView performSelectorOnMainThread:@selector(vboxDestroy) withObject:nil waitUntilDone:NO];
     2296    }
    18782297
    18792298    [pPool release];
     2299    DEBUG_FUNC_LEAVE();
    18802300}
    18812301
    18822302void cocoaViewShow(NativeNSViewRef pView, GLboolean fShowIt)
    18832303{
     2304    DEBUG_FUNC_ENTER();
    18842305    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    18852306
    1886     [pView vboxSubmitVisible:fShowIt];
     2307    [(OverlayView*)pView vboxSetVisible:fShowIt];
    18872308
    18882309    [pPool release];
     2310    DEBUG_FUNC_LEAVE();
    18892311}
    18902312
    18912313void cocoaViewDisplay(NativeNSViewRef pView)
    18922314{
     2315    DEBUG_FUNC_ENTER();
    18932316    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    18942317
     2318    DEBUG_WARN(("cocoaViewDisplay should never happen!\n"));
    18952319    DEBUG_MSG_1(("cocoaViewDisplay %p\n", (void*)pView));
    18962320    [(OverlayView*)pView swapFBO];
    18972321
    18982322    [pPool release];
    1899 
     2323   
     2324    DEBUG_FUNC_LEAVE();
    19002325}
    19012326
    19022327void cocoaViewSetPosition(NativeNSViewRef pView, NativeNSViewRef pParentView, int x, int y)
    19032328{
     2329    DEBUG_FUNC_ENTER();
    19042330    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    19052331
    1906     [(OverlayView*)pView setPos:NSMakePoint(x, y)];
     2332    [(OverlayView*)pView vboxSetPos:NSMakePoint(x, y)];
    19072333
    19082334    [pPool release];
     2335   
     2336    DEBUG_FUNC_LEAVE();
    19092337}
    19102338
    19112339void cocoaViewSetSize(NativeNSViewRef pView, int w, int h)
    19122340{
     2341    DEBUG_FUNC_ENTER();
    19132342    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    19142343
    1915     [(OverlayView*)pView setSize:NSMakeSize(w, h)];
     2344    [(OverlayView*)pView vboxSetSize:NSMakeSize(w, h)];
    19162345
    19172346    [pPool release];
     2347   
     2348    DEBUG_FUNC_LEAVE();
     2349}
     2350
     2351typedef struct CR_RCD_GETGEOMETRY
     2352{
     2353    OverlayView *pView;
     2354    NSRect rect;
     2355} CR_RCD_GETGEOMETRY;
     2356
     2357static DECLCALLBACK(void) vboxRcdGetGeomerty(void *pvCb)
     2358{
     2359    DEBUG_FUNC_ENTER();
     2360    CR_RCD_GETGEOMETRY * pGetGeometry = (CR_RCD_GETGEOMETRY*)pvCb;
     2361    pGetGeometry->rect = [[pGetGeometry->pView window] frame];
     2362    DEBUG_FUNC_LEAVE();
    19182363}
    19192364
    19202365void cocoaViewGetGeometry(NativeNSViewRef pView, int *pX, int *pY, int *pW, int *pH)
    19212366{
     2367    DEBUG_FUNC_ENTER();
    19222368    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    19232369
    1924     NSRect frame = [[pView window] frame];
     2370    NSRect frame;
     2371   
     2372    if (renderspuCalloutAvailable())
     2373    {
     2374        CR_RCD_GETGEOMETRY GetGeometry;
     2375        GetGeometry.pView = (OverlayView*)pView;
     2376        renderspuCalloutClient(vboxRcdGetGeomerty, &GetGeometry);
     2377        frame = GetGeometry.rect;
     2378    }
     2379    else
     2380    {
     2381        DEBUG_MSG(("no callout available on getGeometry\n"));
     2382        frame = [[pView window] frame];
     2383    }
     2384   
    19252385    *pX = frame.origin.x;
    19262386    *pY = frame.origin.y;
     
    19292389
    19302390    [pPool release];
     2391   
     2392    DEBUG_FUNC_LEAVE();
    19312393}
    19322394
    19332395void cocoaViewPresentComposition(NativeNSViewRef pView, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry)
    19342396{
     2397    DEBUG_FUNC_ENTER();
    19352398    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    19362399    NSOpenGLContext *pCtx;
     
    19462409           
    19472410            [pPool release];
     2411            DEBUG_FUNC_LEAVE();
    19482412            return;
    19492413        }
     
    19572421
    19582422    [pPool release];
     2423   
     2424    DEBUG_FUNC_LEAVE();
    19592425}
    19602426
    19612427void cocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx)
    19622428{
     2429    DEBUG_FUNC_ENTER();
    19632430    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    19642431
     
    19762443
    19772444    [pPool release];
     2445   
     2446    DEBUG_FUNC_LEAVE();
    19782447}
    19792448
    19802449GLboolean cocoaViewNeedsEmptyPresent(NativeNSViewRef pView)
    19812450{
     2451    DEBUG_FUNC_ENTER();
     2452   
    19822453    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    19832454
     
    19862457    [pPool release];
    19872458   
     2459    DEBUG_FUNC_LEAVE();
     2460   
    19882461    return fNeedsPresent;
    19892462}
     
    19912464void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, const GLint* paRects)
    19922465{
     2466    DEBUG_FUNC_ENTER();
    19932467    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    19942468
     
    19962470
    19972471    [pPool release];
    1998 }
     2472   
     2473    DEBUG_FUNC_LEAVE();
     2474}
Note: See TracChangeset for help on using the changeset viewer.

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