Changeset 23899 in vbox
- Timestamp:
- Oct 20, 2009 11:42:26 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 53690
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h
r23346 r23899 475 475 void resizeEvent (VBoxResizeEvent *re); 476 476 477 #ifndef QT_MAC_USE_COCOA 478 void testAndSetSNCarbonFix(); 479 #endif /* QT_MAC_USE_COCOA */ 480 477 481 private: 478 482 … … 506 510 * This is operated with atomic cmpxchg and atomic xchg. */ 507 511 RegionRects volatile *mRegionUnused; 512 513 #ifndef QT_MAC_USE_COCOA 514 bool mSnowLeoCarbonFix; 515 EventHandlerRef mDarwinSNWindowHandlerRef; 516 #endif /* QT_MAC_USE_COCOA */ 508 517 }; 509 518 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp
r23796 r23899 34 34 #include "VBoxIChatTheaterWrapper.h" 35 35 36 #include <QDesktopWidget> 37 38 #include "iprt/system.h" 39 36 40 //#define COMP_WITH_SHADOW 41 //#define OVERLAY_CLIPRECTS 37 42 38 43 /** @class VBoxQuartz2DFrameBuffer … … 42 47 */ 43 48 44 VBoxQuartz2DFrameBuffer::VBoxQuartz2DFrameBuffer (VBoxConsoleView *aView) : 45 VBoxFrameBuffer(aView), 46 mDataAddress(NULL), 47 mBitmapData(NULL), 48 mPixelFormat(FramebufferPixelFormat_FOURCC_RGB), 49 mImage(NULL), 50 mRegion (NULL), 51 mRegionUnused (NULL) 49 #ifndef QT_MAC_USE_COCOA 50 static OSStatus darwinSNWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData) 51 { 52 if ( aInUserData 53 && ::GetEventClass (aInEvent) == kEventClassWindow 54 && ::GetEventKind (aInEvent) == kEventWindowBoundsChanged) 55 static_cast<VBoxQuartz2DFrameBuffer *> (aInUserData)->testAndSetSNCarbonFix(); 56 57 return ::CallNextEventHandler (aInHandlerCallRef, aInEvent); 58 } 59 #endif /* QT_MAC_USE_COCOA */ 60 61 VBoxQuartz2DFrameBuffer::VBoxQuartz2DFrameBuffer (VBoxConsoleView *aView) 62 : VBoxFrameBuffer(aView) 63 , mDataAddress(NULL) 64 , mBitmapData(NULL) 65 , mPixelFormat(FramebufferPixelFormat_FOURCC_RGB) 66 , mImage(NULL) 67 , mRegion (NULL) 68 , mRegionUnused (NULL) 69 #ifndef QT_MAC_USE_COCOA 70 , mSnowLeoCarbonFix (false) 71 , mDarwinSNWindowHandlerRef (NULL) 72 #endif /* QT_MAC_USE_COCOA */ 52 73 { 53 74 Log (("Quartz2D: Creating\n")); 75 76 #ifndef QT_MAC_USE_COCOA 77 /* There seems to be a big bug on Snow Leopard regarding hardware 78 * accelerated image handling in Carbon. If our VM image is used on a 79 * second monitor it seems not really to be valid. (maybe the OpenGL 80 * texture is not properly shared between the two contexts). As a 81 * workaround we make a deep copy on every paint event. This workaround 82 * should only be in place if we are firstly on Snow Leopard and secondly 83 * on any screen beside the primary one. To track the current screen, we 84 * install a event handler for the window move event. Whenever the user 85 * drag the window around we recheck the current screen of the window. */ 86 char szInfo[64]; 87 int rc = RTSystemQueryOSInfo (RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo)); 88 if (RT_SUCCESS (rc) && 89 szInfo[0] == '1') /* higher than 1x.x.x */ 90 { 91 EventTypeSpec eventTypes[] = 92 { 93 { kEventClassWindow, kEventWindowBoundsChanged } 94 }; 95 ::InstallWindowEventHandler (::darwinToNativeWindow (mView->viewport()), darwinSNWindowHandler, RT_ELEMENTS (eventTypes), &eventTypes[0], 96 this, &mDarwinSNWindowHandlerRef); 97 /* Initialize it now */ 98 testAndSetSNCarbonFix(); 99 } 100 #endif /* QT_MAC_USE_COCOA */ 54 101 55 102 VBoxResizeEvent event(FramebufferPixelFormat_Opaque, … … 62 109 Log (("Quartz2D: Deleting\n")); 63 110 clean(); 111 #ifndef QT_MAC_USE_COCOA 112 if (mDarwinSNWindowHandlerRef) 113 { 114 ::RemoveEventHandler (mDarwinSNWindowHandlerRef); 115 mDarwinSNWindowHandlerRef = NULL; 116 } 117 #endif /* QT_MAC_USE_COCOA */ 64 118 } 65 119 … … 187 241 } 188 242 else 189 subImage = CGImageCreateWithImageInRect (mImage, CGRectMake (mView->contentsX(), mView->contentsY(), mView->visibleWidth(), mView->visibleHeight())); 243 { 244 245 #ifndef QT_MAC_USE_COCOA 246 /* For the reason of this see the constructor. */ 247 if (mSnowLeoCarbonFix) 248 { 249 CGImageRef copy = CGImageCreateCopy (mImage); 250 subImage = CGImageCreateWithImageInRect (copy, CGRectMake (mView->contentsX(), mView->contentsY(), mView->visibleWidth(), mView->visibleHeight())); 251 CGImageRelease (copy); 252 }else 253 #endif /* QT_MAC_USE_COCOA */ 254 subImage = CGImageCreateWithImageInRect (mImage, CGRectMake (mView->contentsX(), mView->contentsY(), mView->visibleWidth(), mView->visibleHeight())); 255 } 190 256 Assert (VALID_PTR (subImage)); 191 257 /* Clear the background (Make the rect fully transparent) */ 192 258 CGContextClearRect (ctx, viewRect); 259 #ifdef OVERLAY_CLIPRECTS 260 CGContextSetRGBFillColor (ctx, 0.0, 0.0, 5.0, 0.7); 261 CGContextFillRect (ctx, viewRect); 262 #endif 193 263 #ifdef COMP_WITH_SHADOW 194 264 /* Enable shadows */ … … 222 292 #endif 223 293 CGImageRelease (subImage); 294 #ifdef OVERLAY_CLIPRECTS 295 if (rgnRcts && rgnRcts->used > 0) 296 { 297 CGContextBeginPath (ctx); 298 CGContextAddRects (ctx, rgnRcts->rcts, rgnRcts->used); 299 CGContextSetRGBStrokeColor (ctx, 1.0, 0.0, 0.0, 0.7); 300 CGContextDrawPath (ctx, kCGPathStroke); 301 } 302 CGContextSetRGBStrokeColor (ctx, 0.0, 1.0, 0.0, 0.7); 303 CGContextStrokeRect (ctx, viewRect); 304 #endif 224 305 } 225 306 else … … 239 320 } 240 321 else 241 subImage = CGImageCreateWithImageInRect (mImage, ::darwinToCGRect (is)); 322 { 323 #ifndef QT_MAC_USE_COCOA 324 /* For the reason of this see the constructor. */ 325 if (mSnowLeoCarbonFix) 326 { 327 CGImageRef copy = CGImageCreateCopy (mImage); 328 subImage = CGImageCreateWithImageInRect (copy, ::darwinToCGRect (is)); 329 CGImageRelease (copy); 330 }else 331 #endif /* QT_MAC_USE_COCOA */ 332 subImage = CGImageCreateWithImageInRect (mImage, ::darwinToCGRect (is)); 333 } 242 334 Assert (VALID_PTR (subImage)); 243 335 /* Ok, for more performance we set a clipping path of the … … 361 453 } 362 454 455 #ifndef QT_MAC_USE_COCOA 456 void VBoxQuartz2DFrameBuffer::testAndSetSNCarbonFix() 457 { 458 QWidget* viewport = mView->viewport(); 459 Assert (VALID_PTR (viewport)); 460 QDesktopWidget dw; 461 mSnowLeoCarbonFix = dw.primaryScreen() != dw.screenNumber (viewport); 462 } 463 #endif /* QT_MAC_USE_COCOA */ 464 363 465 #endif /* defined (VBOX_GUI_USE_QUARTZ2D) */
Note:
See TracChangeset
for help on using the changeset viewer.