Changeset 53599 in vbox
- Timestamp:
- Dec 22, 2014 11:50:11 AM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 97362
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.h
r53206 r53599 24 24 RT_C_DECLS_BEGIN 25 25 26 #ifndef ___renderspu_cocoa_helper_h 26 27 ADD_COCOA_NATIVE_REF(NSView); 27 28 ADD_COCOA_NATIVE_REF(NSOpenGLContext); 29 #endif 28 30 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 37 VMSVGA3D_DECL(void) vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pSharedCtx); 38 VMSVGA3D_DECL(void) vmsvga3dCocoaDestroyContext(NativeNSOpenGLContextRef pCtx); 39 VMSVGA3D_DECL(void) vmsvga3dCocoaCreateView(NativeNSViewRef *ppView, NativeNSViewRef pParentView); 40 VMSVGA3D_DECL(void) vmsvga3dCocoaDestroyView(NativeNSViewRef pView); 41 VMSVGA3D_DECL(void) vmsvga3dCocoaViewSetPosition(NativeNSViewRef pView, NativeNSViewRef pParentView, int x, int y); 42 VMSVGA3D_DECL(void) vmsvga3dCocoaViewSetSize(NativeNSViewRef pView, int w, int h); 43 VMSVGA3D_DECL(void) vmsvga3dCocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx); 44 VMSVGA3D_DECL(void) vmsvga3dCocoaSwapBuffers(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx); 37 45 38 46 RT_C_DECLS_END 39 47 40 48 #endif /* !__DevVGA_SVGA3d_cocoa_h */ 49 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.m
r53594 r53599 1 1 /** @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. 3 5 */ 4 6 … … 21 23 #include <iprt/thread.h> 22 24 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 23 62 # define DEBUG_MSG(text) \ 24 63 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 29 69 # define DEBUG_MSG_1(text) \ 30 70 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 31 76 #endif 32 77 33 78 # define CHECK_GL_ERROR()\ 34 79 do {} while (0) 80 35 81 36 82 /** Custom OpenGL context class. … … 56 102 NSOpenGLContext *m_pGLCtx; 57 103 58 /* position/size*/104 /* Position/Size tracking */ 59 105 NSPoint m_Pos; 60 106 NSSize m_Size; … … 122 168 -(id)initWithFormat:(NSOpenGLPixelFormat*)format shareContext:(NSOpenGLContext*)share 123 169 { 170 DEBUG_FUNC_ENTER(); 171 124 172 m_pPixelFormat = NULL; 125 173 m_pView = NULL; … … 130 178 131 179 DEBUG_MSG(("OCTX(%p): init VMSVGA3DOpenGLContext\n", (void*)self)); 132 180 DEBUG_FUNC_RET(("%p\n", (void *)self)); 133 181 return self; 134 182 } … … 136 184 - (void)dealloc 137 185 { 186 DEBUG_FUNC_ENTER(); 138 187 DEBUG_MSG(("OCTX(%p): dealloc VMSVGA3DOpenGLContext\n", (void*)self)); 139 188 140 189 [m_pPixelFormat release]; 141 190 191 m_pPixelFormat = NULL; 192 m_pView = NULL; 193 142 194 [super dealloc]; 195 DEBUG_FUNC_LEAVE(); 143 196 } 144 197 145 198 -(bool)isDoubleBuffer 146 199 { 200 DEBUG_FUNC_ENTER(); 147 201 GLint val; 148 202 [m_pPixelFormat getValues:&val forAttribute:NSOpenGLPFADoubleBuffer forVirtualScreen:0]; 203 DEBUG_FUNC_RET(("%d\n", val == 1 ? YES : NO)); 149 204 return val == 1 ? YES : NO; 150 205 } … … 152 207 -(void)setView:(NSView*)view 153 208 { 209 DEBUG_FUNC_ENTER(); 154 210 DEBUG_MSG(("OCTX(%p): setView: new view: %p\n", (void*)self, (void*)view)); 155 211 156 212 m_pView = view; 213 214 DEBUG_FUNC_LEAVE(); 157 215 } 158 216 159 217 -(NSView*)view 160 218 { 219 DEBUG_FUNC_ENTER(); 220 DEBUG_FUNC_RET(("%p\n", (void *)m_pView)); 161 221 return m_pView; 162 222 } … … 164 224 -(void)clearDrawable 165 225 { 226 DEBUG_FUNC_ENTER(); 166 227 DEBUG_MSG(("OCTX(%p): clearDrawable\n", (void*)self)); 167 228 168 m_pView = NULL; ;229 m_pView = NULL; 169 230 [super clearDrawable]; 231 232 DEBUG_FUNC_LEAVE(); 170 233 } 171 234 172 235 -(NSOpenGLPixelFormat*)openGLPixelFormat 173 236 { 237 DEBUG_FUNC_ENTER(); 238 DEBUG_FUNC_RET(("%p\n", (void *)m_pPixelFormat)); 174 239 return m_pPixelFormat; 175 240 } … … 178 243 179 244 180 181 @implementation VMSVGA3DOverlayView182 183 - (id)initWithFrame:(NSRect) frame parentView:(NSView*)pParentView184 {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*)pCtx198 {199 if (m_pGLCtx == pCtx)200 return;201 if (m_pGLCtx)202 [m_pGLCtx clearDrawable];203 m_pGLCtx = pCtx;204 }205 206 - (NSOpenGLContext*)glCtx207 {208 return m_pGLCtx;209 }210 211 - (void)setOverlayWin:(NSWindow*)pWin212 {213 m_pOverlayWin = pWin;214 }215 216 - (NSWindow*)overlayWin217 {218 return m_pOverlayWin;219 }220 221 - (void)setPos:(NSPoint)pos222 {223 m_Pos = pos;224 [self reshape];225 }226 227 - (NSPoint)pos228 {229 return m_Pos;230 }231 232 - (void)setSize:(NSSize)size233 {234 m_Size = size;235 [self reshape];236 }237 238 - (NSSize)size239 {240 return m_Size;241 }242 243 - (void)updateViewportCS244 {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)reshape255 {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 bit265 * 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 out279 * of the parent window. So intersect both frames & use the result as the new280 * 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 is298 * 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 0313 /* 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 #endif325 }326 327 @end328 245 329 246 /******************************************************************************** … … 336 253 -(id)initWithOverlayWindow:(VMSVGA3DOverlayWindow*)pOverlayWindow 337 254 { 255 DEBUG_FUNC_ENTER(); 256 338 257 self = [super initWithFrame:NSZeroRect]; 339 258 340 259 m_pOverlayWindow = pOverlayWindow; 341 260 261 DEBUG_MSG(("OHVW(%p): init OverlayHelperView\n", (void*)self)); 262 DEBUG_FUNC_RET(("%p\n", (void *)self)); 342 263 return self; 343 264 } … … 345 266 -(void)viewDidMoveToWindow 346 267 { 268 DEBUG_FUNC_ENTER(); 347 269 DEBUG_MSG(("OHVW(%p): viewDidMoveToWindow: new win: %p\n", (void*)self, (void*)[self window])); 348 270 349 271 [m_pOverlayWindow parentWindowChanged:[self window]]; 272 273 DEBUG_FUNC_LEAVE(); 350 274 } 351 275 352 276 @end 353 354 277 355 278 /******************************************************************************** … … 362 285 - (id)initWithParentView:(NSView*)pParentView overlayView:(VMSVGA3DOverlayView*)pOverlayView 363 286 { 287 DEBUG_FUNC_ENTER(); 364 288 NSWindow *pParentWin = nil; 365 289 … … 404 328 } 405 329 DEBUG_MSG(("OWIN(%p): init OverlayWindow\n", (void*)self)); 406 330 DEBUG_FUNC_RET(("%p\n", (void *)self)); 407 331 return self; 408 332 } … … 410 334 - (void)dealloc 411 335 { 336 DEBUG_FUNC_ENTER(); 412 337 DEBUG_MSG(("OWIN(%p): dealloc OverlayWindow\n", (void*)self)); 413 338 … … 418 343 419 344 [super dealloc]; 345 DEBUG_FUNC_LEAVE(); 420 346 } 421 347 422 348 - (void)parentWindowFrameChanged:(NSNotification*)pNote 423 349 { 350 DEBUG_FUNC_ENTER(); 424 351 DEBUG_MSG(("OWIN(%p): parentWindowFrameChanged\n", (void*)self)); 425 352 426 353 [m_pOverlayView reshape]; 354 355 DEBUG_FUNC_LEAVE(); 427 356 } 428 357 429 358 - (void)parentWindowChanged:(NSWindow*)pWindow 430 359 { 360 DEBUG_FUNC_ENTER(); 431 361 DEBUG_MSG(("OWIN(%p): parentWindowChanged\n", (void*)self)); 432 362 … … 445 375 [m_pOverlayView reshape]; 446 376 } 377 378 DEBUG_FUNC_LEAVE(); 447 379 } 448 380 449 381 @end 450 382 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 451 624 452 625 void vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pShareCtx) 453 626 { 627 DEBUG_FUNC_ENTER(); 454 628 NSOpenGLPixelFormat *pFmt = nil; 455 456 629 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 457 630 … … 487 660 { 488 661 *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)); 490 663 } 491 664 492 665 [pPool release]; 666 667 DEBUG_FUNC_LEAVE(); 493 668 } 494 669 495 670 void vmsvga3dCocoaDestroyContext(NativeNSOpenGLContextRef pCtx) 496 671 { 672 DEBUG_FUNC_ENTER(); 497 673 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 498 674 [pCtx release]; 499 675 [pPool release]; 676 DEBUG_FUNC_LEAVE(); 500 677 } 501 678 502 679 void vmsvga3dCocoaCreateView(NativeNSViewRef *ppView, NativeNSViewRef pParentView) 503 680 { 681 DEBUG_FUNC_ENTER(); 504 682 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 505 683 … … 516 694 517 695 [pPool release]; 696 DEBUG_FUNC_LEAVE(); 518 697 } 519 698 520 699 void vmsvga3dCocoaDestroyView(NativeNSViewRef pView) 521 700 { 701 DEBUG_FUNC_ENTER(); 522 702 NSWindow *pWin = nil; 523 703 … … 527 707 [pWin release]; 528 708 [pView release]; 709 529 710 [pPool release]; 711 DEBUG_FUNC_LEAVE(); 530 712 } 531 713 532 714 void vmsvga3dCocoaViewSetPosition(NativeNSViewRef pView, NativeNSViewRef pParentView, int x, int y) 533 715 { 716 DEBUG_FUNC_ENTER(); 534 717 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 535 718 … … 541 724 void vmsvga3dCocoaViewSetSize(NativeNSViewRef pView, int w, int h) 542 725 { 726 DEBUG_FUNC_ENTER(); 543 727 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 544 728 … … 546 730 547 731 [pPool release]; 732 DEBUG_FUNC_LEAVE(); 548 733 } 549 734 550 735 void vmsvga3dCocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx) 551 736 { 737 DEBUG_FUNC_ENTER(); 552 738 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 553 739 … … 557 743 { 558 744 [(VMSVGA3DOverlayView*)pView setGLCtx:pCtx]; 559 / / [(VMSVGA3DOverlayView*)pView makeCurrentFBO];745 /* [(VMSVGA3DOverlayView*)pView makeCurrentFBO];*/ 560 746 [pCtx makeCurrentContext]; 561 747 } … … 566 752 567 753 [pPool release]; 568 } 569 570 void vmsvga3dCocoaSwapBuffers(NativeNSOpenGLContextRef pCtx) 571 { 754 DEBUG_FUNC_LEAVE(); 755 } 756 757 void vmsvga3dCocoaSwapBuffers(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx) 758 { 759 DEBUG_FUNC_ENTER(); 572 760 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 573 761 … … 575 763 576 764 [pPool release]; 577 } 765 DEBUG_FUNC_LEAVE(); 766 }
Note:
See TracChangeset
for help on using the changeset viewer.