VirtualBox

Ignore:
Timestamp:
Mar 2, 2015 7:09:13 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: 6227: Step-by-step reworking frame-buffer to move COM implementation into more specific part (step 04).

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r54463 r54590  
    491491        src/medium/UIMediumManager.cpp \
    492492        src/runtime/UIActionPoolRuntime.cpp \
     493        src/runtime/UIFrameBuffer.cpp \
    493494        src/runtime/UIIndicatorsPool.cpp \
    494495        src/runtime/UIStatusBarEditorWindow.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.h

    r54105 r54590  
    18391839};
    18401840
    1841 class VBoxOverlayFrameBuffer : public UIFrameBuffer
    1842 {
    1843 public:
    1844     VBoxOverlayFrameBuffer()
    1845     {
    1846     }
    1847 
    1848     HRESULT init(UIMachineView *pView, CSession * aSession, uint32_t id)
    1849     {
    1850         mpView = pView;
    1851         UIFrameBuffer::init(mpView);
    1852         mOverlay.init(mpView->viewport(), mpView, aSession, id),
    1853         /* sync with framebuffer */
    1854         mOverlay.onResizeEventPostprocess (VBoxFBSizeInfo(this), QPoint(mpView->contentsX(), mpView->contentsY()));
    1855         return S_OK;
    1856     }
    1857 
    1858     STDMETHOD(ProcessVHWACommand)(BYTE *pCommand)
    1859     {
    1860         int rc;
    1861         UIFrameBuffer::lock();
    1862         /* Make sure frame-buffer is used: */
    1863         if (UIFrameBuffer::m_fUnused)
    1864         {
    1865             LogRel2(("ProcessVHWACommand: Postponed!\n"));
    1866             /* Unlock access to frame-buffer: */
    1867             UIFrameBuffer::unlock();
    1868             /* tell client to pend ProcessVHWACommand */
    1869             return E_ACCESSDENIED;
    1870         }
    1871         rc = mOverlay.onVHWACommand ((struct VBOXVHWACMD*)pCommand);
    1872         UIFrameBuffer::unlock();
    1873         if (rc == VINF_CALLBACK_RETURN)
    1874             return S_OK;
    1875         else if (RT_SUCCESS(rc))
    1876             return S_FALSE;
    1877         else if (rc == VERR_INVALID_STATE)
    1878             return E_ACCESSDENIED;
    1879         return E_FAIL;
    1880     }
    1881 
    1882     void doProcessVHWACommand (QEvent * pEvent)
    1883     {
    1884         mOverlay.onVHWACommandEvent (pEvent);
    1885     }
    1886 
    1887     STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY,
    1888                              ULONG aW, ULONG aH)
    1889     {
    1890         HRESULT hr = S_OK;
    1891         UIFrameBuffer::lock();
    1892         /* Make sure frame-buffer is used: */
    1893         if (UIFrameBuffer::m_fUnused)
    1894         {
    1895             LogRel2(("NotifyUpdate: Ignored!\n"));
    1896             mOverlay.onNotifyUpdateIgnore (aX, aY, aW, aH);
    1897             /* Unlock access to frame-buffer: */
    1898             UIFrameBuffer::unlock();
    1899             /*can we actually ignore the notify update?*/
    1900             /* Ignore NotifyUpdate: */
    1901             return E_FAIL;
    1902         }
    1903 
    1904         if (!mOverlay.onNotifyUpdate (aX, aY, aW, aH))
    1905             hr = UIFrameBuffer::NotifyUpdate (aX, aY, aW, aH);
    1906         UIFrameBuffer::unlock();
    1907         return hr;
    1908     }
    1909 
    1910     void performResize(int iWidth, int iHeight)
    1911     {
    1912         UIFrameBuffer::performResize(iWidth, iHeight);
    1913         mOverlay.onResizeEventPostprocess(VBoxFBSizeInfo(this),
    1914                 QPoint(mpView->contentsX(), mpView->contentsY()));
    1915     }
    1916 
    1917     void performRescale()
    1918     {
    1919         UIFrameBuffer::performRescale();
    1920         mOverlay.onResizeEventPostprocess(VBoxFBSizeInfo(this),
    1921                 QPoint(mpView->contentsX(), mpView->contentsY()));
    1922     }
    1923 
    1924     void viewportResized (QResizeEvent * re)
    1925     {
    1926         mOverlay.onViewportResized (re);
    1927         UIFrameBuffer::viewportResized (re);
    1928     }
    1929 
    1930     void viewportScrolled (int dx, int dy)
    1931     {
    1932         mOverlay.onViewportScrolled (QPoint(mpView->contentsX(), mpView->contentsY()));
    1933         UIFrameBuffer::viewportScrolled (dx, dy);
    1934     }
    1935 
    1936     void setView(UIMachineView * pView)
    1937     {
    1938         /* lock to ensure we do not collide with the EMT thread passing commands to us */
    1939         UIFrameBuffer::lock();
    1940         UIFrameBuffer::setView(pView);
    1941         mpView = pView;
    1942         mOverlay.updateAttachment(pView ? pView->viewport() : NULL, pView);
    1943         UIFrameBuffer::unlock();
    1944     }
    1945 
    1946 private:
    1947     VBoxQGLOverlay mOverlay;
    1948     UIMachineView *mpView;
    1949 };
    1950 
    19511841#endif
    19521842
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r54589 r54590  
    55
    66/*
    7  * Copyright (C) 2010-2014 Oracle Corporation
     7 * Copyright (C) 2010-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
    2121/* Qt includes: */
     22# include <QImage>
     23# include <QRegion>
    2224# include <QPainter>
     25# include <QTransform>
    2326/* GUI includes: */
    2427# include "UIFrameBuffer.h"
     
    3336#  include "UIMachineWindow.h"
    3437# endif /* VBOX_WITH_MASKED_SEAMLESS */
     38# ifdef VBOX_WITH_VIDEOHWACCEL
     39#  include "VBoxFBOverlay.h"
     40# endif /* VBOX_WITH_VIDEOHWACCEL */
    3541/* COM includes: */
    3642# include "CConsole.h"
    3743# include "CDisplay.h"
    3844# include "CFramebuffer.h"
     45# include "CDisplaySourceBitmap.h"
    3946#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    4047
    4148/* Other VBox includes: */
     49#include <iprt/critsect.h>
    4250#include <VBox/VBoxVideo3D.h>
     51
     52#ifdef Q_WS_X11
     53/* X11 includes: */
     54# include <QX11Info>
     55# include <X11/Xlib.h>
     56#endif /* Q_WS_X11 */
     57
     58
     59/** IFramebuffer implementation used to maintain VM display video memory. */
     60class ATL_NO_VTABLE UIFrameBufferPrivate : public QObject,
     61                                           public CComObjectRootEx<CComMultiThreadModel>,
     62                                           VBOX_SCRIPTABLE_IMPL(IFramebuffer)
     63{
     64    Q_OBJECT;
     65
     66signals:
     67
     68    /** Notifies listener about guest-screen resolution changes. */
     69    void sigNotifyChange(int iWidth, int iHeight);
     70    /** Notifies listener about guest-screen updates. */
     71    void sigNotifyUpdate(int iX, int iY, int iWidth, int iHeight);
     72    /** Notifies listener about guest-screen visible-region changes. */
     73    void sigSetVisibleRegion(QRegion region);
     74    /** Notifies listener about guest 3D capability changes. */
     75    void sigNotifyAbout3DOverlayVisibilityChange(bool fVisible);
     76
     77public:
     78
     79    /** Frame-buffer constructor. */
     80    UIFrameBufferPrivate();
     81    /** Frame-buffer destructor. */
     82    ~UIFrameBufferPrivate();
     83
     84    /** Frame-buffer initialization.
     85      * @param pMachineView defines machine-view this frame-buffer is bounded to. */
     86    virtual HRESULT init(UIMachineView *pMachineView);
     87
     88    /** Assigns machine-view frame-buffer will be bounded to.
     89      * @param pMachineView defines machine-view this frame-buffer is bounded to. */
     90    virtual void setView(UIMachineView *pMachineView);
     91
     92    /** Returns the copy of the IDisplay wrapper. */
     93    CDisplay display() const { return m_display; }
     94    /** Attach frame-buffer to IDisplay. */
     95    void attach();
     96    /** Detach frame-buffer from IDisplay. */
     97    void detach();
     98
     99    /** Returns frame-buffer data address. */
     100    uchar *address() { return m_image.bits(); }
     101    /** Returns frame-buffer width. */
     102    ulong width() const { return m_iWidth; }
     103    /** Returns frame-buffer height. */
     104    ulong height() const { return m_iHeight; }
     105    /** Returns frame-buffer bits-per-pixel value. */
     106    ulong bitsPerPixel() const { return m_image.depth(); }
     107    /** Returns frame-buffer bytes-per-line value. */
     108    ulong bytesPerLine() const { return m_image.bytesPerLine(); }
     109    /** Returns default frame-buffer pixel-format. */
     110    ulong pixelFormat() const { return BitmapFormat_BGR; }
     111    /** Returns the visual-state this frame-buffer is used for. */
     112    UIVisualStateType visualState() const { return m_pMachineView ? m_pMachineView->visualStateType() : UIVisualStateType_Invalid; }
     113
     114    /** Defines whether frame-buffer is <b>unused</b>.
     115      * @note Refer to m_fUnused for more information.
     116      * @note Calls to this and any other EMT callback are synchronized (from GUI side). */
     117    void setMarkAsUnused(bool fUnused);
     118
     119    /** Returns whether frame-buffer is <b>auto-enabled</b>.
     120      * @note Refer to m_fAutoEnabled for more information. */
     121    bool isAutoEnabled() const { return m_fAutoEnabled; }
     122    /** Defines whether frame-buffer is <b>auto-enabled</b>.
     123      * @note Refer to m_fAutoEnabled for more information. */
     124    void setAutoEnabled(bool fAutoEnabled) { m_fAutoEnabled = fAutoEnabled; }
     125
     126    /** Returns the frame-buffer's scaled-size. */
     127    QSize scaledSize() const { return m_scaledSize; }
     128    /** Defines host-to-guest scale ratio as @a size. */
     129    void setScaledSize(const QSize &size = QSize()) { m_scaledSize = size; }
     130    /** Returns x-origin of the host (scaled) content corresponding to x-origin of guest (actual) content. */
     131    inline int convertGuestXTo(int x) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.width() / m_iWidth * x) : x; }
     132    /** Returns y-origin of the host (scaled) content corresponding to y-origin of guest (actual) content. */
     133    inline int convertGuestYTo(int y) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.height() / m_iHeight * y) : y; }
     134    /** Returns x-origin of the guest (actual) content corresponding to x-origin of host (scaled) content. */
     135    inline int convertHostXTo(int x) const  { return m_scaledSize.isValid() ? qRound((double)m_iWidth / m_scaledSize.width() * x) : x; }
     136    /** Returns y-origin of the guest (actual) content corresponding to y-origin of host (scaled) content. */
     137    inline int convertHostYTo(int y) const  { return m_scaledSize.isValid() ? qRound((double)m_iHeight / m_scaledSize.height() * y) : y; }
     138
     139    /** Returns the scale-factor used by the frame-buffer. */
     140    double scaleFactor() const { return m_dScaleFactor; }
     141    /** Define the scale-factor used by the frame-buffer. */
     142    void setScaleFactor(double dScaleFactor) { m_dScaleFactor = dScaleFactor; }
     143
     144    /** Returns backing-scale-factor used by HiDPI frame-buffer. */
     145    double backingScaleFactor() const { return m_dBackingScaleFactor; }
     146    /** Defines backing-scale-factor used by HiDPI frame-buffer. */
     147    void setBackingScaleFactor(double dBackingScaleFactor) { m_dBackingScaleFactor = dBackingScaleFactor; }
     148
     149    /** Returns whether frame-buffer should use unscaled HiDPI output. */
     150    bool useUnscaledHiDPIOutput() const { return m_fUseUnscaledHiDPIOutput; }
     151    /** Defines whether frame-buffer should use unscaled HiDPI output. */
     152    void setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput) { m_fUseUnscaledHiDPIOutput = fUseUnscaledHiDPIOutput; }
     153
     154    /** Return HiDPI frame-buffer optimization type. */
     155    HiDPIOptimizationType hiDPIOptimizationType() const { return m_hiDPIOptimizationType; }
     156    /** Define HiDPI frame-buffer optimization type: */
     157    void setHiDPIOptimizationType(HiDPIOptimizationType optimizationType) { m_hiDPIOptimizationType = optimizationType; }
     158
     159    DECLARE_NOT_AGGREGATABLE(UIFrameBufferPrivate)
     160
     161    DECLARE_PROTECT_FINAL_CONSTRUCT()
     162
     163    BEGIN_COM_MAP(UIFrameBufferPrivate)
     164        COM_INTERFACE_ENTRY(IFramebuffer)
     165        COM_INTERFACE_ENTRY2(IDispatch,IFramebuffer)
     166        COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
     167    END_COM_MAP()
     168
     169    HRESULT FinalConstruct();
     170    void FinalRelease();
     171
     172    STDMETHOD(COMGETTER(Width))(ULONG *puWidth);
     173    STDMETHOD(COMGETTER(Height))(ULONG *puHeight);
     174    STDMETHOD(COMGETTER(BitsPerPixel))(ULONG *puBitsPerPixel);
     175    STDMETHOD(COMGETTER(BytesPerLine))(ULONG *puBytesPerLine);
     176    STDMETHOD(COMGETTER(PixelFormat))(ULONG *puPixelFormat);
     177    STDMETHOD(COMGETTER(HeightReduction))(ULONG *puHeightReduction);
     178    STDMETHOD(COMGETTER(Overlay))(IFramebufferOverlay **ppOverlay);
     179    STDMETHOD(COMGETTER(WinId))(LONG64 *pWinId);
     180    STDMETHOD(COMGETTER(Capabilities))(ComSafeArrayOut(FramebufferCapabilities_T, aCapabilities));
     181
     182    /** EMT callback: Notifies frame-buffer about guest-screen size change.
     183      * @param        uScreenId Guest screen number.
     184      * @param        uX        Horizontal origin of the update rectangle, in pixels.
     185      * @param        uY        Vertical origin of the update rectangle, in pixels.
     186      * @param        uWidth    Width of the guest display, in pixels.
     187      * @param        uHeight   Height of the guest display, in pixels.
     188      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     189      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     190    STDMETHOD(NotifyChange)(ULONG uScreenId, ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight);
     191
     192    /** EMT callback: Notifies frame-buffer about guest-screen update.
     193      * @param        uX      Horizontal origin of the update rectangle, in pixels.
     194      * @param        uY      Vertical origin of the update rectangle, in pixels.
     195      * @param        uWidth  Width of the update rectangle, in pixels.
     196      * @param        uHeight Height of the update rectangle, in pixels.
     197      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     198      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     199    STDMETHOD(NotifyUpdate)(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight);
     200
     201    /** EMT callback: Notifies frame-buffer about guest-screen update.
     202      * @param        uX      Horizontal origin of the update rectangle, in pixels.
     203      * @param        uY      Vertical origin of the update rectangle, in pixels.
     204      * @param        uWidth  Width of the update rectangle, in pixels.
     205      * @param        uHeight Height of the update rectangle, in pixels.
     206      * @param        image   Brings image container which can be used to copy data from.
     207      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     208      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     209    STDMETHOD(NotifyUpdateImage)(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight, ComSafeArrayIn(BYTE, image));
     210
     211    /** EMT callback: Returns whether the frame-buffer implementation is willing to support a given video-mode.
     212      * @param        uWidth      Width of the guest display, in pixels.
     213      * @param        uHeight     Height of the guest display, in pixels.
     214      * @param        uBPP        Color depth, bits per pixel.
     215      * @param        pfSupported Is frame-buffer able/willing to render the video mode or not.
     216      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     217      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     218    STDMETHOD(VideoModeSupported)(ULONG uWidth, ULONG uHeight, ULONG uBPP, BOOL *pbSupported);
     219
     220    /** EMT callback which is not used in current implementation. */
     221    STDMETHOD(GetVisibleRegion)(BYTE *pRectangles, ULONG uCount, ULONG *puCountCopied);
     222    /** EMT callback: Suggests new visible-region to this frame-buffer.
     223      * @param        pRectangles Pointer to the RTRECT array.
     224      * @param        uCount      Number of RTRECT elements in the rectangles array.
     225      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     226      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     227    STDMETHOD(SetVisibleRegion)(BYTE *pRectangles, ULONG uCount);
     228
     229    /** EMT callback which is not used in current implementation. */
     230    STDMETHOD(ProcessVHWACommand)(BYTE *pCommand);
     231
     232    /** EMT callback: Notifies frame-buffer about 3D backend event.
     233      * @param        uType Event type. Currently only VBOX3D_NOTIFY_EVENT_TYPE_VISIBLE_3DDATA is supported.
     234      * @param        aData Event-specific data, depends on the supplied event type.
     235      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     236      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     237    STDMETHOD(Notify3DEvent)(ULONG uType, ComSafeArrayIn(BYTE, data));
     238
     239    /** Locks frame-buffer access. */
     240    void lock() const { RTCritSectEnter(&m_critSect); }
     241    /** Unlocks frame-buffer access. */
     242    void unlock() const { RTCritSectLeave(&m_critSect); }
     243
     244    /** Handles frame-buffer notify-change-event. */
     245    virtual void handleNotifyChange(int iWidth, int iHeight);
     246    /** Handles frame-buffer paint-event. */
     247    virtual void handlePaintEvent(QPaintEvent *pEvent);
     248    /** Handles frame-buffer set-visible-region-event. */
     249    virtual void handleSetVisibleRegion(const QRegion &region);
     250
     251    /** Performs frame-buffer resizing. */
     252    virtual void performResize(int iWidth, int iHeight);
     253    /** Performs frame-buffer rescaling. */
     254    virtual void performRescale();
     255
     256#ifdef VBOX_WITH_VIDEOHWACCEL
     257    /** Performs Video HW Acceleration command. */
     258    virtual void doProcessVHWACommand(QEvent*) {}
     259    /** Handles viewport resize-event. */
     260    virtual void viewportResized(QResizeEvent*) {}
     261    /** Handles viewport scroll-event. */
     262    virtual void viewportScrolled(int, int) {}
     263#endif /* VBOX_WITH_VIDEOHWACCEL */
     264
     265protected:
     266
     267    /** Prepare connections routine. */
     268    void prepareConnections();
     269    /** Cleanup connections routine. */
     270    void cleanupConnections();
     271
     272    /** Updates coordinate-system: */
     273    void updateCoordinateSystem();
     274
     275    /** Default paint routine. */
     276    void paintDefault(QPaintEvent *pEvent);
     277    /** Paint routine for seamless mode. */
     278    void paintSeamless(QPaintEvent *pEvent);
     279
     280    /** Erases corresponding @a rect with @a painter. */
     281    static void eraseImageRect(QPainter &painter, const QRect &rect,
     282                               bool fUseUnscaledHiDPIOutput,
     283                               HiDPIOptimizationType hiDPIOptimizationType,
     284                               double dBackingScaleFactor);
     285    /** Draws corresponding @a rect of passed @a image with @a painter. */
     286    static void drawImageRect(QPainter &painter, const QImage &image, const QRect &rect,
     287                              int iContentsShiftX, int iContentsShiftY,
     288                              bool fUseUnscaledHiDPIOutput,
     289                              HiDPIOptimizationType hiDPIOptimizationType,
     290                              double dBackingScaleFactor);
     291
     292    /** Holds the screen-id. */
     293    ulong m_uScreenId;
     294
     295    /** Holds the QImage buffer. */
     296    QImage m_image;
     297    /** Holds frame-buffer width. */
     298    int m_iWidth;
     299    /** Holds frame-buffer height. */
     300    int m_iHeight;
     301
     302    /** Holds the copy of the IDisplay wrapper. */
     303    CDisplay m_display;
     304    /** Source bitmap from IDisplay. */
     305    CDisplaySourceBitmap m_sourceBitmap;
     306    /** Source bitmap from IDisplay (acquired but not yet applied). */
     307    CDisplaySourceBitmap m_pendingSourceBitmap;
     308    /** Holds whether there is a pending source bitmap which must be applied. */
     309    bool m_fPendingSourceBitmap;
     310
     311    /** Holds machine-view this frame-buffer is bounded to. */
     312    UIMachineView *m_pMachineView;
     313    /** Holds window ID this frame-buffer referring to. */
     314    int64_t m_iWinId;
     315
     316    /** Reflects whether screen-updates are allowed. */
     317    bool m_fUpdatesAllowed;
     318
     319    /** Defines whether frame-buffer is <b>unused</b>.
     320      * <b>Unused</b> status determines whether frame-buffer should ignore EMT events or not. */
     321    bool m_fUnused;
     322
     323    /** Defines whether frame-buffer is <b>auto-enabled</b>.
     324      * <b>Auto-enabled</b> status means that guest-screen corresponding to this frame-buffer
     325      * was automatically enabled by the multi-screen layout (auto-mount guest-screen) functionality,
     326      * so have potentially incorrect size-hint posted into guest event queue.
     327      * Machine-view will try to automatically adjust guest-screen size as soon as possible. */
     328    bool m_fAutoEnabled;
     329
     330    /** RTCRITSECT object to protect frame-buffer access. */
     331    mutable RTCRITSECT m_critSect;
     332
     333    /** @name Scale-factor related variables.
     334     * @{ */
     335    /** Holds the scale-factor used by the scaled-size. */
     336    double m_dScaleFactor;
     337    /** Holds the coordinate-system for the scale-factor above. */
     338    QTransform m_transform;
     339    /** Holds the frame-buffer's scaled-size. */
     340    QSize m_scaledSize;
     341    /** @} */
     342
     343    /** @name Seamless mode related variables.
     344     * @{ */
     345    /* To avoid a seamless flicker which caused by the latency between
     346     * the initial visible-region arriving from EMT thread
     347     * and actual visible-region appliance on GUI thread
     348     * it was decided to use two visible-region instances: */
     349    /** Sync visible-region which being updated synchronously by locking EMT thread.
     350      * Used for immediate manual clipping of the painting operations. */
     351    QRegion m_syncVisibleRegion;
     352    /** Async visible-region which being updated asynchronously by posting async-event from EMT to GUI thread,
     353      * Used to update viewport parts for visible-region changes,
     354      * because NotifyUpdate doesn't take into account these changes. */
     355    QRegion m_asyncVisibleRegion;
     356    /** When the frame-buffer is being resized, visible region is saved here.
     357      * The saved region is applied when updates are enabled again. */
     358    QRegion m_pendingSyncVisibleRegion;
     359    /** @} */
     360
     361    /** @name HiDPI screens related variables.
     362     * @{ */
     363    /** Holds backing-scale-factor used by HiDPI frame-buffer. */
     364    double m_dBackingScaleFactor;
     365    /** Holds whether frame-buffer should use unscaled HiDPI output. */
     366    bool m_fUseUnscaledHiDPIOutput;
     367    /** Holds HiDPI frame-buffer optimization type. */
     368    HiDPIOptimizationType m_hiDPIOptimizationType;
     369    /** @} */
     370
     371private:
     372
     373#ifdef Q_OS_WIN
     374     CComPtr <IUnknown> m_pUnkMarshaler;
     375#endif /* Q_OS_WIN */
     376};
     377
     378
     379#ifdef VBOX_WITH_VIDEOHWACCEL
     380/** UIFrameBufferPrivate reimplementation used to maintain VM display video memory
     381  *                      for the case when 2D Video Acceleration is enabled. */
     382class VBoxOverlayFrameBuffer : public UIFrameBufferPrivate
     383{
     384    Q_OBJECT;
     385
     386public:
     387
     388    VBoxOverlayFrameBuffer()
     389    {
     390    }
     391
     392    virtual HRESULT init(UIMachineView *pView, CSession * aSession, uint32_t id)
     393    {
     394        mpView = pView;
     395        UIFrameBufferPrivate::init(mpView);
     396        mOverlay.init(mpView->viewport(), mpView, aSession, id),
     397        /* sync with frame-buffer */
     398        mOverlay.onResizeEventPostprocess (VBoxFBSizeInfo(this), QPoint(mpView->contentsX(), mpView->contentsY()));
     399        return S_OK;
     400    }
     401
     402    STDMETHOD(ProcessVHWACommand)(BYTE *pCommand)
     403    {
     404        int rc;
     405        UIFrameBufferPrivate::lock();
     406        /* Make sure frame-buffer is used: */
     407        if (m_fUnused)
     408        {
     409            LogRel2(("ProcessVHWACommand: Postponed!\n"));
     410            /* Unlock access to frame-buffer: */
     411            UIFrameBufferPrivate::unlock();
     412            /* tell client to pend ProcessVHWACommand */
     413            return E_ACCESSDENIED;
     414        }
     415        rc = mOverlay.onVHWACommand ((struct VBOXVHWACMD*)pCommand);
     416        UIFrameBufferPrivate::unlock();
     417        if (rc == VINF_CALLBACK_RETURN)
     418            return S_OK;
     419        else if (RT_SUCCESS(rc))
     420            return S_FALSE;
     421        else if (rc == VERR_INVALID_STATE)
     422            return E_ACCESSDENIED;
     423        return E_FAIL;
     424    }
     425
     426    void doProcessVHWACommand (QEvent * pEvent)
     427    {
     428        mOverlay.onVHWACommandEvent (pEvent);
     429    }
     430
     431    STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY,
     432                             ULONG aW, ULONG aH)
     433    {
     434        HRESULT hr = S_OK;
     435        UIFrameBufferPrivate::lock();
     436        /* Make sure frame-buffer is used: */
     437        if (m_fUnused)
     438        {
     439            LogRel2(("NotifyUpdate: Ignored!\n"));
     440            mOverlay.onNotifyUpdateIgnore (aX, aY, aW, aH);
     441            /* Unlock access to frame-buffer: */
     442            UIFrameBufferPrivate::unlock();
     443            /*can we actually ignore the notify update?*/
     444            /* Ignore NotifyUpdate: */
     445            return E_FAIL;
     446        }
     447
     448        if (!mOverlay.onNotifyUpdate (aX, aY, aW, aH))
     449            hr = UIFrameBufferPrivate::NotifyUpdate (aX, aY, aW, aH);
     450        UIFrameBufferPrivate::unlock();
     451        return hr;
     452    }
     453
     454    void performResize(int iWidth, int iHeight)
     455    {
     456        UIFrameBufferPrivate::performResize(iWidth, iHeight);
     457        mOverlay.onResizeEventPostprocess(VBoxFBSizeInfo(this),
     458                QPoint(mpView->contentsX(), mpView->contentsY()));
     459    }
     460
     461    void performRescale()
     462    {
     463        UIFrameBufferPrivate::performRescale();
     464        mOverlay.onResizeEventPostprocess(VBoxFBSizeInfo(this),
     465                QPoint(mpView->contentsX(), mpView->contentsY()));
     466    }
     467
     468    void viewportResized (QResizeEvent * re)
     469    {
     470        mOverlay.onViewportResized (re);
     471        UIFrameBufferPrivate::viewportResized (re);
     472    }
     473
     474    void viewportScrolled (int dx, int dy)
     475    {
     476        mOverlay.onViewportScrolled (QPoint(mpView->contentsX(), mpView->contentsY()));
     477        UIFrameBufferPrivate::viewportScrolled (dx, dy);
     478    }
     479
     480    void setView(UIMachineView * pView)
     481    {
     482        /* lock to ensure we do not collide with the EMT thread passing commands to us */
     483        UIFrameBufferPrivate::lock();
     484        UIFrameBufferPrivate::setView(pView);
     485        mpView = pView;
     486        mOverlay.updateAttachment(pView ? pView->viewport() : NULL, pView);
     487        UIFrameBufferPrivate::unlock();
     488    }
     489
     490private:
     491
     492    VBoxQGLOverlay mOverlay;
     493    UIMachineView *mpView;
     494};
     495#endif /* VBOX_WITH_VIDEOHWACCEL */
    43496
    44497
     
    47500static CComModule _Module;
    48501#else /* !Q_WS_WIN */
    49 NS_DECL_CLASSINFO(UIFrameBuffer)
    50 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(UIFrameBuffer, IFramebuffer)
     502NS_DECL_CLASSINFO(UIFrameBufferPrivate)
     503NS_IMPL_THREADSAFE_ISUPPORTS1_CI(UIFrameBufferPrivate, IFramebuffer)
    51504#endif /* !Q_WS_WIN */
    52505
    53 #ifdef Q_WS_X11
    54 # include <QX11Info>
    55 # include <X11/Xlib.h>
    56 #endif /* Q_WS_X11 */
    57 
    58 UIFrameBuffer::UIFrameBuffer()
     506
     507UIFrameBufferPrivate::UIFrameBufferPrivate()
    59508    : m_uScreenId(0)
    60509    , m_iWidth(0), m_iHeight(0)
     
    74523}
    75524
    76 HRESULT UIFrameBuffer::init(UIMachineView *pMachineView)
    77 {
    78     LogRel2(("UIFrameBuffer::init %p\n", this));
     525HRESULT UIFrameBufferPrivate::init(UIMachineView *pMachineView)
     526{
     527    LogRel2(("UIFrameBufferPrivate::init %p\n", this));
    79528
    80529    /* Assign mahine-view: */
     
    108557}
    109558
    110 UIFrameBuffer::~UIFrameBuffer()
    111 {
    112     LogRel2(("UIFrameBuffer::~UIFrameBuffer %p\n", this));
     559UIFrameBufferPrivate::~UIFrameBufferPrivate()
     560{
     561    LogRel2(("UIFrameBufferPrivate::~UIFrameBufferPrivate %p\n", this));
    113562
    114563    /* Disconnect handlers: */
     
    120569}
    121570
    122 void UIFrameBuffer::setView(UIMachineView *pMachineView)
     571void UIFrameBufferPrivate::setView(UIMachineView *pMachineView)
    123572{
    124573    /* Disconnect old handlers: */
     
    141590}
    142591
    143 void UIFrameBuffer::attach()
     592void UIFrameBufferPrivate::attach()
    144593{
    145594    display().AttachFramebuffer(m_uScreenId, CFramebuffer(this));
    146595}
    147596
    148 void UIFrameBuffer::detach()
     597void UIFrameBufferPrivate::detach()
    149598{
    150599    CFramebuffer frameBuffer = display().QueryFramebuffer(m_uScreenId);
     
    153602}
    154603
    155 UIVisualStateType UIFrameBuffer::visualState() const
    156 {
    157     return m_pMachineView ? m_pMachineView->visualStateType() : UIVisualStateType_Invalid;
    158 }
    159 
    160 void UIFrameBuffer::setMarkAsUnused(bool fUnused)
     604void UIFrameBufferPrivate::setMarkAsUnused(bool fUnused)
    161605{
    162606    lock();
     
    165609}
    166610
    167 HRESULT UIFrameBuffer::FinalConstruct()
     611HRESULT UIFrameBufferPrivate::FinalConstruct()
    168612{
    169613    return 0;
    170614}
    171615
    172 void UIFrameBuffer::FinalRelease()
     616void UIFrameBufferPrivate::FinalRelease()
    173617{
    174618    return;
    175619}
    176620
    177 STDMETHODIMP UIFrameBuffer::COMGETTER(Width)(ULONG *puWidth)
     621STDMETHODIMP UIFrameBufferPrivate::COMGETTER(Width)(ULONG *puWidth)
    178622{
    179623    if (!puWidth)
     
    183627}
    184628
    185 STDMETHODIMP UIFrameBuffer::COMGETTER(Height)(ULONG *puHeight)
     629STDMETHODIMP UIFrameBufferPrivate::COMGETTER(Height)(ULONG *puHeight)
    186630{
    187631    if (!puHeight)
     
    191635}
    192636
    193 STDMETHODIMP UIFrameBuffer::COMGETTER(BitsPerPixel)(ULONG *puBitsPerPixel)
     637STDMETHODIMP UIFrameBufferPrivate::COMGETTER(BitsPerPixel)(ULONG *puBitsPerPixel)
    194638{
    195639    if (!puBitsPerPixel)
     
    199643}
    200644
    201 STDMETHODIMP UIFrameBuffer::COMGETTER(BytesPerLine)(ULONG *puBytesPerLine)
     645STDMETHODIMP UIFrameBufferPrivate::COMGETTER(BytesPerLine)(ULONG *puBytesPerLine)
    202646{
    203647    if (!puBytesPerLine)
     
    207651}
    208652
    209 STDMETHODIMP UIFrameBuffer::COMGETTER(PixelFormat)(ULONG *puPixelFormat)
     653STDMETHODIMP UIFrameBufferPrivate::COMGETTER(PixelFormat)(ULONG *puPixelFormat)
    210654{
    211655    if (!puPixelFormat)
     
    215659}
    216660
    217 STDMETHODIMP UIFrameBuffer::COMGETTER(HeightReduction)(ULONG *puHeightReduction)
     661STDMETHODIMP UIFrameBufferPrivate::COMGETTER(HeightReduction)(ULONG *puHeightReduction)
    218662{
    219663    if (!puHeightReduction)
     
    223667}
    224668
    225 STDMETHODIMP UIFrameBuffer::COMGETTER(Overlay)(IFramebufferOverlay **ppOverlay)
     669STDMETHODIMP UIFrameBufferPrivate::COMGETTER(Overlay)(IFramebufferOverlay **ppOverlay)
    226670{
    227671    if (!ppOverlay)
     
    231675}
    232676
    233 STDMETHODIMP UIFrameBuffer::COMGETTER(WinId)(LONG64 *pWinId)
     677STDMETHODIMP UIFrameBufferPrivate::COMGETTER(WinId)(LONG64 *pWinId)
    234678{
    235679    if (!pWinId)
     
    239683}
    240684
    241 STDMETHODIMP UIFrameBuffer::COMGETTER(Capabilities)(ComSafeArrayOut(FramebufferCapabilities_T, enmCapabilities))
     685STDMETHODIMP UIFrameBufferPrivate::COMGETTER(Capabilities)(ComSafeArrayOut(FramebufferCapabilities_T, enmCapabilities))
    242686{
    243687    if (ComSafeArrayOutIsNull(enmCapabilities))
     
    261705}
    262706
    263 STDMETHODIMP UIFrameBuffer::NotifyChange(ULONG uScreenId, ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight)
     707STDMETHODIMP UIFrameBufferPrivate::NotifyChange(ULONG uScreenId, ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight)
    264708{
    265709    CDisplaySourceBitmap sourceBitmap;
     
    273717    if (m_fUnused)
    274718    {
    275         LogRel(("UIFrameBuffer::NotifyChange: Screen=%lu, Origin=%lux%lu, Size=%lux%lu, Ignored!\n",
     719        LogRel(("UIFrameBufferPrivate::NotifyChange: Screen=%lu, Origin=%lux%lu, Size=%lux%lu, Ignored!\n",
    276720                (unsigned long)uScreenId,
    277721                (unsigned long)uX, (unsigned long)uY,
     
    300744    /* Widget resize is NOT thread-safe and *probably* never will be,
    301745     * We have to notify machine-view with the async-signal to perform resize operation. */
    302     LogRel(("UIFrameBuffer::NotifyChange: Screen=%lu, Origin=%lux%lu, Size=%lux%lu, Sending to async-handler\n",
     746    LogRel(("UIFrameBufferPrivate::NotifyChange: Screen=%lu, Origin=%lux%lu, Size=%lux%lu, Sending to async-handler\n",
    303747            (unsigned long)uScreenId,
    304748            (unsigned long)uX, (unsigned long)uY,
     
    316760}
    317761
    318 STDMETHODIMP UIFrameBuffer::NotifyUpdate(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight)
     762STDMETHODIMP UIFrameBufferPrivate::NotifyUpdate(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight)
    319763{
    320764    /* Lock access to frame-buffer: */
     
    324768    if (m_fUnused)
    325769    {
    326         LogRel2(("UIFrameBuffer::NotifyUpdate: Origin=%lux%lu, Size=%lux%lu, Ignored!\n",
     770        LogRel2(("UIFrameBufferPrivate::NotifyUpdate: Origin=%lux%lu, Size=%lux%lu, Ignored!\n",
    327771                 (unsigned long)uX, (unsigned long)uY,
    328772                 (unsigned long)uWidth, (unsigned long)uHeight));
     
    337781    /* Widget update is NOT thread-safe and *seems* never will be,
    338782     * We have to notify machine-view with the async-signal to perform update operation. */
    339     LogRel2(("UIFrameBuffer::NotifyUpdate: Origin=%lux%lu, Size=%lux%lu, Sending to async-handler\n",
     783    LogRel2(("UIFrameBufferPrivate::NotifyUpdate: Origin=%lux%lu, Size=%lux%lu, Sending to async-handler\n",
    340784             (unsigned long)uX, (unsigned long)uY,
    341785             (unsigned long)uWidth, (unsigned long)uHeight));
     
    349793}
    350794
    351 STDMETHODIMP UIFrameBuffer::NotifyUpdateImage(ULONG uX, ULONG uY,
    352                                               ULONG uWidth, ULONG uHeight,
    353                                               ComSafeArrayIn(BYTE, image))
     795STDMETHODIMP UIFrameBufferPrivate::NotifyUpdateImage(ULONG uX, ULONG uY,
     796                                                     ULONG uWidth, ULONG uHeight,
     797                                                     ComSafeArrayIn(BYTE, image))
    354798{
    355799    /* Wrapping received data: */
     
    362806    if (m_fUnused)
    363807    {
    364         LogRel2(("UIFrameBuffer::NotifyUpdateImage: Origin=%lux%lu, Size=%lux%lu, Ignored!\n",
     808        LogRel2(("UIFrameBufferPrivate::NotifyUpdateImage: Origin=%lux%lu, Size=%lux%lu, Ignored!\n",
    365809                 (unsigned long)uX, (unsigned long)uY,
    366810                 (unsigned long)uWidth, (unsigned long)uHeight));
     
    389833        /* Widget update is NOT thread-safe and *seems* never will be,
    390834         * We have to notify machine-view with the async-signal to perform update operation. */
    391         LogRel2(("UIFrameBuffer::NotifyUpdateImage: Origin=%lux%lu, Size=%lux%lu, Sending to async-handler\n",
     835        LogRel2(("UIFrameBufferPrivate::NotifyUpdateImage: Origin=%lux%lu, Size=%lux%lu, Sending to async-handler\n",
    392836                 (unsigned long)uX, (unsigned long)uY,
    393837                 (unsigned long)uWidth, (unsigned long)uHeight));
     
    402846}
    403847
    404 STDMETHODIMP UIFrameBuffer::VideoModeSupported(ULONG uWidth, ULONG uHeight, ULONG uBPP, BOOL *pfSupported)
     848STDMETHODIMP UIFrameBufferPrivate::VideoModeSupported(ULONG uWidth, ULONG uHeight, ULONG uBPP, BOOL *pfSupported)
    405849{
    406850    /* Make sure result pointer is valid: */
    407851    if (!pfSupported)
    408852    {
    409         LogRel2(("UIFrameBuffer::IsVideoModeSupported: Mode: BPP=%lu, Size=%lux%lu, Invalid pfSupported pointer!\n",
     853        LogRel2(("UIFrameBufferPrivate::IsVideoModeSupported: Mode: BPP=%lu, Size=%lux%lu, Invalid pfSupported pointer!\n",
    410854                 (unsigned long)uBPP, (unsigned long)uWidth, (unsigned long)uHeight));
    411855
     
    419863    if (m_fUnused)
    420864    {
    421         LogRel2(("UIFrameBuffer::IsVideoModeSupported: Mode: BPP=%lu, Size=%lux%lu, Ignored!\n",
     865        LogRel2(("UIFrameBufferPrivate::IsVideoModeSupported: Mode: BPP=%lu, Size=%lux%lu, Ignored!\n",
    422866                 (unsigned long)uBPP, (unsigned long)uWidth, (unsigned long)uHeight));
    423867
     
    440884        && (uHeight > (ULONG)height()))
    441885        *pfSupported = FALSE;
    442     LogRel2(("UIFrameBuffer::IsVideoModeSupported: Mode: BPP=%lu, Size=%lux%lu, Supported=%s\n",
     886    LogRel2(("UIFrameBufferPrivate::IsVideoModeSupported: Mode: BPP=%lu, Size=%lux%lu, Supported=%s\n",
    443887             (unsigned long)uBPP, (unsigned long)uWidth, (unsigned long)uHeight, *pfSupported ? "TRUE" : "FALSE"));
    444888
     
    450894}
    451895
    452 STDMETHODIMP UIFrameBuffer::GetVisibleRegion(BYTE *pRectangles, ULONG uCount, ULONG *puCountCopied)
     896STDMETHODIMP UIFrameBufferPrivate::GetVisibleRegion(BYTE *pRectangles, ULONG uCount, ULONG *puCountCopied)
    453897{
    454898    PRTRECT rects = (PRTRECT)pRectangles;
     
    463907}
    464908
    465 STDMETHODIMP UIFrameBuffer::SetVisibleRegion(BYTE *pRectangles, ULONG uCount)
     909STDMETHODIMP UIFrameBufferPrivate::SetVisibleRegion(BYTE *pRectangles, ULONG uCount)
    466910{
    467911    /* Make sure rectangles were passed: */
    468912    if (!pRectangles)
    469913    {
    470         LogRel2(("UIFrameBuffer::SetVisibleRegion: Rectangle count=%lu, Invalid pRectangles pointer!\n",
     914        LogRel2(("UIFrameBufferPrivate::SetVisibleRegion: Rectangle count=%lu, Invalid pRectangles pointer!\n",
    471915                 (unsigned long)uCount));
    472916
     
    480924    if (m_fUnused)
    481925    {
    482         LogRel2(("UIFrameBuffer::SetVisibleRegion: Rectangle count=%lu, Ignored!\n",
     926        LogRel2(("UIFrameBufferPrivate::SetVisibleRegion: Rectangle count=%lu, Ignored!\n",
    483927                 (unsigned long)uCount));
    484928
     
    515959        m_syncVisibleRegion = region;
    516960        /* And send async-signal to update asynchronous one: */
    517         LogRel2(("UIFrameBuffer::SetVisibleRegion: Rectangle count=%lu, Sending to async-handler\n",
     961        LogRel2(("UIFrameBufferPrivate::SetVisibleRegion: Rectangle count=%lu, Sending to async-handler\n",
    518962                 (unsigned long)uCount));
    519963        emit sigSetVisibleRegion(region);
     
    523967        /* Save the region. */
    524968        m_pendingSyncVisibleRegion = region;
    525         LogRel2(("UIFrameBuffer::SetVisibleRegion: Rectangle count=%lu, Saved\n",
     969        LogRel2(("UIFrameBufferPrivate::SetVisibleRegion: Rectangle count=%lu, Saved\n",
    526970                 (unsigned long)uCount));
    527971    }
     
    534978}
    535979
    536 STDMETHODIMP UIFrameBuffer::ProcessVHWACommand(BYTE *pCommand)
     980STDMETHODIMP UIFrameBufferPrivate::ProcessVHWACommand(BYTE *pCommand)
    537981{
    538982    Q_UNUSED(pCommand);
     
    540984}
    541985
    542 STDMETHODIMP UIFrameBuffer::Notify3DEvent(ULONG uType, ComSafeArrayIn(BYTE, data))
     986STDMETHODIMP UIFrameBufferPrivate::Notify3DEvent(ULONG uType, ComSafeArrayIn(BYTE, data))
    543987{
    544988    /* Lock access to frame-buffer: */
     
    548992    if (m_fUnused)
    549993    {
    550         LogRel2(("UIFrameBuffer::Notify3DEvent: Ignored!\n"));
     994        LogRel2(("UIFrameBufferPrivate::Notify3DEvent: Ignored!\n"));
    551995
    552996        /* Unlock access to frame-buffer: */
     
    5651009             * about 3D overlay visibility change: */
    5661010            BOOL fVisible = eventData[0];
    567             LogRel2(("UIFrameBuffer::Notify3DEvent: Sending to async-handler: "
     1011            LogRel2(("UIFrameBufferPrivate::Notify3DEvent: Sending to async-handler: "
    5681012                     "(VBOX3D_NOTIFY_EVENT_TYPE_VISIBLE_3DDATA = %s)\n",
    5691013                     fVisible ? "TRUE" : "FALSE"));
     
    5951039}
    5961040
    597 void UIFrameBuffer::handleNotifyChange(int iWidth, int iHeight)
    598 {
    599     LogRel(("UIFrameBuffer::handleNotifyChange: Size=%dx%d\n", iWidth, iHeight));
     1041void UIFrameBufferPrivate::handleNotifyChange(int iWidth, int iHeight)
     1042{
     1043    LogRel(("UIFrameBufferPrivate::handleNotifyChange: Size=%dx%d\n", iWidth, iHeight));
    6001044
    6011045    /* Make sure machine-view is assigned: */
     
    6091053    {
    6101054        /* Do nothing, change-event already processed: */
    611         LogRel2(("UIFrameBuffer::handleNotifyChange: Already processed.\n"));
     1055        LogRel2(("UIFrameBufferPrivate::handleNotifyChange: Already processed.\n"));
    6121056        /* Unlock access to frame-buffer: */
    6131057        unlock();
     
    6281072}
    6291073
    630 void UIFrameBuffer::handlePaintEvent(QPaintEvent *pEvent)
    631 {
    632     LogRel2(("UIFrameBuffer::handlePaintEvent: Origin=%lux%lu, Size=%dx%d\n",
     1074void UIFrameBufferPrivate::handlePaintEvent(QPaintEvent *pEvent)
     1075{
     1076    LogRel2(("UIFrameBufferPrivate::handlePaintEvent: Origin=%lux%lu, Size=%dx%d\n",
    6331077             pEvent->rect().x(), pEvent->rect().y(),
    6341078             pEvent->rect().width(), pEvent->rect().height()));
     
    6671111}
    6681112
    669 void UIFrameBuffer::handleSetVisibleRegion(const QRegion &region)
     1113void UIFrameBufferPrivate::handleSetVisibleRegion(const QRegion &region)
    6701114{
    6711115    /* Make sure async visible-region has changed: */
     
    6871131}
    6881132
    689 void UIFrameBuffer::performResize(int iWidth, int iHeight)
    690 {
    691     LogRel(("UIFrameBuffer::performResize: Size=%dx%d\n", iWidth, iHeight));
     1133void UIFrameBufferPrivate::performResize(int iWidth, int iHeight)
     1134{
     1135    LogRel(("UIFrameBufferPrivate::performResize: Size=%dx%d\n", iWidth, iHeight));
    6921136
    6931137    /* Make sure machine-view is assigned: */
     
    7071151    if (m_sourceBitmap.isNull())
    7081152    {
    709         LogRel(("UIFrameBuffer::performResize: "
     1153        LogRel(("UIFrameBufferPrivate::performResize: "
    7101154                "Using FALLBACK buffer due to source-bitmap is not provided..\n"));
    7111155
     
    7211165    else
    7221166    {
    723         LogRel(("UIFrameBuffer::performResize: "
     1167        LogRel(("UIFrameBufferPrivate::performResize: "
    7241168                "Directly using source-bitmap content\n"));
    7251169
     
    7771221
    7781222        /* And send async-signal to update asynchronous one: */
    779         LogRel2(("UIFrameBuffer::performResize: Rectangle count=%lu, Sending to async-handler\n",
     1223        LogRel2(("UIFrameBufferPrivate::performResize: Rectangle count=%lu, Sending to async-handler\n",
    7801224                 (unsigned long)m_syncVisibleRegion.rectCount()));
    7811225        emit sigSetVisibleRegion(m_syncVisibleRegion);
     
    7851229}
    7861230
    787 void UIFrameBuffer::performRescale()
    788 {
    789 //    printf("UIFrameBuffer::performRescale\n");
     1231void UIFrameBufferPrivate::performRescale()
     1232{
     1233//    printf("UIFrameBufferPrivate::performRescale\n");
    7901234
    7911235    /* Make sure machine-view is assigned: */
     
    8061250    updateCoordinateSystem();
    8071251
    808 //    printf("UIFrameBuffer::performRescale: Complete: Scale-factor=%f, Scaled-size=%dx%d\n",
     1252//    printf("UIFrameBufferPrivate::performRescale: Complete: Scale-factor=%f, Scaled-size=%dx%d\n",
    8091253//           scaleFactor(), scaledSize().width(), scaledSize().height());
    8101254}
    8111255
    812 void UIFrameBuffer::prepareConnections()
     1256void UIFrameBufferPrivate::prepareConnections()
    8131257{
    8141258    /* Attach EMT connections: */
     
    8271271}
    8281272
    829 void UIFrameBuffer::cleanupConnections()
     1273void UIFrameBufferPrivate::cleanupConnections()
    8301274{
    8311275    /* Detach EMT connections: */
     
    8401284}
    8411285
    842 void UIFrameBuffer::updateCoordinateSystem()
     1286void UIFrameBufferPrivate::updateCoordinateSystem()
    8431287{
    8441288    /* Reset to default: */
     
    8541298}
    8551299
    856 void UIFrameBuffer::paintDefault(QPaintEvent *pEvent)
     1300void UIFrameBufferPrivate::paintDefault(QPaintEvent *pEvent)
    8571301{
    8581302    /* Scaled image is NULL by default: */
     
    8941338}
    8951339
    896 void UIFrameBuffer::paintSeamless(QPaintEvent *pEvent)
     1340void UIFrameBufferPrivate::paintSeamless(QPaintEvent *pEvent)
    8971341{
    8981342    /* Scaled image is NULL by default: */
     
    9611405
    9621406/* static */
    963 void UIFrameBuffer::eraseImageRect(QPainter &painter, const QRect &rect,
    964                                    bool fUseUnscaledHiDPIOutput,
    965                                    HiDPIOptimizationType hiDPIOptimizationType,
    966                                    double dBackingScaleFactor)
     1407void UIFrameBufferPrivate::eraseImageRect(QPainter &painter, const QRect &rect,
     1408                                          bool fUseUnscaledHiDPIOutput,
     1409                                          HiDPIOptimizationType hiDPIOptimizationType,
     1410                                          double dBackingScaleFactor)
    9671411{
    9681412    /* Prepare sub-pixmap: */
     
    10071451
    10081452/* static */
    1009 void UIFrameBuffer::drawImageRect(QPainter &painter, const QImage &image, const QRect &rect,
    1010                                   int iContentsShiftX, int iContentsShiftY,
    1011                                   bool fUseUnscaledHiDPIOutput,
    1012                                   HiDPIOptimizationType hiDPIOptimizationType,
    1013                                   double dBackingScaleFactor)
     1453void UIFrameBufferPrivate::drawImageRect(QPainter &painter, const QImage &image, const QRect &rect,
     1454                                         int iContentsShiftX, int iContentsShiftY,
     1455                                         bool fUseUnscaledHiDPIOutput,
     1456                                         HiDPIOptimizationType hiDPIOptimizationType,
     1457                                         double dBackingScaleFactor)
    10141458{
    10151459    /* Calculate offset: */
     
    10661510}
    10671511
     1512
     1513#ifdef VBOX_WITH_VIDEOHWACCEL
     1514UIFrameBuffer::UIFrameBuffer(bool m_fAccelerate2DVideo)
     1515{
     1516    if (m_fAccelerate2DVideo)
     1517    {
     1518        ComObjPtr<VBoxOverlayFrameBuffer> pFrameBuffer;
     1519        pFrameBuffer.createObject();
     1520        m_pFrameBuffer = pFrameBuffer;
     1521    }
     1522    else
     1523    {
     1524        m_pFrameBuffer.createObject();
     1525    }
     1526}
     1527#else /* !VBOX_WITH_VIDEOHWACCEL */
     1528UIFrameBuffer::UIFrameBuffer()
     1529{
     1530    m_pFrameBuffer.createObject();
     1531}
     1532#endif /* !VBOX_WITH_VIDEOHWACCEL */
     1533
     1534UIFrameBuffer::~UIFrameBuffer()
     1535{
     1536    m_pFrameBuffer.setNull();
     1537}
     1538
     1539HRESULT UIFrameBuffer::init(UIMachineView *pMachineView)
     1540{
     1541    return m_pFrameBuffer->init(pMachineView);
     1542}
     1543
     1544void UIFrameBuffer::attach()
     1545{
     1546    m_pFrameBuffer->attach();
     1547}
     1548
     1549void UIFrameBuffer::detach()
     1550{
     1551    m_pFrameBuffer->detach();
     1552}
     1553
     1554uchar* UIFrameBuffer::address()
     1555{
     1556    return m_pFrameBuffer->address();
     1557}
     1558
     1559ulong UIFrameBuffer::width() const
     1560{
     1561    return m_pFrameBuffer->width();
     1562}
     1563
     1564ulong UIFrameBuffer::height() const
     1565{
     1566    return m_pFrameBuffer->height();
     1567}
     1568
     1569ulong UIFrameBuffer::bitsPerPixel() const
     1570{
     1571    return m_pFrameBuffer->bitsPerPixel();
     1572}
     1573
     1574ulong UIFrameBuffer::bytesPerLine() const
     1575{
     1576    return m_pFrameBuffer->bytesPerLine();
     1577}
     1578
     1579UIVisualStateType UIFrameBuffer::visualState() const
     1580{
     1581    return m_pFrameBuffer->visualState();
     1582}
     1583
     1584void UIFrameBuffer::setView(UIMachineView *pMachineView)
     1585{
     1586    m_pFrameBuffer->setView(pMachineView);
     1587}
     1588
     1589void UIFrameBuffer::setMarkAsUnused(bool fUnused)
     1590{
     1591    m_pFrameBuffer->setMarkAsUnused(fUnused);
     1592}
     1593
     1594bool UIFrameBuffer::isAutoEnabled() const
     1595{
     1596    return m_pFrameBuffer->isAutoEnabled();
     1597}
     1598
     1599void UIFrameBuffer::setAutoEnabled(bool fAutoEnabled)
     1600{
     1601    m_pFrameBuffer->setAutoEnabled(fAutoEnabled);
     1602}
     1603
     1604QSize UIFrameBuffer::scaledSize() const
     1605{
     1606    return m_pFrameBuffer->scaledSize();
     1607}
     1608
     1609void UIFrameBuffer::setScaledSize(const QSize &size /* = QSize() */)
     1610{
     1611    m_pFrameBuffer->setScaledSize(size);
     1612}
     1613
     1614int UIFrameBuffer::convertHostXTo(int iX) const
     1615{
     1616    return m_pFrameBuffer->convertHostXTo(iX);
     1617}
     1618
     1619int UIFrameBuffer::convertHostYTo(int iY) const
     1620{
     1621    return m_pFrameBuffer->convertHostXTo(iY);
     1622}
     1623
     1624double UIFrameBuffer::scaleFactor() const
     1625{
     1626    return m_pFrameBuffer->scaleFactor();
     1627}
     1628
     1629void UIFrameBuffer::setScaleFactor(double dScaleFactor)
     1630{
     1631    m_pFrameBuffer->setScaleFactor(dScaleFactor);
     1632}
     1633
     1634double UIFrameBuffer::backingScaleFactor() const
     1635{
     1636    return m_pFrameBuffer->backingScaleFactor();
     1637}
     1638
     1639void UIFrameBuffer::setBackingScaleFactor(double dBackingScaleFactor)
     1640{
     1641    m_pFrameBuffer->setBackingScaleFactor(dBackingScaleFactor);
     1642}
     1643
     1644bool UIFrameBuffer::useUnscaledHiDPIOutput() const
     1645{
     1646    return m_pFrameBuffer->useUnscaledHiDPIOutput();
     1647}
     1648
     1649void UIFrameBuffer::setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput)
     1650{
     1651    m_pFrameBuffer->setUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput);
     1652}
     1653
     1654HiDPIOptimizationType UIFrameBuffer::hiDPIOptimizationType() const
     1655{
     1656    return m_pFrameBuffer->hiDPIOptimizationType();
     1657}
     1658
     1659void UIFrameBuffer::setHiDPIOptimizationType(HiDPIOptimizationType optimizationType)
     1660{
     1661    m_pFrameBuffer->setHiDPIOptimizationType(optimizationType);
     1662}
     1663
     1664void UIFrameBuffer::handleNotifyChange(int iWidth, int iHeight)
     1665{
     1666    m_pFrameBuffer->handleNotifyChange(iWidth, iHeight);
     1667}
     1668
     1669void UIFrameBuffer::handlePaintEvent(QPaintEvent *pEvent)
     1670{
     1671    m_pFrameBuffer->handlePaintEvent(pEvent);
     1672}
     1673
     1674void UIFrameBuffer::handleSetVisibleRegion(const QRegion &region)
     1675{
     1676    m_pFrameBuffer->handleSetVisibleRegion(region);
     1677}
     1678
     1679void UIFrameBuffer::performResize(int iWidth, int iHeight)
     1680{
     1681    m_pFrameBuffer->performResize(iWidth, iHeight);
     1682}
     1683
     1684void UIFrameBuffer::performRescale()
     1685{
     1686    m_pFrameBuffer->performRescale();
     1687}
     1688
     1689#ifdef VBOX_WITH_VIDEOHWACCEL
     1690void UIFrameBuffer::doProcessVHWACommand(QEvent *pEvent)
     1691{
     1692    m_pFrameBuffer->doProcessVHWACommand(pEvent);
     1693}
     1694
     1695void UIFrameBuffer::viewportResized(QResizeEvent *pEvent)
     1696{
     1697    m_pFrameBuffer->viewportResized(pEvent);
     1698}
     1699
     1700void UIFrameBuffer::viewportScrolled(int iX, int iY)
     1701{
     1702    m_pFrameBuffer->viewportScrolled(iX, iY);
     1703}
     1704#endif /* VBOX_WITH_VIDEOHWACCEL */
     1705
     1706#include "UIFrameBuffer.moc"
     1707
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r54589 r54590  
    44
    55/*
    6  * Copyright (C) 2010-2014 Oracle Corporation
     6 * Copyright (C) 2010-2015 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919
    2020/* Qt includes: */
    21 #include <QRegion>
    22 #include <QImage>
    23 #include <QTransform>
     21#include <QSize>
    2422
    2523/* GUI includes: */
    26 #include "UIDefs.h"
    2724#include "UIExtraDataDefs.h"
    2825
    29 /* COM includes: */
    30 #include "CDisplay.h"
    31 #include "CDisplaySourceBitmap.h"
    32 
    3326/* Other VBox includes: */
    34 #include <iprt/critsect.h>
     27#include <VBox/com/ptr.h>
    3528
    3629/* Forward declarations: */
     30class UIFrameBufferPrivate;
     31class UIMachineView;
    3732class QResizeEvent;
    3833class QPaintEvent;
    39 class UIMachineView;
     34class QRegion;
    4035
    4136/** IFramebuffer implementation used to maintain VM display video memory. */
    42 class ATL_NO_VTABLE UIFrameBuffer : public QObject,
    43                                     public CComObjectRootEx<CComMultiThreadModel>,
    44                                     VBOX_SCRIPTABLE_IMPL(IFramebuffer)
     37class UIFrameBuffer : public QObject
    4538{
    4639    Q_OBJECT;
    4740
    48 signals:
    49 
    50     /** Notifies listener about guest-screen resolution changes. */
    51     void sigNotifyChange(int iWidth, int iHeight);
    52     /** Notifies listener about guest-screen updates. */
    53     void sigNotifyUpdate(int iX, int iY, int iWidth, int iHeight);
    54     /** Notifies listener about guest-screen visible-region changes. */
    55     void sigSetVisibleRegion(QRegion region);
    56     /** Notifies listener about guest 3D capability changes. */
    57     void sigNotifyAbout3DOverlayVisibilityChange(bool fVisible);
    58 
    5941public:
    6042
     43#ifdef VBOX_WITH_VIDEOHWACCEL
     44    /** Frame-buffer constructor.
     45      * @param m_fAccelerate2DVideo defines whether we should use VBoxOverlayFrameBuffer
     46      *                             instead of the default one. */
     47    UIFrameBuffer(bool m_fAccelerate2DVideo);
     48#else /* !VBOX_WITH_VIDEOHWACCEL */
    6149    /** Frame-buffer constructor. */
    6250    UIFrameBuffer();
     51#endif /* !VBOX_WITH_VIDEOHWACCEL */
     52
    6353    /** Frame-buffer destructor. */
    6454    ~UIFrameBuffer();
     
    6656    /** Frame-buffer initialization.
    6757      * @param pMachineView defines machine-view this frame-buffer is bounded to. */
    68     virtual HRESULT init(UIMachineView *pMachineView);
     58    HRESULT init(UIMachineView *pMachineView);
    6959
    7060    /** Assigns machine-view frame-buffer will be bounded to.
    7161      * @param pMachineView defines machine-view this frame-buffer is bounded to. */
    72     virtual void setView(UIMachineView *pMachineView);
     62    void setView(UIMachineView *pMachineView);
    7363
    74     /** Returns the copy of the IDisplay wrapper. */
    75     CDisplay display() const { return m_display; }
    7664    /** Attach frame-buffer to the Display. */
    7765    void attach();
     
    8068
    8169    /** Returns frame-buffer data address. */
    82     uchar *address() { return m_image.bits(); }
     70    uchar* address();
    8371    /** Returns frame-buffer width. */
    84     ulong width() const { return m_iWidth; }
     72    ulong width() const;
    8573    /** Returns frame-buffer height. */
    86     ulong height() const { return m_iHeight; }
     74    ulong height() const;
    8775    /** Returns frame-buffer bits-per-pixel value. */
    88     ulong bitsPerPixel() const { return m_image.depth(); }
     76    ulong bitsPerPixel() const;
    8977    /** Returns frame-buffer bytes-per-line value. */
    90     ulong bytesPerLine() const { return m_image.bytesPerLine(); }
    91     /** Returns default frame-buffer pixel-format. */
    92     ulong pixelFormat() const { return BitmapFormat_BGR; }
     78    ulong bytesPerLine() const;
    9379    /** Returns the visual-state this frame-buffer is used for. */
    9480    UIVisualStateType visualState() const;
    9581
    9682    /** Defines whether frame-buffer is <b>unused</b>.
    97       * @note Refer to m_fUnused for more information.
    9883      * @note Calls to this and any other EMT callback are synchronized (from GUI side). */
    9984    void setMarkAsUnused(bool fUnused);
     
    10186    /** Returns whether frame-buffer is <b>auto-enabled</b>.
    10287      * @note Refer to m_fAutoEnabled for more information. */
    103     bool isAutoEnabled() const { return m_fAutoEnabled; }
     88    bool isAutoEnabled() const;
    10489    /** Defines whether frame-buffer is <b>auto-enabled</b>.
    10590      * @note Refer to m_fAutoEnabled for more information. */
    106     void setAutoEnabled(bool fAutoEnabled) { m_fAutoEnabled = fAutoEnabled; }
     91    void setAutoEnabled(bool fAutoEnabled);
    10792
    10893    /** Returns the frame-buffer's scaled-size. */
    109     QSize scaledSize() const { return m_scaledSize; }
     94    QSize scaledSize() const;
    11095    /** Defines host-to-guest scale ratio as @a size. */
    111     void setScaledSize(const QSize &size = QSize()) { m_scaledSize = size; }
    112     /** Returns x-origin of the host (scaled) content corresponding to x-origin of guest (actual) content. */
    113     inline int convertGuestXTo(int x) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.width() / m_iWidth * x) : x; }
    114     /** Returns y-origin of the host (scaled) content corresponding to y-origin of guest (actual) content. */
    115     inline int convertGuestYTo(int y) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.height() / m_iHeight * y) : y; }
     96    void setScaledSize(const QSize &size = QSize());
    11697    /** Returns x-origin of the guest (actual) content corresponding to x-origin of host (scaled) content. */
    117     inline int convertHostXTo(int x) const  { return m_scaledSize.isValid() ? qRound((double)m_iWidth / m_scaledSize.width() * x) : x; }
     98    int convertHostXTo(int iX) const;
    11899    /** Returns y-origin of the guest (actual) content corresponding to y-origin of host (scaled) content. */
    119     inline int convertHostYTo(int y) const  { return m_scaledSize.isValid() ? qRound((double)m_iHeight / m_scaledSize.height() * y) : y; }
     100    int convertHostYTo(int iY) const;
    120101
    121102    /** Returns the scale-factor used by the frame-buffer. */
    122     double scaleFactor() const { return m_dScaleFactor; }
     103    double scaleFactor() const;
    123104    /** Define the scale-factor used by the frame-buffer. */
    124     void setScaleFactor(double dScaleFactor) { m_dScaleFactor = dScaleFactor; }
     105    void setScaleFactor(double dScaleFactor);
    125106
    126107    /** Returns backing-scale-factor used by HiDPI frame-buffer. */
    127     double backingScaleFactor() const { return m_dBackingScaleFactor; }
     108    double backingScaleFactor() const;
    128109    /** Defines backing-scale-factor used by HiDPI frame-buffer. */
    129     void setBackingScaleFactor(double dBackingScaleFactor) { m_dBackingScaleFactor = dBackingScaleFactor; }
     110    void setBackingScaleFactor(double dBackingScaleFactor);
    130111
    131112    /** Returns whether frame-buffer should use unscaled HiDPI output. */
    132     bool useUnscaledHiDPIOutput() const { return m_fUseUnscaledHiDPIOutput; }
     113    bool useUnscaledHiDPIOutput() const;
    133114    /** Defines whether frame-buffer should use unscaled HiDPI output. */
    134     void setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput) { m_fUseUnscaledHiDPIOutput = fUseUnscaledHiDPIOutput; }
     115    void setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput);
    135116
    136117    /** Return HiDPI frame-buffer optimization type. */
    137     HiDPIOptimizationType hiDPIOptimizationType() const { return m_hiDPIOptimizationType; }
     118    HiDPIOptimizationType hiDPIOptimizationType() const;
    138119    /** Define HiDPI frame-buffer optimization type: */
    139     void setHiDPIOptimizationType(HiDPIOptimizationType optimizationType) { m_hiDPIOptimizationType = optimizationType; }
    140 
    141     DECLARE_NOT_AGGREGATABLE(UIFrameBuffer)
    142 
    143     DECLARE_PROTECT_FINAL_CONSTRUCT()
    144 
    145     BEGIN_COM_MAP(UIFrameBuffer)
    146         COM_INTERFACE_ENTRY(IFramebuffer)
    147         COM_INTERFACE_ENTRY2(IDispatch,IFramebuffer)
    148         COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
    149     END_COM_MAP()
    150 
    151     HRESULT FinalConstruct();
    152     void FinalRelease();
    153 
    154     /* IFramebuffer COM methods: */
    155     STDMETHOD(COMGETTER(Width))(ULONG *puWidth);
    156     STDMETHOD(COMGETTER(Height))(ULONG *puHeight);
    157     STDMETHOD(COMGETTER(BitsPerPixel))(ULONG *puBitsPerPixel);
    158     STDMETHOD(COMGETTER(BytesPerLine))(ULONG *puBytesPerLine);
    159     STDMETHOD(COMGETTER(PixelFormat))(ULONG *puPixelFormat);
    160     STDMETHOD(COMGETTER(HeightReduction))(ULONG *puHeightReduction);
    161     STDMETHOD(COMGETTER(Overlay))(IFramebufferOverlay **ppOverlay);
    162     STDMETHOD(COMGETTER(WinId))(LONG64 *pWinId);
    163     STDMETHOD(COMGETTER(Capabilities))(ComSafeArrayOut(FramebufferCapabilities_T, aCapabilities));
    164 
    165     /** EMT callback: Notifies frame-buffer about guest-screen size change.
    166       * @param        uScreenId Guest screen number.
    167       * @param        uX        Horizontal origin of the update rectangle, in pixels.
    168       * @param        uY        Vertical origin of the update rectangle, in pixels.
    169       * @param        uWidth    Width of the guest display, in pixels.
    170       * @param        uHeight   Height of the guest display, in pixels.
    171       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    172       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    173     STDMETHOD(NotifyChange)(ULONG uScreenId, ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight);
    174 
    175     /** EMT callback: Notifies frame-buffer about guest-screen update.
    176       * @param        uX      Horizontal origin of the update rectangle, in pixels.
    177       * @param        uY      Vertical origin of the update rectangle, in pixels.
    178       * @param        uWidth  Width of the update rectangle, in pixels.
    179       * @param        uHeight Height of the update rectangle, in pixels.
    180       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    181       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    182     STDMETHOD(NotifyUpdate)(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight);
    183 
    184     /** EMT callback: Notifies frame-buffer about guest-screen update.
    185       * @param        uX      Horizontal origin of the update rectangle, in pixels.
    186       * @param        uY      Vertical origin of the update rectangle, in pixels.
    187       * @param        uWidth  Width of the update rectangle, in pixels.
    188       * @param        uHeight Height of the update rectangle, in pixels.
    189       * @param        image   Brings image container which can be used to copy data from.
    190       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    191       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    192     STDMETHOD(NotifyUpdateImage)(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight, ComSafeArrayIn(BYTE, image));
    193 
    194     /** EMT callback: Returns whether the frame-buffer implementation is willing to support a given video-mode.
    195       * @param        uWidth      Width of the guest display, in pixels.
    196       * @param        uHeight     Height of the guest display, in pixels.
    197       * @param        uBPP        Color depth, bits per pixel.
    198       * @param        pfSupported Is frame-buffer able/willing to render the video mode or not.
    199       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    200       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    201     STDMETHOD(VideoModeSupported)(ULONG uWidth, ULONG uHeight, ULONG uBPP, BOOL *pbSupported);
    202 
    203     /** EMT callback which is not used in current implementation. */
    204     STDMETHOD(GetVisibleRegion)(BYTE *pRectangles, ULONG uCount, ULONG *puCountCopied);
    205     /** EMT callback: Suggests new visible-region to this frame-buffer.
    206       * @param        pRectangles Pointer to the RTRECT array.
    207       * @param        uCount      Number of RTRECT elements in the rectangles array.
    208       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    209       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    210     STDMETHOD(SetVisibleRegion)(BYTE *pRectangles, ULONG uCount);
    211 
    212     /** EMT callback which is not used in current implementation. */
    213     STDMETHOD(ProcessVHWACommand)(BYTE *pCommand);
    214 
    215     /** EMT callback: Notifies frame-buffer about 3D backend event.
    216       * @param        uType Event type. Currently only VBOX3D_NOTIFY_EVENT_TYPE_VISIBLE_3DDATA is supported.
    217       * @param        aData Event-specific data, depends on the supplied event type.
    218       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    219       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    220     STDMETHOD(Notify3DEvent)(ULONG uType, ComSafeArrayIn(BYTE, data));
    221 
    222     /** Locks frame-buffer access. */
    223     void lock() const { RTCritSectEnter(&m_critSect); }
    224     /** Unlocks frame-buffer access. */
    225     void unlock() const { RTCritSectLeave(&m_critSect); }
     120    void setHiDPIOptimizationType(HiDPIOptimizationType optimizationType);
    226121
    227122    /** Handles frame-buffer notify-change-event. */
    228     virtual void handleNotifyChange(int iWidth, int iHeight);
     123    void handleNotifyChange(int iWidth, int iHeight);
    229124    /** Handles frame-buffer paint-event. */
    230     virtual void handlePaintEvent(QPaintEvent *pEvent);
     125    void handlePaintEvent(QPaintEvent *pEvent);
    231126    /** Handles frame-buffer set-visible-region-event. */
    232     virtual void handleSetVisibleRegion(const QRegion &region);
     127    void handleSetVisibleRegion(const QRegion &region);
    233128
    234129    /** Performs frame-buffer resizing. */
    235     virtual void performResize(int iWidth, int iHeight);
     130    void performResize(int iWidth, int iHeight);
    236131    /** Performs frame-buffer rescaling. */
    237     virtual void performRescale();
     132    void performRescale();
    238133
    239134#ifdef VBOX_WITH_VIDEOHWACCEL
    240135    /** Performs Video HW Acceleration command. */
    241     virtual void doProcessVHWACommand(QEvent* /* pEvent */) {}
     136    void doProcessVHWACommand(QEvent *pEvent);
    242137    /** Handles viewport resize-event. */
    243     virtual void viewportResized(QResizeEvent* /* pEvent */) {}
     138    void viewportResized(QResizeEvent *pEvent);
    244139    /** Handles viewport scroll-event. */
    245     virtual void viewportScrolled(int /* iX */, int /* iY */) {}
     140    void viewportScrolled(int iX, int iY);
    246141#endif /* VBOX_WITH_VIDEOHWACCEL */
    247 
    248 
    249 protected:
    250 
    251     /** Prepare connections routine. */
    252     void prepareConnections();
    253     /** Cleanup connections routine. */
    254     void cleanupConnections();
    255 
    256     /** Updates coordinate-system: */
    257     void updateCoordinateSystem();
    258 
    259     /** Default paint routine. */
    260     void paintDefault(QPaintEvent *pEvent);
    261     /** Paint routine for seamless mode. */
    262     void paintSeamless(QPaintEvent *pEvent);
    263 
    264     /** Erases corresponding @a rect with @a painter. */
    265     static void eraseImageRect(QPainter &painter, const QRect &rect,
    266                                bool fUseUnscaledHiDPIOutput,
    267                                HiDPIOptimizationType hiDPIOptimizationType,
    268                                double dBackingScaleFactor);
    269     /** Draws corresponding @a rect of passed @a image with @a painter. */
    270     static void drawImageRect(QPainter &painter, const QImage &image, const QRect &rect,
    271                               int iContentsShiftX, int iContentsShiftY,
    272                               bool fUseUnscaledHiDPIOutput,
    273                               HiDPIOptimizationType hiDPIOptimizationType,
    274                               double dBackingScaleFactor);
    275 
    276     /** Holds the screen-id. */
    277     ulong m_uScreenId;
    278 
    279     /** Holds the QImage buffer. */
    280     QImage m_image;
    281     /** Holds frame-buffer width. */
    282     int m_iWidth;
    283     /** Holds frame-buffer height. */
    284     int m_iHeight;
    285 
    286     /** Holds the copy of the IDisplay wrapper. */
    287     CDisplay m_display;
    288     /** Source bitmap from IDisplay. */
    289     CDisplaySourceBitmap m_sourceBitmap;
    290     /** Source bitmap from IDisplay (acquired but not yet applied). */
    291     CDisplaySourceBitmap m_pendingSourceBitmap;
    292     /** There is a pending source bitmap which must be applied. */
    293     bool m_fPendingSourceBitmap;
    294 
    295     /** Holds machine-view this frame-buffer is bounded to. */
    296     UIMachineView *m_pMachineView;
    297     /** Holds window ID this frame-buffer referring to. */
    298     int64_t m_iWinId;
    299 
    300     /** Reflects whether screen-updates are allowed. */
    301     bool m_fUpdatesAllowed;
    302 
    303     /** Defines whether frame-buffer is <b>unused</b>.
    304       * <b>Unused</b> status determines whether frame-buffer should ignore EMT events or not. */
    305     bool m_fUnused;
    306 
    307     /** Defines whether frame-buffer is <b>auto-enabled</b>.
    308       * <b>Auto-enabled</b> status means that guest-screen corresponding to this frame-buffer
    309       * was automatically enabled by the multi-screen layout (auto-mount guest-screen) functionality,
    310       * so have potentially incorrect size-hint posted into guest event queue.
    311       * Machine-view will try to automatically adjust guest-screen size as soon as possible. */
    312     bool m_fAutoEnabled;
    313 
    314     /** RTCRITSECT object to protect frame-buffer access. */
    315     mutable RTCRITSECT m_critSect;
    316 
    317     /** @name Scale-factor related variables.
    318      * @{ */
    319     /** Holds the scale-factor used by the scaled-size. */
    320     double m_dScaleFactor;
    321     /** Holds the coordinate-system for the scale-factor above. */
    322     QTransform m_transform;
    323     /** Holds the frame-buffer's scaled-size. */
    324     QSize m_scaledSize;
    325     /** @} */
    326 
    327     /** @name Seamless mode related variables.
    328      * @{ */
    329     /* To avoid a seamless flicker which caused by the latency between
    330      * the initial visible-region arriving from EMT thread
    331      * and actual visible-region appliance on GUI thread
    332      * it was decided to use two visible-region instances: */
    333     /** Sync visible-region which being updated synchronously by locking EMT thread.
    334       * Used for immediate manual clipping of the painting operations. */
    335     QRegion m_syncVisibleRegion;
    336     /** Async visible-region which being updated asynchronously by posting async-event from EMT to GUI thread,
    337       * Used to update viewport parts for visible-region changes,
    338       * because NotifyUpdate doesn't take into account these changes. */
    339     QRegion m_asyncVisibleRegion;
    340     /** When the framebuffer is being resized, visible region is saved here.
    341       * The saved region is applied when updates are enabled again. */
    342     QRegion m_pendingSyncVisibleRegion;
    343     /** @} */
    344 
    345     /** @name HiDPI screens related variables.
    346      * @{ */
    347     /** Holds backing-scale-factor used by HiDPI frame-buffer. */
    348     double m_dBackingScaleFactor;
    349     /** Holds whether frame-buffer should use unscaled HiDPI output. */
    350     bool m_fUseUnscaledHiDPIOutput;
    351     /** Holds HiDPI frame-buffer optimization type. */
    352     HiDPIOptimizationType m_hiDPIOptimizationType;
    353     /** @} */
    354142
    355143private:
    356144
    357 #ifdef Q_OS_WIN
    358      CComPtr <IUnknown> m_pUnkMarshaler;
    359 #endif /* Q_OS_WIN */
     145    /** Holds the frame-buffer private instance. */
     146    ComObjPtr<UIFrameBufferPrivate> m_pFrameBuffer;
    360147};
    361148
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r54589 r54590  
    527527    {
    528528#ifdef VBOX_WITH_VIDEOHWACCEL
    529         /* If 2D video acceleration is activated: */
    530         if (m_fAccelerate2DVideo)
    531         {
    532             /* Create new frame-buffer on the basis
    533              * of VBoxOverlayFrameBuffer template: */
    534             ComObjPtr<VBoxOverlayFrameBuffer> pOFB;
    535             pOFB.createObject();
    536             pOFB->init(this, &session(), (uint32_t)screenId());
    537             m_pFrameBuffer = pOFB;
    538         }
    539         /* If 2D video acceleration is not activated: */
    540         else
    541         {
    542             /* Create new default frame-buffer: */
    543             m_pFrameBuffer.createObject();
    544             m_pFrameBuffer->init(this);
    545         }
     529        /* Create new frame-buffer: */
     530        m_pFrameBuffer = new UIFrameBuffer(m_fAccelerate2DVideo);
     531        m_pFrameBuffer->init(this);
    546532#else /* VBOX_WITH_VIDEOHWACCEL */
    547         /* Create new default frame-buffer: */
    548         m_pFrameBuffer.createObject();
     533        /* Create new frame-buffer: */
     534        m_pFrameBuffer = new UIFrameBuffer;
    549535        m_pFrameBuffer->init(this);
    550536#endif /* !VBOX_WITH_VIDEOHWACCEL */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r54554 r54590  
    270270    UIMachineWindow *m_pMachineWindow;
    271271    ulong m_uScreenId;
    272     ComObjPtr<UIFrameBuffer> m_pFrameBuffer;
     272    UIFrameBuffer *m_pFrameBuffer;
    273273    KMachineState m_previousState;
    274274    /** HACK: when switching out of fullscreen or seamless we wish to override
     
    307307    friend class UIMachineLogic;
    308308    friend class UIFrameBuffer;
     309    friend class UIFrameBufferPrivate;
    309310    friend class VBoxOverlayFrameBuffer;
    310311};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r54589 r54590  
    14201420            /* Detach framebuffer from Display: */
    14211421            pFrameBuffer->detach();
    1422             /* Release framebuffer reference: */
    1423             m_frameBufferVector[i].setNull();
     1422            /* Delete framebuffer reference: */
     1423            delete pFrameBuffer;
    14241424        }
    14251425    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r54577 r54590  
    243243    void setFrameBuffer(ulong uScreenId, UIFrameBuffer* pFrameBuffer);
    244244    /** Returns existing frame-buffer vector. */
    245     const QVector<ComObjPtr<UIFrameBuffer> >& frameBuffers() const { return m_frameBufferVector; }
     245    const QVector<UIFrameBuffer*>& frameBuffers() const { return m_frameBufferVector; }
    246246
    247247    /** Updates VRDE Server action state. */
     
    419419
    420420    /* Frame-buffers vector: */
    421     QVector<ComObjPtr<UIFrameBuffer> > m_frameBufferVector;
     421    QVector<UIFrameBuffer*> m_frameBufferVector;
    422422
    423423    /* Common variables: */
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