VirtualBox

Changeset 27021 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 4, 2010 12:58:38 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: new core: Mac seamless fixes

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  
    3535#include "UIFrameBufferQuartz2D.h"
    3636#include "UIMachineView.h"
     37#include "UIMachineLogic.h"
    3738#include "VBoxUtils.h"
    38 
    39 ///* Needed for checking against seamless mode */
    40 //#include "VBoxConsoleWnd.h"
    41 //#include "VBoxIChatTheaterWrapper.h"
    4239
    4340#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    5249 */
    5350
    54 #ifndef QT_MAC_USE_COCOA
    55 static OSStatus darwinSNWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData)
    56 {
    57     if (     aInUserData
    58         && ::GetEventClass (aInEvent) == kEventClassWindow
    59         && ::GetEventKind (aInEvent) == kEventWindowBoundsChanged)
    60         static_cast<UIFrameBufferQuartz2D *> (aInUserData)->testAndSetSNCarbonFix();
    61 
    62     return ::CallNextEventHandler (aInHandlerCallRef, aInEvent);
    63 }
    64 #endif /* QT_MAC_USE_COCOA */
    65 
    6651UIFrameBufferQuartz2D::UIFrameBufferQuartz2D(UIMachineView *pMachineView)
    6752    : UIFrameBuffer(pMachineView)
     53    , m_pMachineLogic(pMachineView->machineLogic())
    6854    , m_pDataAddress(NULL)
    6955    , m_pBitmapData(NULL)
    7056    , m_uPixelFormat(FramebufferPixelFormat_FOURCC_RGB)
    7157    , 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)
    7860{
    7961    Log (("Quartz2D: Creating\n"));
    80 
    81 #ifndef QT_MAC_USE_COCOA
    82     /* There seems to be a big bug on Snow Leopard regarding hardware
    83      * accelerated image handling in Carbon. If our VM image is used on a
    84      * second monitor it seems not really to be valid. (maybe the OpenGL
    85      * texture is not properly shared between the two contexts). As a
    86      * workaround we make a deep copy on every paint event. This workaround
    87      * should only be in place if we are firstly on Snow Leopard and secondly
    88      * on any screen beside the primary one. To track the current screen, we
    89      * install a event handler for the window move event. Whenever the user
    90      * 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 */
    10662
    10763    UIResizeEvent event(FramebufferPixelFormat_Opaque,
     
    11470    Log (("Quartz2D: Deleting\n"));
    11571    clean();
    116 #ifndef QT_MAC_USE_COCOA
    117     if (mDarwinSNWindowHandlerRef)
    118     {
    119        ::RemoveEventHandler (mDarwinSNWindowHandlerRef);
    120        mDarwinSNWindowHandlerRef = NULL;
    121     }
    122 #endif /* QT_MAC_USE_COCOA */
    12372}
    12473
    12574/** @note This method is called on EMT from under this object's lock */
    126 STDMETHODIMP UIFrameBufferQuartz2D::NotifyUpdate (ULONG aX, ULONG aY,
     75STDMETHODIMP UIFrameBufferQuartz2D::NotifyUpdate(ULONG aX, ULONG aY,
    12776                                                 ULONG aW, ULONG aH)
    12877{
    12978/*    Log (("Quartz2D: NotifyUpdate %d,%d %dx%d\n", aX, aY, aW, aH));*/
    13079
    131     QApplication::postEvent (m_pMachineView,
    132                              new UIRepaintEvent (aX, aY, aW, aH));
     80    QApplication::postEvent(m_pMachineView,
     81                            new UIRepaintEvent (aX, aY, aW, aH));
    13382    return S_OK;
    13483}
    13584
    136 STDMETHODIMP UIFrameBufferQuartz2D::SetVisibleRegion (BYTE *aRectangles, ULONG aCount)
     85STDMETHODIMP UIFrameBufferQuartz2D::SetVisibleRegion(BYTE *aRectangles, ULONG aCount)
    13786{
    13887    PRTRECT rects = (PRTRECT)aRectangles;
     
    14796     * ASMAtomic(Cmp)XchgPtr and a struct { cAllocated; cRects; aRects[1]; }
    14897     * *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);
    15099    if (rgnRcts && rgnRcts->allocated < aCount)
    151100    {
     
    155104    if (!rgnRcts)
    156105    {
    157         ULONG allocated = RT_ALIGN_32 (aCount + 1, 32);
     106        ULONG allocated = RT_ALIGN_32(aCount + 1, 32);
    158107        allocated = RT_MAX (128, allocated);
    159         rgnRcts = (RegionRects *) RTMemAlloc (RT_OFFSETOF (RegionRects, rcts[allocated]));
     108        rgnRcts = (RegionRects *)RTMemAlloc(RT_OFFSETOF(RegionRects, rcts[allocated]));
    160109        if (!rgnRcts)
    161110            return E_OUTOFMEMORY;
     
    170119    {
    171120        QRect rect;
    172         rect.setLeft (rects->xLeft);
    173         rect.setTop (rects->yTop);
     121        rect.setLeft(rects->xLeft);
     122        rect.setTop(rects->yTop);
    174123        /* QRect are inclusive */
    175         rect.setRight (rects->xRight - 1);
    176         rect.setBottom (rects->yBottom - 1);
     124        rect.setRight(rects->xRight - 1);
     125        rect.setBottom(rects->yBottom - 1);
    177126
    178127        /* The rect should intersect with the vm screen. */
    179         rect = vmScreenRect.intersect (rect);
     128        rect = vmScreenRect.intersect(rect);
    180129        ++ rects;
    181130        /* Make sure only valid rects are distributed */
     
    198147//    printf ("..................................\n");
    199148
    200     void *pvOld = ASMAtomicXchgPtr ((void * volatile *) &mRegion, rgnRcts);
     149    void *pvOld = ASMAtomicXchgPtr((void * volatile *)&mRegion, rgnRcts);
    201150    if (    pvOld
    202         &&  !ASMAtomicCmpXchgPtr ((void * volatile *) &mRegionUnused, pvOld, NULL))
     151        &&  !ASMAtomicCmpXchgPtr((void * volatile *)&mRegionUnused, pvOld, NULL))
    203152        RTMemFree (pvOld);
    204153
    205     QApplication::postEvent (m_pMachineView, new UISetRegionEvent (reg));
     154    QApplication::postEvent(m_pMachineView, new UISetRegionEvent (reg));
    206155
    207156    return S_OK;
    208157}
    209158
    210 void UIFrameBufferQuartz2D::paintEvent (QPaintEvent *aEvent)
     159void UIFrameBufferQuartz2D::paintEvent(QPaintEvent *aEvent)
    211160{
    212161    /* For debugging /Developer/Applications/Performance Tools/Quartz
     
    219168//    Assert (VALID_PTR (main));
    220169    QWidget* viewport = m_pMachineView->viewport();
    221     Assert (VALID_PTR (viewport));
     170    Assert(VALID_PTR (viewport));
    222171    /* Get the dimensions of the viewport */
    223     CGRect viewRect = ::darwinToCGRect (viewport->geometry());
     172    CGRect viewRect = ::darwinToCGRect(viewport->geometry());
    224173    /* Get the context of this window from Qt */
    225     CGContextRef ctx = ::darwinToCGContextRef (viewport);
    226     Assert (VALID_PTR (ctx));
     174    CGContextRef ctx = ::darwinToCGContextRef(viewport);
     175    Assert(VALID_PTR (ctx));
    227176
    228177    /* Flip the context */
     
    231180
    232181    /* We handle the seamless mode as a special case. */
    233 //    if (main->isTrueSeamless())
    234     if (0)
     182    if (m_pMachineLogic->visualStateType() == UIVisualStateType_Seamless)
    235183    {
    236184        /* Here we paint the windows without any wallpaper.
     
    247195        }
    248196        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()));
    262198        Assert (VALID_PTR (subImage));
    263199        /* Clear the background (Make the rect fully transparent) */
     
    326262        }
    327263        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));
    340265        Assert (VALID_PTR (subImage));
    341266        /* Ok, for more performance we set a clipping path of the
     
    459384}
    460385
    461 #ifndef QT_MAC_USE_COCOA
    462 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 
    471386#endif /* defined (VBOX_GUI_USE_QUARTZ2D) */
    472387
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.h

    r26781 r27021  
    3232#include <Carbon/Carbon.h>
    3333
     34/* Local forward declarations */
     35class UIMachineLogic;
     36
    3437class UIFrameBufferQuartz2D : public UIFrameBuffer
    3538{
     
    5356    void resizeEvent(UIResizeEvent *pEvent);
    5457
    55 #ifndef QT_MAC_USE_COCOA
    56     void testAndSetSNCarbonFix();
    57 #endif /* QT_MAC_USE_COCOA */
    58 
    5958private:
    6059
    6160    void clean();
    6261
     62    UIMachineLogic *m_pMachineLogic;
    6363    uchar *m_pDataAddress;
    6464    void *m_pBitmapData;
     
    8989    RegionRects volatile *mRegionUnused;
    9090
    91 #ifndef QT_MAC_USE_COCOA
    92     bool mSnowLeoCarbonFix;
    93     EventHandlerRef mDarwinSNWindowHandlerRef;
    94 #endif /* QT_MAC_USE_COCOA */
    9591};
    9692#endif /* Q_WS_MAC && VBOX_GUI_USE_QUARTZ2D */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r27012 r27021  
    284284{
    285285    return verticalScrollBar()->pageStep();
     286}
     287
     288UIMachineLogic* UIMachineView::machineLogic() const
     289{
     290    return machineWindowWrapper()->machineLogic();
    286291}
    287292
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r27015 r27021  
    3939class UIFrameBuffer;
    4040class UIMachineWindow;
     41class UIMachineLogic;
    4142class VBoxGlobalSettings;
    4243#ifdef Q_WS_MAC
     
    117118    UIFrameBuffer* frameBuffer() const { return m_pFrameBuffer; }
    118119    UIMachineWindow* machineWindowWrapper() const { return m_pMachineWindow; }
     120    UIMachineLogic* machineLogic() const;
    119121    bool isHostKeyPressed() const { return m_bIsHostkeyPressed; }
    120122    bool isMachineWindowResizeIgnored() const { return m_bIsMachineWindowResizeIgnored; }
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