Changeset 52429 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/render
- Timestamp:
- Aug 20, 2014 11:58:38 AM (10 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedOpenGL/render
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
r52368 r52429 1444 1444 } 1445 1445 1446 bool renderspuCalloutAvailable() 1447 { 1448 return render_spu.pfnClientCallout != NULL; 1449 } 1450 1451 bool 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 } 1446 1460 1447 1461 static void RENDER_APIENTRY … … 1455 1469 1456 1470 switch (target) { 1457 1471 case GL_HH_SET_CLIENT_CALLOUT: 1472 render_spu.pfnClientCallout = (PFNVCRSERVER_CLIENT_CALLOUT)values; 1473 break; 1458 1474 case GL_GATHER_CONNECT_CR: 1459 1475 if (render_spu.gather_userbuf_size) -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h
r51442 r52429 219 219 #endif 220 220 221 typedef DECLCALLBACKPTR(void, PFNVCRSERVER_CLIENT_CALLOUT_CB)(void *pvCb); 222 typedef DECLCALLBACKPTR(void, PFNVCRSERVER_CLIENT_CALLOUT)(PFNVCRSERVER_CLIENT_CALLOUT_CB pfnCb, void*pvCb); 223 224 221 225 /** 222 226 * Renderspu state info … … 287 291 SPUDispatchTable blitterDispatch; 288 292 CRHashTable *blitterTable; 293 294 PFNVCRSERVER_CLIENT_CALLOUT pfnClientCallout; 289 295 290 296 #ifdef USE_OSMESA … … 454 460 uint32_t renderspuContextRetain(ContextInfo *context); 455 461 462 bool renderspuCalloutAvailable(); 463 bool renderspuCalloutClient(PFNVCRSERVER_CLIENT_CALLOUT_CB pfnCb, void *pvCb); 464 465 456 466 #ifdef __cplusplus 457 467 extern "C" { -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
r52398 r52429 115 115 #endif 116 116 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 117 126 #ifdef DEBUG_poetzsch 118 127 # define CHECK_GL_ERROR()\ … … 361 370 - (NSWindow*)overlayWin; 362 371 363 - (void)setPos:(NSPoint)pos; 372 - (void)vboxSetPos:(NSPoint)pos; 373 - (void)vboxSetPosUI:(NSPoint)pos; 374 - (void)vboxSetPosUIObj:(NSValue*)pPos; 364 375 - (NSPoint)pos; 365 376 - (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; 367 381 - (NSSize)size; 368 382 - (void)updateViewportCS; … … 376 390 - (void)makeCurrentFBO; 377 391 - (void)swapFBO; 378 - (void)vboxS ubmitVisible:(GLboolean)fVisible;379 - (void)vboxSetVisibleUI ;380 - (void)vboxSet HiddenUI;392 - (void)vboxSetVisible:(GLboolean)fVisible; 393 - (void)vboxSetVisibleUIObj:(NSNumber*)pVisible; 394 - (void)vboxSetVisibleUI:(GLboolean)fVisible; 381 395 - (void)vboxTryDraw; 382 396 - (void)vboxTryDrawUI; 397 - (void)vboxReparent:(NSView*)pParentView; 398 - (void)vboxReparentUI:(NSView*)pParentView; 383 399 - (void)vboxPresent:(const VBOXVR_SCR_COMPOSITOR*)pCompositor; 384 400 - (void)vboxPresentCS:(const VBOXVR_SCR_COMPOSITOR*)pCompositor; … … 451 467 - (id)init 452 468 { 469 DEBUG_FUNC_ENTER(); 453 470 self = [super init]; 454 471 … … 461 478 } 462 479 480 DEBUG_FUNC_LEAVE(); 481 463 482 return self; 464 483 } … … 466 485 - (void)dealloc 467 486 { 487 DEBUG_FUNC_ENTER(); 488 468 489 [self cleanup]; 469 490 [m_Lock release]; 470 491 471 492 [super dealloc]; 493 494 DEBUG_FUNC_LEAVE(); 472 495 } 473 496 474 497 - (void)cleanup 475 498 { 499 DEBUG_FUNC_ENTER(); 500 476 501 if (m_ThumbImage != nil) 477 502 { … … 484 509 m_ThumbBitmap = nil; 485 510 } 511 512 DEBUG_FUNC_LEAVE(); 486 513 } 487 514 488 515 - (void)lock 489 516 { 517 DEBUG_FUNC_ENTER(); 490 518 [m_Lock lock]; 519 DEBUG_FUNC_LEAVE(); 491 520 } 492 521 493 522 - (void)unlock 494 523 { 524 DEBUG_FUNC_ENTER(); 495 525 [m_Lock unlock]; 526 DEBUG_FUNC_LEAVE(); 496 527 } 497 528 498 529 - (void)setFrame:(NSRect)frame 499 530 { 531 DEBUG_FUNC_ENTER(); 500 532 [super setFrame:frame]; 501 533 … … 522 554 } 523 555 [self unlock]; 556 DEBUG_FUNC_LEAVE(); 524 557 } 525 558 526 559 - (BOOL)isFlipped 527 560 { 561 DEBUG_FUNC_ENTER(); 562 DEBUG_FUNC_LEAVE(); 528 563 return YES; 529 564 } … … 531 566 - (void)drawRect:(NSRect)aRect 532 567 { 568 DEBUG_FUNC_ENTER(); 533 569 NSRect frame; 534 570 … … 542 578 [m_ThumbImage drawAtPoint:NSMakePoint(0, 0) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; 543 579 [self unlock]; 580 DEBUG_FUNC_LEAVE(); 544 581 } 545 582 546 583 - (NSBitmapImageRep*)thumbBitmap 547 584 { 585 DEBUG_FUNC_ENTER(); 586 DEBUG_FUNC_LEAVE(); 548 587 return m_ThumbBitmap; 549 588 } … … 551 590 - (NSImage*)thumbImage 552 591 { 592 DEBUG_FUNC_ENTER(); 593 DEBUG_FUNC_LEAVE(); 594 553 595 return m_ThumbImage; 554 596 } … … 564 606 -(id)initWithFormat:(NSOpenGLPixelFormat*)format shareContext:(NSOpenGLContext*)share 565 607 { 608 DEBUG_FUNC_ENTER(); 609 566 610 m_pPixelFormat = NULL; 567 611 m_pView = NULL; … … 573 617 DEBUG_MSG(("OCTX(%p): init OverlayOpenGLContext\n", (void*)self)); 574 618 619 DEBUG_FUNC_LEAVE(); 620 575 621 return self; 576 622 } … … 578 624 - (void)dealloc 579 625 { 626 DEBUG_FUNC_ENTER(); 627 580 628 DEBUG_MSG(("OCTX(%p): dealloc OverlayOpenGLContext\n", (void*)self)); 581 629 … … 583 631 584 632 [super dealloc]; 633 634 DEBUG_FUNC_LEAVE(); 585 635 } 586 636 587 637 -(bool)isDoubleBuffer 588 638 { 639 DEBUG_FUNC_ENTER(); 640 589 641 GLint val; 590 642 [m_pPixelFormat getValues:&val forAttribute:NSOpenGLPFADoubleBuffer forVirtualScreen:0]; 643 644 DEBUG_FUNC_LEAVE(); 645 591 646 return val == GL_TRUE ? YES : NO; 592 647 } … … 594 649 -(void)setView:(NSView*)view 595 650 { 651 DEBUG_FUNC_ENTER(); 652 596 653 DEBUG_MSG(("OCTX(%p): setView: new view: %p\n", (void*)self, (void*)view)); 597 654 … … 601 658 [super setView: view]; 602 659 #endif 660 661 DEBUG_FUNC_LEAVE(); 603 662 } 604 663 605 664 -(NSView*)view 606 665 { 666 DEBUG_FUNC_ENTER(); 667 DEBUG_FUNC_LEAVE(); 668 607 669 #if 1 /* def FBO */ 608 670 return m_pView; … … 614 676 -(void)clearDrawable 615 677 { 678 DEBUG_FUNC_ENTER(); 679 616 680 DEBUG_MSG(("OCTX(%p): clearDrawable\n", (void*)self)); 617 681 618 682 m_pView = NULL;; 619 683 [super clearDrawable]; 684 685 DEBUG_FUNC_LEAVE(); 620 686 } 621 687 622 688 -(NSOpenGLPixelFormat*)openGLPixelFormat 623 689 { 690 DEBUG_FUNC_ENTER(); 691 DEBUG_FUNC_LEAVE(); 692 624 693 return m_pPixelFormat; 625 694 } … … 636 705 -(id)initWithOverlayWindow:(OverlayWindow*)pOverlayWindow 637 706 { 707 DEBUG_FUNC_ENTER(); 708 638 709 self = [super initWithFrame:NSZeroRect]; 639 710 … … 642 713 DEBUG_MSG(("OHVW(%p): init OverlayHelperView\n", (void*)self)); 643 714 715 DEBUG_FUNC_LEAVE(); 716 644 717 return self; 645 718 } … … 647 720 -(void)viewDidMoveToWindow 648 721 { 722 DEBUG_FUNC_ENTER(); 723 649 724 DEBUG_MSG(("OHVW(%p): viewDidMoveToWindow: new win: %p\n", (void*)self, (void*)[self window])); 650 725 651 726 [m_pOverlayWindow parentWindowChanged:[self window]]; 727 728 DEBUG_FUNC_LEAVE(); 652 729 } 653 730 … … 663 740 - (id)initWithParentView:(NSView*)pParentView overlayView:(OverlayView*)pOverlayView 664 741 { 742 DEBUG_FUNC_ENTER(); 743 665 744 NSWindow *pParentWin = nil; 666 745 … … 706 785 DEBUG_MSG(("OWIN(%p): init OverlayWindow\n", (void*)self)); 707 786 787 DEBUG_FUNC_LEAVE(); 788 708 789 return self; 709 790 } … … 711 792 - (void)dealloc 712 793 { 794 DEBUG_FUNC_ENTER(); 795 713 796 DEBUG_MSG(("OWIN(%p): dealloc OverlayWindow\n", (void*)self)); 714 797 … … 719 802 720 803 [super dealloc]; 804 805 DEBUG_FUNC_LEAVE(); 721 806 } 722 807 723 808 - (void)parentWindowFrameChanged:(NSNotification*)pNote 724 809 { 810 DEBUG_FUNC_ENTER(); 811 725 812 DEBUG_MSG(("OWIN(%p): parentWindowFrameChanged\n", (void*)self)); 726 813 … … 738 825 [self performSelectorOnMainThread:@selector(vboxReshapePerform) withObject:nil waitUntilDone:NO]; 739 826 } 827 828 DEBUG_FUNC_LEAVE(); 740 829 } 741 830 742 831 - (void)parentWindowChanged:(NSWindow*)pWindow 743 832 { 833 DEBUG_FUNC_ENTER(); 834 744 835 DEBUG_MSG(("OWIN(%p): parentWindowChanged\n", (void*)self)); 745 836 … … 771 862 } 772 863 } 864 865 DEBUG_FUNC_LEAVE(); 773 866 } 774 867 … … 784 877 - (id)initWithFrame:(NSRect)frame thread:(RTTHREAD)aThread parentView:(NSView*)pParentView winInfo:(WindowInfo*)pWinInfo 785 878 { 879 DEBUG_FUNC_ENTER(); 880 786 881 m_pParentView = pParentView; 787 882 /* Make some reasonable defaults */ … … 808 903 DEBUG_MSG(("OVIW(%p): init OverlayView\n", (void*)self)); 809 904 905 DEBUG_FUNC_LEAVE(); 906 810 907 return self; 811 908 } … … 813 910 - (void)cleanupData 814 911 { 912 DEBUG_FUNC_ENTER(); 913 815 914 [self deleteDockTile]; 816 915 … … 834 933 835 934 [self clearVisibleRegions]; 935 936 DEBUG_FUNC_LEAVE(); 836 937 } 837 938 838 939 - (void)dealloc 839 940 { 941 DEBUG_FUNC_ENTER(); 942 840 943 DEBUG_MSG(("OVIW(%p): dealloc OverlayView\n", (void*)self)); 841 944 … … 843 946 844 947 [super dealloc]; 948 949 DEBUG_FUNC_LEAVE(); 845 950 } 846 951 … … 852 957 - (void)setGLCtx:(NSOpenGLContext*)pCtx 853 958 { 959 DEBUG_FUNC_ENTER(); 960 854 961 DEBUG_MSG(("OVIW(%p): setGLCtx: new ctx: %p\n", (void*)self, (void*)pCtx)); 855 962 if (m_pGLCtx == pCtx) 963 { 964 DEBUG_FUNC_LEAVE(); 856 965 return; 966 } 857 967 858 968 /* ensure the context drawable is cleared to avoid holding a reference to inexistent view */ … … 867 977 if (pCtx) 868 978 [pCtx retain]; 979 980 DEBUG_FUNC_LEAVE(); 869 981 } 870 982 871 983 - (NSOpenGLContext*)glCtx 872 984 { 985 DEBUG_FUNC_ENTER(); 986 DEBUG_FUNC_LEAVE(); 987 873 988 return m_pGLCtx; 874 989 } … … 876 991 - (NSView*)parentView 877 992 { 993 DEBUG_FUNC_ENTER(); 994 DEBUG_FUNC_LEAVE(); 995 878 996 return m_pParentView; 879 997 } … … 881 999 - (void)setParentView:(NSView*)pView 882 1000 { 1001 DEBUG_FUNC_ENTER(); 1002 883 1003 DEBUG_MSG(("OVIW(%p): setParentView: new view: %p\n", (void*)self, (void*)pView)); 884 1004 885 1005 m_pParentView = pView; 1006 1007 DEBUG_FUNC_LEAVE(); 886 1008 } 887 1009 888 1010 - (void)setOverlayWin:(NSWindow*)pWin 889 1011 { 1012 DEBUG_FUNC_ENTER(); 1013 890 1014 DEBUG_MSG(("OVIW(%p): setOverlayWin: new win: %p\n", (void*)self, (void*)pWin)); 891 1015 892 1016 m_pOverlayWin = pWin; 1017 1018 DEBUG_FUNC_LEAVE(); 893 1019 } 894 1020 895 1021 - (NSWindow*)overlayWin 896 1022 { 1023 DEBUG_FUNC_ENTER(); 1024 DEBUG_FUNC_LEAVE(); 1025 897 1026 return m_pOverlayWin; 898 1027 } 899 1028 900 - (void) setPos:(NSPoint)pos901 { 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(); 903 1032 904 1033 m_Pos = pos; 905 1034 906 1035 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 1052 typedef struct CR_RCD_SETPOS 1053 { 1054 OverlayView *pView; 1055 NSPoint pos; 1056 } CR_RCD_SETPOS; 1057 1058 static 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(); 908 1090 } 909 1091 910 1092 - (NSPoint)pos 911 1093 { 1094 DEBUG_FUNC_ENTER(); 1095 DEBUG_FUNC_LEAVE(); 912 1096 return m_Pos; 913 1097 } … … 915 1099 - (bool)isEverSized 916 1100 { 1101 DEBUG_FUNC_ENTER(); 1102 DEBUG_FUNC_LEAVE(); 917 1103 return m_fEverSized; 918 1104 } 919 1105 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(); 924 1158 m_Size = size; 925 1159 926 1160 m_fEverSized = true; 927 1161 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]; 930 1164 931 1165 /* 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 1170 typedef struct CR_RCD_SETSIZE 1171 { 1172 OverlayView *pView; 1173 NSSize size; 1174 } CR_RCD_SETSIZE; 1175 1176 static 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(); 933 1202 } 934 1203 935 1204 - (NSSize)size 936 1205 { 1206 DEBUG_FUNC_ENTER(); 937 1207 return m_Size; 1208 DEBUG_FUNC_LEAVE(); 938 1209 } 939 1210 940 1211 - (void)updateViewportCS 941 1212 { 1213 DEBUG_FUNC_ENTER(); 942 1214 DEBUG_MSG(("OVIW(%p): updateViewport\n", (void*)self)); 943 1215 … … 949 1221 /* Clear background to transparent */ 950 1222 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 1223 DEBUG_FUNC_LEAVE(); 951 1224 } 952 1225 953 1226 - (void)vboxReshapeOnResizePerform 954 1227 { 1228 DEBUG_FUNC_ENTER(); 955 1229 [self vboxReshapePerform]; 956 1230 … … 971 1245 } 972 1246 #endif 1247 DEBUG_FUNC_LEAVE(); 973 1248 } 974 1249 975 1250 - (void)vboxReshapeOnReparentPerform 976 1251 { 1252 DEBUG_FUNC_ENTER(); 977 1253 [self createDockTile]; 1254 DEBUG_FUNC_LEAVE(); 978 1255 } 979 1256 980 1257 - (void)vboxReshapePerform 981 1258 { 1259 DEBUG_FUNC_ENTER(); 982 1260 NSRect parentFrame = NSZeroRect; 983 1261 NSPoint parentPos = NSZeroPoint; … … 1071 1349 vboxCtxLeave(&CtxInfo); 1072 1350 } 1351 DEBUG_FUNC_LEAVE(); 1073 1352 } 1074 1353 1075 1354 - (void)createDockTile 1076 1355 { 1356 DEBUG_FUNC_ENTER(); 1077 1357 NSView *pDockScreen = nil; 1078 1358 [self deleteDockTile]; … … 1087 1367 [pDockScreen addSubview:m_DockTileView]; 1088 1368 } 1369 DEBUG_FUNC_LEAVE(); 1089 1370 } 1090 1371 1091 1372 - (void)deleteDockTile 1092 1373 { 1374 DEBUG_FUNC_ENTER(); 1093 1375 if (m_DockTileView != nil) 1094 1376 { … … 1097 1379 m_DockTileView = nil; 1098 1380 } 1381 DEBUG_FUNC_LEAVE(); 1099 1382 } 1100 1383 … … 1137 1420 - (bool)vboxSharedCtxCreate 1138 1421 { 1422 DEBUG_FUNC_ENTER(); 1139 1423 if (m_pSharedGLCtx) 1424 { 1425 DEBUG_FUNC_LEAVE(); 1140 1426 return true; 1427 } 1141 1428 1142 1429 Assert(!m_pBlitter); … … 1145 1432 { 1146 1433 DEBUG_WARN(("m_pBlitter allocation failed")); 1434 DEBUG_FUNC_LEAVE(); 1147 1435 return false; 1148 1436 } … … 1158 1446 RTMemFree(m_pBlitter); 1159 1447 m_pBlitter = NULL; 1448 DEBUG_FUNC_LEAVE(); 1160 1449 return false; 1161 1450 } … … 1173 1462 m_pSharedGLCtx = pSharedGLCtx; 1174 1463 1464 DEBUG_FUNC_LEAVE(); 1175 1465 return true; 1176 1466 } … … 1185 1475 } 1186 1476 1187 - (void)vboxSubmitVisible:(GLboolean)fVisible 1188 { 1189 if (fVisible) 1190 [self performSelectorOnMainThread:@selector(vboxSetVisibleUI) withObject:nil waitUntilDone:NO]; 1477 typedef struct CR_RCD_SETVISIBLE 1478 { 1479 OverlayView *pView; 1480 BOOL fVisible; 1481 } CR_RCD_SETVISIBLE; 1482 1483 static 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 } 1191 1502 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 1528 typedef struct CR_RCD_REPARENT 1529 { 1530 OverlayView *pView; 1531 NSView *pParent; 1532 } CR_RCD_REPARENT; 1533 1534 static 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(); 1203 1584 } 1204 1585 … … 1274 1655 - (void)swapFBO 1275 1656 { 1657 DEBUG_FUNC_ENTER(); 1276 1658 [m_pGLCtx flushBuffer]; 1659 DEBUG_FUNC_LEAVE(); 1277 1660 } 1278 1661 … … 1596 1979 - (void)clearVisibleRegions 1597 1980 { 1981 DEBUG_FUNC_ENTER(); 1598 1982 if(m_paClipRects) 1599 1983 { … … 1602 1986 } 1603 1987 m_cClipRects = 0; 1988 DEBUG_FUNC_LEAVE(); 1604 1989 } 1605 1990 … … 1617 2002 - (void)setVisibleRegions:(GLint)cRects paRects:(const GLint*)paRects 1618 2003 { 2004 DEBUG_FUNC_ENTER(); 1619 2005 GLint cOldRects = m_cClipRects; 1620 2006 … … 1635 2021 memcpy(m_paClipRects, paRects, sizeof(GLint) * 4 * cRects); 1636 2022 } 2023 2024 DEBUG_FUNC_LEAVE(); 1637 2025 } 1638 2026 1639 2027 - (NSView*)dockTileScreen 1640 2028 { 2029 DEBUG_FUNC_ENTER(); 1641 2030 NSView *contentView = [[[NSApplication sharedApplication] dockTile] contentView]; 1642 2031 NSView *screenContent = nil; … … 1648 2037 else if ([contentView respondsToSelector:@selector(screenContent)]) 1649 2038 screenContent = [contentView performSelector:@selector(screenContent)]; 2039 2040 DEBUG_FUNC_LEAVE(); 1650 2041 return screenContent; 1651 2042 } … … 1653 2044 - (void)reshapeDockTile 1654 2045 { 2046 DEBUG_FUNC_ENTER(); 1655 2047 NSRect newFrame = NSZeroRect; 1656 2048 … … 1672 2064 [m_DockTileView setFrame: newFrame]; 1673 2065 } 2066 DEBUG_FUNC_LEAVE(); 1674 2067 } 1675 2068 … … 1683 2076 void cocoaGLCtxCreate(NativeNSOpenGLContextRef *ppCtx, GLbitfield fVisParams, NativeNSOpenGLContextRef pSharedCtx) 1684 2077 { 2078 DEBUG_FUNC_ENTER(); 1685 2079 NSOpenGLPixelFormat *pFmt = nil; 1686 2080 … … 1766 2160 1767 2161 [pPool release]; 2162 2163 DEBUG_FUNC_LEAVE(); 1768 2164 } 1769 2165 1770 2166 void cocoaGLCtxDestroy(NativeNSOpenGLContextRef pCtx) 1771 2167 { 2168 DEBUG_FUNC_ENTER(); 1772 2169 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1773 2170 … … 1776 2173 1777 2174 [pPool release]; 2175 DEBUG_FUNC_LEAVE(); 1778 2176 } 1779 2177 … … 1783 2181 * 1784 2182 ********************************************************************************/ 1785 void cocoaViewCreate(NativeNSViewRef *ppView, WindowInfo *pWinInfo, NativeNSViewRef pParentView, GLbitfield fVisParams) 1786 { 1787 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1788 2183 typedef struct CR_RCD_CREATEVIEW 2184 { 2185 WindowInfo *pWinInfo; 2186 NSView *pParentView; 2187 GLbitfield fVisParams; 2188 /* out */ 2189 OverlayView *pView; 2190 } CR_RCD_CREATEVIEW; 2191 2192 static OverlayView * vboxViewCreate(WindowInfo *pWinInfo, NativeNSViewRef pParentView, GLbitfield fVisParams) 2193 { 2194 DEBUG_FUNC_ENTER(); 1789 2195 /* Create our worker view */ 1790 2196 OverlayView* pView = [[OverlayView alloc] initWithFrame:NSZeroRect thread:RTThreadSelf() parentView:pParentView winInfo:pWinInfo]; … … 1795 2201 [[OverlayWindow alloc] initWithParentView:pParentView overlayView:pView]; 1796 2202 /* 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 2211 static 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 2219 void 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 1800 2246 [pPool release]; 2247 2248 DEBUG_FUNC_LEAVE(); 1801 2249 } 1802 2250 1803 2251 void cocoaViewReparent(NativeNSViewRef pView, NativeNSViewRef pParentView) 1804 2252 { 2253 DEBUG_FUNC_ENTER(); 1805 2254 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1806 2255 … … 1809 2258 if (pOView) 1810 2259 { 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]; 1827 2261 } 1828 2262 1829 2263 [pPool release]; 2264 2265 DEBUG_FUNC_LEAVE(); 2266 } 2267 2268 typedef struct CR_RCD_DESTROYVIEW 2269 { 2270 OverlayView *pView; 2271 } CR_RCD_DESTROYVIEW; 2272 2273 static 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(); 1830 2279 } 1831 2280 1832 2281 void cocoaViewDestroy(NativeNSViewRef pView) 1833 2282 { 1834 NSWindow *pWin = nil; 1835 2283 DEBUG_FUNC_ENTER(); 1836 2284 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1837 2285 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 } 1878 2297 1879 2298 [pPool release]; 2299 DEBUG_FUNC_LEAVE(); 1880 2300 } 1881 2301 1882 2302 void cocoaViewShow(NativeNSViewRef pView, GLboolean fShowIt) 1883 2303 { 2304 DEBUG_FUNC_ENTER(); 1884 2305 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1885 2306 1886 [ pView vboxSubmitVisible:fShowIt];2307 [(OverlayView*)pView vboxSetVisible:fShowIt]; 1887 2308 1888 2309 [pPool release]; 2310 DEBUG_FUNC_LEAVE(); 1889 2311 } 1890 2312 1891 2313 void cocoaViewDisplay(NativeNSViewRef pView) 1892 2314 { 2315 DEBUG_FUNC_ENTER(); 1893 2316 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1894 2317 2318 DEBUG_WARN(("cocoaViewDisplay should never happen!\n")); 1895 2319 DEBUG_MSG_1(("cocoaViewDisplay %p\n", (void*)pView)); 1896 2320 [(OverlayView*)pView swapFBO]; 1897 2321 1898 2322 [pPool release]; 1899 2323 2324 DEBUG_FUNC_LEAVE(); 1900 2325 } 1901 2326 1902 2327 void cocoaViewSetPosition(NativeNSViewRef pView, NativeNSViewRef pParentView, int x, int y) 1903 2328 { 2329 DEBUG_FUNC_ENTER(); 1904 2330 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1905 2331 1906 [(OverlayView*)pView setPos:NSMakePoint(x, y)];2332 [(OverlayView*)pView vboxSetPos:NSMakePoint(x, y)]; 1907 2333 1908 2334 [pPool release]; 2335 2336 DEBUG_FUNC_LEAVE(); 1909 2337 } 1910 2338 1911 2339 void cocoaViewSetSize(NativeNSViewRef pView, int w, int h) 1912 2340 { 2341 DEBUG_FUNC_ENTER(); 1913 2342 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1914 2343 1915 [(OverlayView*)pView setSize:NSMakeSize(w, h)];2344 [(OverlayView*)pView vboxSetSize:NSMakeSize(w, h)]; 1916 2345 1917 2346 [pPool release]; 2347 2348 DEBUG_FUNC_LEAVE(); 2349 } 2350 2351 typedef struct CR_RCD_GETGEOMETRY 2352 { 2353 OverlayView *pView; 2354 NSRect rect; 2355 } CR_RCD_GETGEOMETRY; 2356 2357 static 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(); 1918 2363 } 1919 2364 1920 2365 void cocoaViewGetGeometry(NativeNSViewRef pView, int *pX, int *pY, int *pW, int *pH) 1921 2366 { 2367 DEBUG_FUNC_ENTER(); 1922 2368 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1923 2369 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 1925 2385 *pX = frame.origin.x; 1926 2386 *pY = frame.origin.y; … … 1929 2389 1930 2390 [pPool release]; 2391 2392 DEBUG_FUNC_LEAVE(); 1931 2393 } 1932 2394 1933 2395 void cocoaViewPresentComposition(NativeNSViewRef pView, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry) 1934 2396 { 2397 DEBUG_FUNC_ENTER(); 1935 2398 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1936 2399 NSOpenGLContext *pCtx; … … 1946 2409 1947 2410 [pPool release]; 2411 DEBUG_FUNC_LEAVE(); 1948 2412 return; 1949 2413 } … … 1957 2421 1958 2422 [pPool release]; 2423 2424 DEBUG_FUNC_LEAVE(); 1959 2425 } 1960 2426 1961 2427 void cocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx) 1962 2428 { 2429 DEBUG_FUNC_ENTER(); 1963 2430 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1964 2431 … … 1976 2443 1977 2444 [pPool release]; 2445 2446 DEBUG_FUNC_LEAVE(); 1978 2447 } 1979 2448 1980 2449 GLboolean cocoaViewNeedsEmptyPresent(NativeNSViewRef pView) 1981 2450 { 2451 DEBUG_FUNC_ENTER(); 2452 1982 2453 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1983 2454 … … 1986 2457 [pPool release]; 1987 2458 2459 DEBUG_FUNC_LEAVE(); 2460 1988 2461 return fNeedsPresent; 1989 2462 } … … 1991 2464 void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, const GLint* paRects) 1992 2465 { 2466 DEBUG_FUNC_ENTER(); 1993 2467 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1994 2468 … … 1996 2470 1997 2471 [pPool release]; 1998 } 2472 2473 DEBUG_FUNC_LEAVE(); 2474 }
Note:
See TracChangeset
for help on using the changeset viewer.