Changeset 52086 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jul 17, 2014 7:57:07 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
r51667 r52086 4147 4147 } 4148 4148 4149 VBoxQGLOverlay::VBoxQGLOverlay ( QWidget *pViewport,QObject *pPostEventObject, CSession * aSession, uint32_t id)4149 VBoxQGLOverlay::VBoxQGLOverlay () 4150 4150 : mpOverlayWgt (NULL), 4151 mpViewport ( pViewport),4151 mpViewport (NULL), 4152 4152 mGlOn (false), 4153 4153 mOverlayWidgetVisible (false), … … 4157 4157 mNeedOverlayRepaint (false), 4158 4158 mNeedSetVisible (false), 4159 mCmdPipe ( pPostEventObject),4160 mSettings ( *aSession),4161 mpSession( aSession),4159 mCmdPipe (), 4160 mSettings (), 4161 mpSession(), 4162 4162 mpShareWgt (NULL), 4163 m_id( id)4163 m_id(0) 4164 4164 { 4165 4165 /* postpone the gl widget initialization to avoid conflict with 3D on Mac */ 4166 } 4167 4168 void VBoxQGLOverlay::init(QWidget *pViewport, QObject *pPostEventObject, CSession * aSession, uint32_t id) 4169 { 4170 mpViewport = pViewport; 4171 mpSession = aSession; 4172 m_id = id; 4173 mSettings.init(*aSession); 4174 mCmdPipe.init(pPostEventObject); 4166 4175 } 4167 4176 … … 4948 4957 } 4949 4958 4950 VBoxVHWACommandElementProcessor::VBoxVHWACommandElementProcessor( QObject *pNotifyObject) :4951 m_pNotifyObject( pNotifyObject),4959 VBoxVHWACommandElementProcessor::VBoxVHWACommandElementProcessor() : 4960 m_pNotifyObject(NULL), 4952 4961 mpCurCmd(NULL), 4953 4962 mbResetting(false), … … 4960 4969 4961 4970 m_pCmdEntryCache = new VBoxVHWAEntriesCache; 4971 } 4972 4973 void VBoxVHWACommandElementProcessor::init(QObject *pNotifyObject) 4974 { 4975 m_pNotifyObject = pNotifyObject; 4962 4976 } 4963 4977 … … 5775 5789 } 5776 5790 5777 VBoxVHWASettings::VBoxVHWASettings (CSession &session) 5791 VBoxVHWASettings::VBoxVHWASettings () 5792 { 5793 } 5794 5795 void VBoxVHWASettings::init(CSession &session) 5778 5796 { 5779 5797 const QString strMachineID = session.GetMachine().GetId(); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.h
r51493 r52086 32 32 #include "UIDefs.h" 33 33 #include "VBoxFBOverlayCommon.h" 34 #include "runtime/UIFrameBuffer.h" 35 #include "runtime/UIMachineView.h" 34 36 35 37 /* COM includes: */ … … 84 86 { 85 87 public: 86 VBoxVHWASettings (CSession &session); 88 VBoxVHWASettings (); 89 void init(CSession &session); 87 90 88 91 int fourccEnabledCount() const { return mFourccEnabledCount; } … … 1311 1314 { 1312 1315 public: 1313 VBoxVHWACommandElementProcessor(QObject *pNotifyObject); 1316 VBoxVHWACommandElementProcessor(); 1317 void init(QObject *pNotifyObject); 1314 1318 ~VBoxVHWACommandElementProcessor(); 1315 1319 void postCmd(VBOXVHWA_PIPECMD_TYPE aType, void * pvData); … … 1673 1677 { 1674 1678 public: 1675 VBoxQGLOverlay(QWidget *pViewport, QObject *pPostEventObject, CSession * aSession, uint32_t id); 1679 VBoxQGLOverlay(); 1680 void init(QWidget *pViewport, QObject *pPostEventObject, CSession * aSession, uint32_t id); 1676 1681 ~VBoxQGLOverlay() 1677 1682 { … … 1819 1824 }; 1820 1825 1821 /* this additional class V is to workaround the [VBox|UI] duplication, 1822 * @todo: remove it once VBox stuff is removed */ 1823 template <class T, class V> 1824 class VBoxOverlayFrameBuffer : public T 1825 { 1826 public: 1827 VBoxOverlayFrameBuffer (V *pView, CSession * aSession, uint32_t id) 1828 : T (pView), 1829 mOverlay(pView->viewport(), pView, aSession, id), 1830 mpView (pView) 1831 { 1826 class VBoxOverlayFrameBuffer : public UIFrameBuffer 1827 { 1828 public: 1829 VBoxOverlayFrameBuffer() 1830 { 1831 } 1832 1833 HRESULT init(UIMachineView *pView, CSession * aSession, uint32_t id) 1834 { 1835 mpView = pView; 1836 UIFrameBuffer::init(mpView); 1837 mOverlay.init(mpView->viewport(), mpView, aSession, id), 1832 1838 /* sync with framebuffer */ 1833 1839 mOverlay.onResizeEventPostprocess (VBoxFBSizeInfo(this), QPoint(mpView->contentsX(), mpView->contentsY())); 1840 return S_OK; 1834 1841 } 1835 1842 … … 1837 1844 { 1838 1845 int rc; 1839 T::lock();1846 UIFrameBuffer::lock(); 1840 1847 /* Make sure frame-buffer is used: */ 1841 if ( T::m_fUnused)1848 if (UIFrameBuffer::m_fUnused) 1842 1849 { 1843 1850 LogRel2(("ProcessVHWACommand: Postponed!\n")); 1844 1851 /* Unlock access to frame-buffer: */ 1845 T::unlock();1852 UIFrameBuffer::unlock(); 1846 1853 /* tell client to pend ProcessVHWACommand */ 1847 1854 return E_ACCESSDENIED; 1848 1855 } 1849 1856 rc = mOverlay.onVHWACommand ((struct VBOXVHWACMD*)pCommand); 1850 T::unlock();1857 UIFrameBuffer::unlock(); 1851 1858 if (rc == VINF_CALLBACK_RETURN) 1852 1859 return S_OK; … … 1867 1874 { 1868 1875 HRESULT hr = S_OK; 1869 T::lock();1876 UIFrameBuffer::lock(); 1870 1877 /* Make sure frame-buffer is used: */ 1871 if ( T::m_fUnused)1878 if (UIFrameBuffer::m_fUnused) 1872 1879 { 1873 1880 LogRel2(("NotifyUpdate: Ignored!\n")); 1874 1881 mOverlay.onNotifyUpdateIgnore (aX, aY, aW, aH); 1875 1882 /* Unlock access to frame-buffer: */ 1876 T::unlock();1883 UIFrameBuffer::unlock(); 1877 1884 /*can we actually ignore the notify update?*/ 1878 1885 /* Ignore NotifyUpdate: */ … … 1881 1888 1882 1889 if (!mOverlay.onNotifyUpdate (aX, aY, aW, aH)) 1883 hr = T::NotifyUpdate (aX, aY, aW, aH);1884 T::unlock();1890 hr = UIFrameBuffer::NotifyUpdate (aX, aY, aW, aH); 1891 UIFrameBuffer::unlock(); 1885 1892 return hr; 1886 1893 } … … 1888 1895 void resizeEvent(int iWidth, int iHeight) 1889 1896 { 1890 T::resizeEvent(iWidth, iHeight);1897 UIFrameBuffer::resizeEvent(iWidth, iHeight); 1891 1898 mOverlay.onResizeEventPostprocess(VBoxFBSizeInfo(this), 1892 1899 QPoint(mpView->contentsX(), mpView->contentsY())); … … 1896 1903 { 1897 1904 mOverlay.onViewportResized (re); 1898 T::viewportResized (re);1905 UIFrameBuffer::viewportResized (re); 1899 1906 } 1900 1907 … … 1902 1909 { 1903 1910 mOverlay.onViewportScrolled (QPoint(mpView->contentsX(), mpView->contentsY())); 1904 T::viewportScrolled (dx, dy);1905 } 1906 1907 void setView( V* pView)1911 UIFrameBuffer::viewportScrolled (dx, dy); 1912 } 1913 1914 void setView(UIMachineView * pView) 1908 1915 { 1909 1916 /* lock to ensure we do not collide with the EMT thread passing commands to us */ 1910 T::lock();1911 T::setView(pView);1917 UIFrameBuffer::lock(); 1918 UIFrameBuffer::setView(pView); 1912 1919 mpView = pView; 1913 1920 mOverlay.updateAttachment(pView ? pView->viewport() : NULL, pView); 1914 T::unlock();1921 UIFrameBuffer::unlock(); 1915 1922 } 1916 1923 1917 1924 private: 1918 1925 VBoxQGLOverlay mOverlay; 1919 V*mpView;1926 UIMachineView *mpView; 1920 1927 }; 1921 1928 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r51747 r52086 47 47 #endif /* !Q_WS_WIN */ 48 48 49 UIFrameBuffer::UIFrameBuffer( UIMachineView *pMachineView)49 UIFrameBuffer::UIFrameBuffer() 50 50 : m_iWidth(0), m_iHeight(0) 51 , m_pMachineView( pMachineView)51 , m_pMachineView(NULL) 52 52 , m_iWinId(0) 53 53 , m_fUpdatesAllowed(true) 54 54 , m_fUnused(false) 55 55 , m_fAutoEnabled(false) 56 #ifdef Q_OS_WIN57 , m_iRefCnt(0)58 #endif /* Q_OS_WIN */59 56 , m_hiDPIOptimizationType(HiDPIOptimizationType_None) 60 57 , m_dBackingScaleFactor(1.0) 61 58 { 59 } 60 61 HRESULT UIFrameBuffer::init(UIMachineView *pMachineView) 62 { 63 LogRel2(("UIFrameBuffer::init %p\n", this)); 64 62 65 /* Assign mahine-view: */ 63 AssertMsg(m_pMachineView, ("UIMachineView must not be NULL\n"));66 m_pMachineView = pMachineView; 64 67 /* Cache window ID: */ 65 68 m_iWinId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0; … … 75 78 /* Resize frame-buffer to default size: */ 76 79 resizeEvent(640, 480); 80 81 #ifdef Q_OS_WIN 82 CoCreateFreeThreadedMarshaler(this, &m_pUnkMarshaler.p); 83 #endif /* Q_OS_WIN */ 84 return S_OK; 77 85 } 78 86 79 87 UIFrameBuffer::~UIFrameBuffer() 80 88 { 89 LogRel2(("UIFrameBuffer::~UIFrameBuffer %p\n", this)); 90 81 91 /* Disconnect handlers: */ 82 92 if (m_pMachineView) … … 85 95 /* Deinitialize critical-section: */ 86 96 RTCritSectDelete(&m_critSect); 97 } 98 99 HRESULT UIFrameBuffer::FinalConstruct() 100 { 101 return 0; 102 } 103 104 void UIFrameBuffer::FinalRelease() 105 { 106 return; 87 107 } 88 108 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h
r51693 r52086 38 38 39 39 /** Common IFramebuffer implementation used to maintain VM display video memory. */ 40 class UIFrameBuffer : public QObject, VBOX_SCRIPTABLE_IMPL(IFramebuffer) 40 class ATL_NO_VTABLE UIFrameBuffer : 41 public QObject, 42 public CComObjectRootEx<CComMultiThreadModel>, 43 VBOX_SCRIPTABLE_IMPL(IFramebuffer) 41 44 { 42 45 Q_OBJECT; … … 55 58 public: 56 59 57 /** Frame-buffer constructor. 58 * @param pMachineView defines machine-view this frame-buffer is bounded to. */ 59 UIFrameBuffer(UIMachineView *pMachineView); 60 /** Frame-buffer constructor. */ 61 UIFrameBuffer(); 60 62 /** Frame-buffer destructor. */ 61 63 ~UIFrameBuffer(); 64 65 /** Frame-buffer initialization. 66 * @param pMachineView defines machine-view this frame-buffer is bounded to. */ 67 HRESULT init(UIMachineView *pMachineView); 62 68 63 69 /** Assigns machine-view frame-buffer will be bounded to. … … 77 83 void setAutoEnabled(bool fAutoEnabled) { m_fAutoEnabled = fAutoEnabled; } 78 84 79 NS_DECL_ISUPPORTS 80 81 #ifdef Q_OS_WIN 82 /** Windows: Increments reference-counter. */ 83 STDMETHOD_(ULONG, AddRef)() 84 { 85 return ::InterlockedIncrement(&m_iRefCnt); 86 } 87 88 /** Windows: Decrements reference-counter. */ 89 STDMETHOD_(ULONG, Release)() 90 { 91 long iCounter = ::InterlockedDecrement(&m_iRefCnt); 92 if (iCounter == 0) 93 delete this; 94 return iCounter; 95 } 96 #endif /* Q_OS_WIN */ 97 98 VBOX_SCRIPTABLE_DISPATCH_IMPL(IFramebuffer) 85 DECLARE_NOT_AGGREGATABLE(UIFrameBuffer) 86 87 DECLARE_PROTECT_FINAL_CONSTRUCT() 88 89 BEGIN_COM_MAP(UIFrameBuffer) 90 COM_INTERFACE_ENTRY(IFramebuffer) 91 COM_INTERFACE_ENTRY2(IDispatch,IFramebuffer) 92 COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p) 93 END_COM_MAP() 94 95 HRESULT FinalConstruct(); 96 void FinalRelease(); 99 97 100 98 /* IFramebuffer COM methods: */ … … 269 267 /** RTCRITSECT object to protect frame-buffer access. */ 270 268 mutable RTCRITSECT m_critSect; 271 272 #ifdef Q_OS_WIN273 /** Windows: Holds the reference counter. */274 long m_iRefCnt;275 #endif /* Q_OS_WIN */276 269 277 270 /** @name Scaled mode related variables. … … 306 299 double m_dBackingScaleFactor; 307 300 /** @} */ 301 302 private: 303 304 #ifdef Q_OS_WIN 305 CComPtr <IUnknown> m_pUnkMarshaler; 306 #endif /* Q_OS_WIN */ 308 307 }; 309 308 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r51666 r52086 379 379 LogRelFlow(("UIMachineView::prepareFrameBuffer: Start EMT callbacks accepting for screen: %d.\n", screenId())); 380 380 pFrameBuffer->setMarkAsUnused(false); 381 uisession()->setFrameBuffer(screenId(), pFrameBuffer);381 m_pFrameBuffer = pFrameBuffer; 382 382 } 383 383 else … … 386 386 if (m_fAccelerate2DVideo) 387 387 { 388 /** these two additional template args is a workaround to389 * this [VBox|UI] duplication390 * @todo: they are to be removed once VBox stuff is gone */391 pFrameBuffer = new VBoxOverlayFrameBuffer<UIFrameBuffer, UIMachineView>(this, &session(), (uint32_t)screenId());388 ComObjPtr<VBoxOverlayFrameBuffer> pOFB; 389 pOFB.createObject(); 390 pOFB->init(this, &session(), (uint32_t)screenId()); 391 m_pFrameBuffer = pOFB; 392 392 } 393 393 else 394 pFrameBuffer = new UIFrameBuffer(this); 394 { 395 m_pFrameBuffer.createObject(); 396 m_pFrameBuffer->init(this); 397 } 395 398 # else /* VBOX_WITH_VIDEOHWACCEL */ 396 pFrameBuffer = new UIFrameBuffer(this); 399 m_pFrameBuffer.createObject(); 400 m_pFrameBuffer->init(this); 397 401 # endif /* !VBOX_WITH_VIDEOHWACCEL */ 398 pFrameBuffer->setHiDPIOptimizationType(uisession()->hiDPIOptimizationType());399 uisession()->setFrameBuffer(screenId(), pFrameBuffer); 400 }401 m_pFrameBuffer = pFrameBuffer;402 m_pFrameBuffer->setHiDPIOptimizationType(uisession()->hiDPIOptimizationType()); 403 404 uisession()->setFrameBuffer(screenId(), m_pFrameBuffer); 405 } 402 406 403 407 /* If frame-buffer was prepared: */ … … 407 411 CDisplay display = session().GetConsole().GetDisplay(); 408 412 Assert(!display.isNull()); 409 CFramebuffer fb(NULL); 410 /* Check if the framebuffer is already assigned; 411 * in this case we do not need to re-assign it neither do we need to AddRef. */ 412 fb = display.QueryFramebuffer(m_uScreenId); 413 if (fb.raw() != m_pFrameBuffer) /* <-this will evaluate to true iff no framebuffer is yet assigned */ 414 { 415 m_pFrameBuffer->AddRef(); 416 } 413 CFramebuffer fb = display.QueryFramebuffer(m_uScreenId); 417 414 /* Always perform AttachFramebuffer to ensure 3D gets notified: */ 418 415 if (!fb.isNull()) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r51558 r52086 226 226 UIMachineWindow *m_pMachineWindow; 227 227 ulong m_uScreenId; 228 UIFrameBuffer *m_pFrameBuffer;228 ComObjPtr<UIFrameBuffer> m_pFrameBuffer; 229 229 KMachineState m_previousState; 230 230 /** HACK: when switching out of fullscreen or seamless we wish to override … … 260 260 friend class UIMachineLogic; 261 261 friend class UIFrameBuffer; 262 template<class, class>friend class VBoxOverlayFrameBuffer;262 friend class VBoxOverlayFrameBuffer; 263 263 }; 264 264 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r51811 r52086 1207 1207 display.DetachFramebuffer(i); 1208 1208 /* Release framebuffer reference: */ 1209 pFb->Release();1209 m_frameBufferVector[i].setNull(); 1210 1210 } 1211 1211 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r52014 r52086 359 359 360 360 /* Frame-buffers vector: */ 361 QVector< UIFrameBuffer*> m_frameBufferVector;361 QVector<ComObjPtr<UIFrameBuffer>> m_frameBufferVector; 362 362 363 363 /* Common variables: */
Note:
See TracChangeset
for help on using the changeset viewer.