Changeset 27021 in vbox for trunk/src/VBox
- Timestamp:
- Mar 4, 2010 12:58:38 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.cpp
r26781 r27021 35 35 #include "UIFrameBufferQuartz2D.h" 36 36 #include "UIMachineView.h" 37 #include "UIMachineLogic.h" 37 38 #include "VBoxUtils.h" 38 39 ///* Needed for checking against seamless mode */40 //#include "VBoxConsoleWnd.h"41 //#include "VBoxIChatTheaterWrapper.h"42 39 43 40 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 52 49 */ 53 50 54 #ifndef QT_MAC_USE_COCOA55 static OSStatus darwinSNWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData)56 {57 if ( aInUserData58 && ::GetEventClass (aInEvent) == kEventClassWindow59 && ::GetEventKind (aInEvent) == kEventWindowBoundsChanged)60 static_cast<UIFrameBufferQuartz2D *> (aInUserData)->testAndSetSNCarbonFix();61 62 return ::CallNextEventHandler (aInHandlerCallRef, aInEvent);63 }64 #endif /* QT_MAC_USE_COCOA */65 66 51 UIFrameBufferQuartz2D::UIFrameBufferQuartz2D(UIMachineView *pMachineView) 67 52 : UIFrameBuffer(pMachineView) 53 , m_pMachineLogic(pMachineView->machineLogic()) 68 54 , m_pDataAddress(NULL) 69 55 , m_pBitmapData(NULL) 70 56 , m_uPixelFormat(FramebufferPixelFormat_FOURCC_RGB) 71 57 , m_image(NULL) 72 , mRegion (NULL) 73 , mRegionUnused (NULL) 74 #ifndef QT_MAC_USE_COCOA 75 , mSnowLeoCarbonFix (false) 76 , mDarwinSNWindowHandlerRef (NULL) 77 #endif /* QT_MAC_USE_COCOA */ 58 , mRegion(NULL) 59 , mRegionUnused(NULL) 78 60 { 79 61 Log (("Quartz2D: Creating\n")); 80 81 #ifndef QT_MAC_USE_COCOA82 /* There seems to be a big bug on Snow Leopard regarding hardware83 * accelerated image handling in Carbon. If our VM image is used on a84 * second monitor it seems not really to be valid. (maybe the OpenGL85 * texture is not properly shared between the two contexts). As a86 * workaround we make a deep copy on every paint event. This workaround87 * should only be in place if we are firstly on Snow Leopard and secondly88 * on any screen beside the primary one. To track the current screen, we89 * install a event handler for the window move event. Whenever the user90 * drag the window around we recheck the current screen of the window. */91 char szInfo[64];92 int rc = RTSystemQueryOSInfo (RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo));93 if (RT_SUCCESS (rc) &&94 szInfo[0] == '1') /* higher than 1x.x.x */95 {96 EventTypeSpec eventTypes[] =97 {98 { kEventClassWindow, kEventWindowBoundsChanged }99 };100 ::InstallWindowEventHandler (::darwinToNativeWindow (m_pMachineView->viewport()), darwinSNWindowHandler, RT_ELEMENTS (eventTypes), &eventTypes[0],101 this, &mDarwinSNWindowHandlerRef);102 /* Initialize it now */103 testAndSetSNCarbonFix();104 }105 #endif /* QT_MAC_USE_COCOA */106 62 107 63 UIResizeEvent event(FramebufferPixelFormat_Opaque, … … 114 70 Log (("Quartz2D: Deleting\n")); 115 71 clean(); 116 #ifndef QT_MAC_USE_COCOA117 if (mDarwinSNWindowHandlerRef)118 {119 ::RemoveEventHandler (mDarwinSNWindowHandlerRef);120 mDarwinSNWindowHandlerRef = NULL;121 }122 #endif /* QT_MAC_USE_COCOA */123 72 } 124 73 125 74 /** @note This method is called on EMT from under this object's lock */ 126 STDMETHODIMP UIFrameBufferQuartz2D::NotifyUpdate 75 STDMETHODIMP UIFrameBufferQuartz2D::NotifyUpdate(ULONG aX, ULONG aY, 127 76 ULONG aW, ULONG aH) 128 77 { 129 78 /* Log (("Quartz2D: NotifyUpdate %d,%d %dx%d\n", aX, aY, aW, aH));*/ 130 79 131 QApplication::postEvent 132 80 QApplication::postEvent(m_pMachineView, 81 new UIRepaintEvent (aX, aY, aW, aH)); 133 82 return S_OK; 134 83 } 135 84 136 STDMETHODIMP UIFrameBufferQuartz2D::SetVisibleRegion 85 STDMETHODIMP UIFrameBufferQuartz2D::SetVisibleRegion(BYTE *aRectangles, ULONG aCount) 137 86 { 138 87 PRTRECT rects = (PRTRECT)aRectangles; … … 147 96 * ASMAtomic(Cmp)XchgPtr and a struct { cAllocated; cRects; aRects[1]; } 148 97 * *mRegion, *mUnusedRegion; should suffice (and permit you to reuse allocations). */ 149 RegionRects *rgnRcts = (RegionRects *) ASMAtomicXchgPtr((void * volatile *) &mRegionUnused, NULL);98 RegionRects *rgnRcts = (RegionRects *)ASMAtomicXchgPtr((void * volatile *) &mRegionUnused, NULL); 150 99 if (rgnRcts && rgnRcts->allocated < aCount) 151 100 { … … 155 104 if (!rgnRcts) 156 105 { 157 ULONG allocated = RT_ALIGN_32 106 ULONG allocated = RT_ALIGN_32(aCount + 1, 32); 158 107 allocated = RT_MAX (128, allocated); 159 rgnRcts = (RegionRects *) RTMemAlloc (RT_OFFSETOF(RegionRects, rcts[allocated]));108 rgnRcts = (RegionRects *)RTMemAlloc(RT_OFFSETOF(RegionRects, rcts[allocated])); 160 109 if (!rgnRcts) 161 110 return E_OUTOFMEMORY; … … 170 119 { 171 120 QRect rect; 172 rect.setLeft 173 rect.setTop 121 rect.setLeft(rects->xLeft); 122 rect.setTop(rects->yTop); 174 123 /* QRect are inclusive */ 175 rect.setRight 176 rect.setBottom 124 rect.setRight(rects->xRight - 1); 125 rect.setBottom(rects->yBottom - 1); 177 126 178 127 /* The rect should intersect with the vm screen. */ 179 rect = vmScreenRect.intersect 128 rect = vmScreenRect.intersect(rect); 180 129 ++ rects; 181 130 /* Make sure only valid rects are distributed */ … … 198 147 // printf ("..................................\n"); 199 148 200 void *pvOld = ASMAtomicXchgPtr ((void * volatile *)&mRegion, rgnRcts);149 void *pvOld = ASMAtomicXchgPtr((void * volatile *)&mRegion, rgnRcts); 201 150 if ( pvOld 202 && !ASMAtomicCmpXchgPtr ((void * volatile *)&mRegionUnused, pvOld, NULL))151 && !ASMAtomicCmpXchgPtr((void * volatile *)&mRegionUnused, pvOld, NULL)) 203 152 RTMemFree (pvOld); 204 153 205 QApplication::postEvent 154 QApplication::postEvent(m_pMachineView, new UISetRegionEvent (reg)); 206 155 207 156 return S_OK; 208 157 } 209 158 210 void UIFrameBufferQuartz2D::paintEvent 159 void UIFrameBufferQuartz2D::paintEvent(QPaintEvent *aEvent) 211 160 { 212 161 /* For debugging /Developer/Applications/Performance Tools/Quartz … … 219 168 // Assert (VALID_PTR (main)); 220 169 QWidget* viewport = m_pMachineView->viewport(); 221 Assert 170 Assert(VALID_PTR (viewport)); 222 171 /* Get the dimensions of the viewport */ 223 CGRect viewRect = ::darwinToCGRect 172 CGRect viewRect = ::darwinToCGRect(viewport->geometry()); 224 173 /* Get the context of this window from Qt */ 225 CGContextRef ctx = ::darwinToCGContextRef 226 Assert 174 CGContextRef ctx = ::darwinToCGContextRef(viewport); 175 Assert(VALID_PTR (ctx)); 227 176 228 177 /* Flip the context */ … … 231 180 232 181 /* We handle the seamless mode as a special case. */ 233 // if (main->isTrueSeamless()) 234 if (0) 182 if (m_pMachineLogic->visualStateType() == UIVisualStateType_Seamless) 235 183 { 236 184 /* Here we paint the windows without any wallpaper. … … 247 195 } 248 196 else 249 { 250 251 #ifndef QT_MAC_USE_COCOA 252 /* For the reason of this see the constructor. */ 253 if (mSnowLeoCarbonFix) 254 { 255 CGImageRef copy = CGImageCreateCopy (m_image); 256 subImage = CGImageCreateWithImageInRect (copy, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight())); 257 CGImageRelease (copy); 258 }else 259 #endif /* QT_MAC_USE_COCOA */ 260 subImage = CGImageCreateWithImageInRect (m_image, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight())); 261 } 197 subImage = CGImageCreateWithImageInRect (m_image, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight())); 262 198 Assert (VALID_PTR (subImage)); 263 199 /* Clear the background (Make the rect fully transparent) */ … … 326 262 } 327 263 else 328 { 329 #ifndef QT_MAC_USE_COCOA 330 /* For the reason of this see the constructor. */ 331 if (mSnowLeoCarbonFix) 332 { 333 CGImageRef copy = CGImageCreateCopy (m_image); 334 subImage = CGImageCreateWithImageInRect (copy, ::darwinToCGRect (is)); 335 CGImageRelease (copy); 336 }else 337 #endif /* QT_MAC_USE_COCOA */ 338 subImage = CGImageCreateWithImageInRect (m_image, ::darwinToCGRect (is)); 339 } 264 subImage = CGImageCreateWithImageInRect (m_image, ::darwinToCGRect (is)); 340 265 Assert (VALID_PTR (subImage)); 341 266 /* Ok, for more performance we set a clipping path of the … … 459 384 } 460 385 461 #ifndef QT_MAC_USE_COCOA462 void UIFrameBufferQuartz2D::testAndSetSNCarbonFix()463 {464 QWidget* viewport = m_pMachineView->viewport();465 Assert (VALID_PTR (viewport));466 QDesktopWidget dw;467 mSnowLeoCarbonFix = dw.primaryScreen() != dw.screenNumber (viewport);468 }469 #endif /* QT_MAC_USE_COCOA */470 471 386 #endif /* defined (VBOX_GUI_USE_QUARTZ2D) */ 472 387 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.h
r26781 r27021 32 32 #include <Carbon/Carbon.h> 33 33 34 /* Local forward declarations */ 35 class UIMachineLogic; 36 34 37 class UIFrameBufferQuartz2D : public UIFrameBuffer 35 38 { … … 53 56 void resizeEvent(UIResizeEvent *pEvent); 54 57 55 #ifndef QT_MAC_USE_COCOA56 void testAndSetSNCarbonFix();57 #endif /* QT_MAC_USE_COCOA */58 59 58 private: 60 59 61 60 void clean(); 62 61 62 UIMachineLogic *m_pMachineLogic; 63 63 uchar *m_pDataAddress; 64 64 void *m_pBitmapData; … … 89 89 RegionRects volatile *mRegionUnused; 90 90 91 #ifndef QT_MAC_USE_COCOA92 bool mSnowLeoCarbonFix;93 EventHandlerRef mDarwinSNWindowHandlerRef;94 #endif /* QT_MAC_USE_COCOA */95 91 }; 96 92 #endif /* Q_WS_MAC && VBOX_GUI_USE_QUARTZ2D */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r27012 r27021 284 284 { 285 285 return verticalScrollBar()->pageStep(); 286 } 287 288 UIMachineLogic* UIMachineView::machineLogic() const 289 { 290 return machineWindowWrapper()->machineLogic(); 286 291 } 287 292 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r27015 r27021 39 39 class UIFrameBuffer; 40 40 class UIMachineWindow; 41 class UIMachineLogic; 41 42 class VBoxGlobalSettings; 42 43 #ifdef Q_WS_MAC … … 117 118 UIFrameBuffer* frameBuffer() const { return m_pFrameBuffer; } 118 119 UIMachineWindow* machineWindowWrapper() const { return m_pMachineWindow; } 120 UIMachineLogic* machineLogic() const; 119 121 bool isHostKeyPressed() const { return m_bIsHostkeyPressed; } 120 122 bool isMachineWindowResizeIgnored() const { return m_bIsMachineWindowResizeIgnored; }
Note:
See TracChangeset
for help on using the changeset viewer.