VirtualBox

Changeset 54587 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Mar 2, 2015 6:13:38 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 01).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r54566 r54587  
    114114}
    115115
    116 HRESULT UIFrameBuffer::FinalConstruct()
    117 {
    118     return 0;
    119 }
    120 
    121 void UIFrameBuffer::FinalRelease()
    122 {
    123     return;
    124 }
    125 
    126116void UIFrameBuffer::setView(UIMachineView *pMachineView)
    127117{
     
    136126
    137127#ifdef Q_WS_X11
    138     /* Sync Qt and X11 Server. Notify server about newly
    139      * created winId (see xTracker #7547). */
     128    /* Sync Qt and X11 Server (see xTracker #7547). */
    140129    XSync(QX11Info::display(), false);
    141130#endif
     
    146135}
    147136
     137UIVisualStateType UIFrameBuffer::visualState() const
     138{
     139    return m_pMachineView ? m_pMachineView->visualStateType() : UIVisualStateType_Invalid;
     140}
     141
    148142void UIFrameBuffer::setMarkAsUnused(bool fUnused)
    149143{
     
    153147}
    154148
    155 UIVisualStateType UIFrameBuffer::visualState() const
    156 {
    157     return m_pMachineView ? m_pMachineView->visualStateType() : UIVisualStateType_Invalid;
     149HRESULT UIFrameBuffer::FinalConstruct()
     150{
     151    return 0;
     152}
     153
     154void UIFrameBuffer::FinalRelease()
     155{
     156    return;
    158157}
    159158
     
    222221}
    223222
    224 STDMETHODIMP UIFrameBuffer::COMGETTER(Capabilities)(ComSafeArrayOut(FramebufferCapabilities_T, aCapabilities))
    225 {
    226     if (ComSafeArrayOutIsNull(aCapabilities))
     223STDMETHODIMP UIFrameBuffer::COMGETTER(Capabilities)(ComSafeArrayOut(FramebufferCapabilities_T, enmCapabilities))
     224{
     225    if (ComSafeArrayOutIsNull(enmCapabilities))
    227226        return E_POINTER;
    228227
     
    240239    }
    241240
    242     caps.detachTo(ComSafeArrayOutArg(aCapabilities));
     241    caps.detachTo(ComSafeArrayOutArg(enmCapabilities));
    243242    return S_OK;
    244243}
     
    794793}
    795794
    796 #ifdef VBOX_WITH_VIDEOHWACCEL
    797 void UIFrameBuffer::doProcessVHWACommand(QEvent *pEvent)
    798 {
    799     Q_UNUSED(pEvent);
    800     /* should never be here */
    801     AssertBreakpoint();
    802     // TODO: Is this required? ^
    803 }
    804 #endif /* VBOX_WITH_VIDEOHWACCEL */
    805 
    806795void UIFrameBuffer::prepareConnections()
    807796{
    808     /* EMT connections: */
     797    /* Attach EMT connections: */
    809798    connect(this, SIGNAL(sigNotifyChange(int, int)),
    810799            m_pMachineView, SLOT(sltHandleNotifyChange(int, int)),
     
    823812void UIFrameBuffer::cleanupConnections()
    824813{
    825     /* EMT connections: */
     814    /* Detach EMT connections: */
    826815    disconnect(this, SIGNAL(sigNotifyChange(int, int)),
    827816               m_pMachineView, SLOT(sltHandleNotifyChange(int, int)));
     
    942931#if defined(VBOX_WITH_TRANSLUCENT_SEAMLESS)
    943932# if defined(Q_WS_WIN) || defined(Q_WS_X11)
    944     /* Replace translucent background with black one,
    945      * that is necessary for window with Qt::WA_TranslucentBackground
    946      * and no native backing store support like Mac OS X has: */
     933    /* Replace translucent background with black one: */
    947934    painter.setCompositionMode(QPainter::CompositionMode_Source);
    948935    painter.fillRect(paintRect, QColor(Qt::black));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r54566 r54587  
    3939class UIMachineView;
    4040
    41 /** Common IFramebuffer implementation used to maintain VM display video memory. */
    42 class ATL_NO_VTABLE UIFrameBuffer :
    43     public QObject,
    44     public CComObjectRootEx<CComMultiThreadModel>,
    45     VBOX_SCRIPTABLE_IMPL(IFramebuffer)
     41/** IFramebuffer implementation used to maintain VM display video memory. */
     42class ATL_NO_VTABLE UIFrameBuffer : public QObject,
     43                                    public CComObjectRootEx<CComMultiThreadModel>,
     44                                    VBOX_SCRIPTABLE_IMPL(IFramebuffer)
    4645{
    4746    Q_OBJECT;
     
    6766    /** Frame-buffer initialization.
    6867      * @param pMachineView defines machine-view this frame-buffer is bounded to. */
    69     HRESULT init(UIMachineView *pMachineView);
    70 
    71     /** Returns the copy of the IDisplay wrapper. */
    72     CDisplay display() const { return m_display; }
     68    virtual HRESULT init(UIMachineView *pMachineView);
    7369
    7470    /** Assigns machine-view frame-buffer will be bounded to.
     
    7672    virtual void setView(UIMachineView *pMachineView);
    7773
    78     /** Defines whether frame-buffer is <b>unused</b>.
    79       * @note Refer to m_fUnused for more information.
    80       * @note Calls to this and any other EMT callback are synchronized (from GUI side). */
    81     void setMarkAsUnused(bool fUnused);
    82 
    83     /** Returns the visual-state this frame-buffer is used for. */
    84     UIVisualStateType visualState() const;
    85 
    86     /** Returns whether frame-buffer is <b>auto-enabled</b>.
    87       * @note Refer to m_fAutoEnabled for more information. */
    88     bool isAutoEnabled() const { return m_fAutoEnabled; }
    89     /** Defines whether frame-buffer is <b>auto-enabled</b>.
    90       * @note Refer to m_fAutoEnabled for more information. */
    91     void setAutoEnabled(bool fAutoEnabled) { m_fAutoEnabled = fAutoEnabled; }
    92 
    93     DECLARE_NOT_AGGREGATABLE(UIFrameBuffer)
    94 
    95     DECLARE_PROTECT_FINAL_CONSTRUCT()
    96 
    97     BEGIN_COM_MAP(UIFrameBuffer)
    98         COM_INTERFACE_ENTRY(IFramebuffer)
    99         COM_INTERFACE_ENTRY2(IDispatch,IFramebuffer)
    100         COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
    101     END_COM_MAP()
    102 
    103     HRESULT FinalConstruct();
    104     void FinalRelease();
    105 
    106     /* IFramebuffer COM methods: */
    107     STDMETHOD(COMGETTER(Width))(ULONG *puWidth);
    108     STDMETHOD(COMGETTER(Height))(ULONG *puHeight);
    109     STDMETHOD(COMGETTER(BitsPerPixel))(ULONG *puBitsPerPixel);
    110     STDMETHOD(COMGETTER(BytesPerLine))(ULONG *puBytesPerLine);
    111     STDMETHOD(COMGETTER(PixelFormat))(ULONG *puPixelFormat);
    112     STDMETHOD(COMGETTER(HeightReduction))(ULONG *puHeightReduction);
    113     STDMETHOD(COMGETTER(Overlay))(IFramebufferOverlay **ppOverlay);
    114     STDMETHOD(COMGETTER(WinId))(LONG64 *pWinId);
    115     STDMETHOD(COMGETTER(Capabilities))(ComSafeArrayOut(FramebufferCapabilities_T, aCapabilities));
    116 
    117     /** EMT callback: Notifies frame-buffer about guest-screen size change.
    118       * @param        uScreenId Guest screen number.
    119       * @param        uX        Horizontal origin of the update rectangle, in pixels.
    120       * @param        uY        Vertical origin of the update rectangle, in pixels.
    121       * @param        uWidth    Width of the guest display, in pixels.
    122       * @param        uHeight   Height of the guest display, in pixels.
    123       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    124       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    125     STDMETHOD(NotifyChange)(ULONG uScreenId, ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight);
    126 
    127     /** EMT callback: Notifies frame-buffer about guest-screen update.
    128       * @param        uX      Horizontal origin of the update rectangle, in pixels.
    129       * @param        uY      Vertical origin of the update rectangle, in pixels.
    130       * @param        uWidth  Width of the update rectangle, in pixels.
    131       * @param        uHeight Height of the update rectangle, in pixels.
    132       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    133       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    134     STDMETHOD(NotifyUpdate)(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight);
    135 
    136     /** EMT callback: Notifies frame-buffer about guest-screen update.
    137       * @param        uX      Horizontal origin of the update rectangle, in pixels.
    138       * @param        uY      Vertical origin of the update rectangle, in pixels.
    139       * @param        uWidth  Width of the update rectangle, in pixels.
    140       * @param        uHeight Height of the update rectangle, in pixels.
    141       * @param        image   Brings image container which can be used to copy data from.
    142       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    143       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    144     STDMETHOD(NotifyUpdateImage)(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight, ComSafeArrayIn(BYTE, image));
    145 
    146     /** EMT callback: Returns whether the frame-buffer implementation is willing to support a given video-mode.
    147       * @param        uWidth      Width of the guest display, in pixels.
    148       * @param        uHeight     Height of the guest display, in pixels.
    149       * @param        uBPP        Color depth, bits per pixel.
    150       * @param        pfSupported Is frame-buffer able/willing to render the video mode or not.
    151       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    152       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    153     STDMETHOD(VideoModeSupported)(ULONG uWidth, ULONG uHeight, ULONG uBPP, BOOL *pbSupported);
    154 
    155     /** EMT callback which is not used in current implementation. */
    156     STDMETHOD(GetVisibleRegion)(BYTE *pRectangles, ULONG uCount, ULONG *puCountCopied);
    157     /** EMT callback: Suggests new visible-region to this frame-buffer.
    158       * @param        pRectangles Pointer to the RTRECT array.
    159       * @param        uCount      Number of RTRECT elements in the rectangles array.
    160       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    161       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    162     STDMETHOD(SetVisibleRegion)(BYTE *pRectangles, ULONG uCount);
    163 
    164     /** EMT callback which is not used in current implementation. */
    165     STDMETHOD(ProcessVHWACommand)(BYTE *pCommand);
    166 
    167     /** EMT callback: Notifies frame-buffer about 3D backend event.
    168       * @param        uType Event type. Currently only VBOX3D_NOTIFY_EVENT_TYPE_VISIBLE_3DDATA is supported.
    169       * @param        aData Event-specific data, depends on the supplied event type.
    170       * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
    171       * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
    172     STDMETHOD(Notify3DEvent)(ULONG uType, ComSafeArrayIn(BYTE, data));
     74    /** Returns the copy of the IDisplay wrapper. */
     75    CDisplay display() const { return m_display; }
    17376
    17477    /** Returns frame-buffer data address. */
     
    18487    /** Returns default frame-buffer pixel-format. */
    18588    ulong pixelFormat() const { return BitmapFormat_BGR; }
    186 
    187     /** Locks frame-buffer access. */
    188     void lock() const { RTCritSectEnter(&m_critSect); }
    189     /** Unlocks frame-buffer access. */
    190     void unlock() const { RTCritSectLeave(&m_critSect); }
     89    /** Returns the visual-state this frame-buffer is used for. */
     90    UIVisualStateType visualState() const;
     91
     92    /** Defines whether frame-buffer is <b>unused</b>.
     93      * @note Refer to m_fUnused for more information.
     94      * @note Calls to this and any other EMT callback are synchronized (from GUI side). */
     95    void setMarkAsUnused(bool fUnused);
     96
     97    /** Returns whether frame-buffer is <b>auto-enabled</b>.
     98      * @note Refer to m_fAutoEnabled for more information. */
     99    bool isAutoEnabled() const { return m_fAutoEnabled; }
     100    /** Defines whether frame-buffer is <b>auto-enabled</b>.
     101      * @note Refer to m_fAutoEnabled for more information. */
     102    void setAutoEnabled(bool fAutoEnabled) { m_fAutoEnabled = fAutoEnabled; }
    191103
    192104    /** Returns the frame-buffer's scaled-size. */
     
    203115    inline int convertHostYTo(int y) const  { return m_scaledSize.isValid() ? qRound((double)m_iHeight / m_scaledSize.height() * y) : y; }
    204116
     117    /** Returns the scale-factor used by the frame-buffer. */
     118    double scaleFactor() const { return m_dScaleFactor; }
     119    /** Define the scale-factor used by the frame-buffer. */
     120    void setScaleFactor(double dScaleFactor) { m_dScaleFactor = dScaleFactor; }
     121
     122    /** Returns backing-scale-factor used by HiDPI frame-buffer. */
     123    double backingScaleFactor() const { return m_dBackingScaleFactor; }
     124    /** Defines backing-scale-factor used by HiDPI frame-buffer. */
     125    void setBackingScaleFactor(double dBackingScaleFactor) { m_dBackingScaleFactor = dBackingScaleFactor; }
     126
     127    /** Returns whether frame-buffer should use unscaled HiDPI output. */
     128    bool useUnscaledHiDPIOutput() const { return m_fUseUnscaledHiDPIOutput; }
     129    /** Defines whether frame-buffer should use unscaled HiDPI output. */
     130    void setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput) { m_fUseUnscaledHiDPIOutput = fUseUnscaledHiDPIOutput; }
     131
     132    /** Return HiDPI frame-buffer optimization type. */
     133    HiDPIOptimizationType hiDPIOptimizationType() const { return m_hiDPIOptimizationType; }
     134    /** Define HiDPI frame-buffer optimization type: */
     135    void setHiDPIOptimizationType(HiDPIOptimizationType optimizationType) { m_hiDPIOptimizationType = optimizationType; }
     136
     137    DECLARE_NOT_AGGREGATABLE(UIFrameBuffer)
     138
     139    DECLARE_PROTECT_FINAL_CONSTRUCT()
     140
     141    BEGIN_COM_MAP(UIFrameBuffer)
     142        COM_INTERFACE_ENTRY(IFramebuffer)
     143        COM_INTERFACE_ENTRY2(IDispatch,IFramebuffer)
     144        COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
     145    END_COM_MAP()
     146
     147    HRESULT FinalConstruct();
     148    void FinalRelease();
     149
     150    /* IFramebuffer COM methods: */
     151    STDMETHOD(COMGETTER(Width))(ULONG *puWidth);
     152    STDMETHOD(COMGETTER(Height))(ULONG *puHeight);
     153    STDMETHOD(COMGETTER(BitsPerPixel))(ULONG *puBitsPerPixel);
     154    STDMETHOD(COMGETTER(BytesPerLine))(ULONG *puBytesPerLine);
     155    STDMETHOD(COMGETTER(PixelFormat))(ULONG *puPixelFormat);
     156    STDMETHOD(COMGETTER(HeightReduction))(ULONG *puHeightReduction);
     157    STDMETHOD(COMGETTER(Overlay))(IFramebufferOverlay **ppOverlay);
     158    STDMETHOD(COMGETTER(WinId))(LONG64 *pWinId);
     159    STDMETHOD(COMGETTER(Capabilities))(ComSafeArrayOut(FramebufferCapabilities_T, aCapabilities));
     160
     161    /** EMT callback: Notifies frame-buffer about guest-screen size change.
     162      * @param        uScreenId Guest screen number.
     163      * @param        uX        Horizontal origin of the update rectangle, in pixels.
     164      * @param        uY        Vertical origin of the update rectangle, in pixels.
     165      * @param        uWidth    Width of the guest display, in pixels.
     166      * @param        uHeight   Height of the guest display, in pixels.
     167      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     168      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     169    STDMETHOD(NotifyChange)(ULONG uScreenId, ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight);
     170
     171    /** EMT callback: Notifies frame-buffer about guest-screen update.
     172      * @param        uX      Horizontal origin of the update rectangle, in pixels.
     173      * @param        uY      Vertical origin of the update rectangle, in pixels.
     174      * @param        uWidth  Width of the update rectangle, in pixels.
     175      * @param        uHeight Height of the update rectangle, in pixels.
     176      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     177      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     178    STDMETHOD(NotifyUpdate)(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight);
     179
     180    /** EMT callback: Notifies frame-buffer about guest-screen update.
     181      * @param        uX      Horizontal origin of the update rectangle, in pixels.
     182      * @param        uY      Vertical origin of the update rectangle, in pixels.
     183      * @param        uWidth  Width of the update rectangle, in pixels.
     184      * @param        uHeight Height of the update rectangle, in pixels.
     185      * @param        image   Brings image container which can be used to copy data from.
     186      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     187      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     188    STDMETHOD(NotifyUpdateImage)(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight, ComSafeArrayIn(BYTE, image));
     189
     190    /** EMT callback: Returns whether the frame-buffer implementation is willing to support a given video-mode.
     191      * @param        uWidth      Width of the guest display, in pixels.
     192      * @param        uHeight     Height of the guest display, in pixels.
     193      * @param        uBPP        Color depth, bits per pixel.
     194      * @param        pfSupported Is frame-buffer able/willing to render the video mode or not.
     195      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     196      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     197    STDMETHOD(VideoModeSupported)(ULONG uWidth, ULONG uHeight, ULONG uBPP, BOOL *pbSupported);
     198
     199    /** EMT callback which is not used in current implementation. */
     200    STDMETHOD(GetVisibleRegion)(BYTE *pRectangles, ULONG uCount, ULONG *puCountCopied);
     201    /** EMT callback: Suggests new visible-region to this frame-buffer.
     202      * @param        pRectangles Pointer to the RTRECT array.
     203      * @param        uCount      Number of RTRECT elements in the rectangles array.
     204      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     205      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     206    STDMETHOD(SetVisibleRegion)(BYTE *pRectangles, ULONG uCount);
     207
     208    /** EMT callback which is not used in current implementation. */
     209    STDMETHOD(ProcessVHWACommand)(BYTE *pCommand);
     210
     211    /** EMT callback: Notifies frame-buffer about 3D backend event.
     212      * @param        uType Event type. Currently only VBOX3D_NOTIFY_EVENT_TYPE_VISIBLE_3DDATA is supported.
     213      * @param        aData Event-specific data, depends on the supplied event type.
     214      * @note         Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
     215      * @note         Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
     216    STDMETHOD(Notify3DEvent)(ULONG uType, ComSafeArrayIn(BYTE, data));
     217
     218    /** Locks frame-buffer access. */
     219    void lock() const { RTCritSectEnter(&m_critSect); }
     220    /** Unlocks frame-buffer access. */
     221    void unlock() const { RTCritSectLeave(&m_critSect); }
     222
    205223    /** Handles frame-buffer notify-change-event. */
    206224    virtual void handleNotifyChange(int iWidth, int iHeight);
     
    217235#ifdef VBOX_WITH_VIDEOHWACCEL
    218236    /** Performs Video HW Acceleration command. */
    219     virtual void doProcessVHWACommand(QEvent *pEvent);
     237    virtual void doProcessVHWACommand(QEvent* /* pEvent */) {}
    220238    /** Handles viewport resize-event. */
    221     virtual void viewportResized(QResizeEvent * /* pEvent */) {}
     239    virtual void viewportResized(QResizeEvent* /* pEvent */) {}
    222240    /** Handles viewport scroll-event. */
    223241    virtual void viewportScrolled(int /* iX */, int /* iY */) {}
    224242#endif /* VBOX_WITH_VIDEOHWACCEL */
    225243
    226     /** Returns the scale-factor used by the frame-buffer. */
    227     double scaleFactor() const { return m_dScaleFactor; }
    228     /** Define the scale-factor used by the frame-buffer. */
    229     void setScaleFactor(double dScaleFactor) { m_dScaleFactor = dScaleFactor; }
    230 
    231     /** Returns backing-scale-factor used by HiDPI frame-buffer. */
    232     double backingScaleFactor() const { return m_dBackingScaleFactor; }
    233     /** Defines backing-scale-factor used by HiDPI frame-buffer. */
    234     void setBackingScaleFactor(double dBackingScaleFactor) { m_dBackingScaleFactor = dBackingScaleFactor; }
    235 
    236     /** Returns whether frame-buffer should use unscaled HiDPI output. */
    237     bool useUnscaledHiDPIOutput() const { return m_fUseUnscaledHiDPIOutput; }
    238     /** Defines whether frame-buffer should use unscaled HiDPI output. */
    239     void setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput) { m_fUseUnscaledHiDPIOutput = fUseUnscaledHiDPIOutput; }
    240 
    241     /** Return HiDPI frame-buffer optimization type. */
    242     HiDPIOptimizationType hiDPIOptimizationType() const { return m_hiDPIOptimizationType; }
    243     /** Define HiDPI frame-buffer optimization type: */
    244     void setHiDPIOptimizationType(HiDPIOptimizationType optimizationType) { m_hiDPIOptimizationType = optimizationType; }
    245244
    246245protected:
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