Changeset 54590 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Mar 2, 2015 7:09:13 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r54463 r54590 491 491 src/medium/UIMediumManager.cpp \ 492 492 src/runtime/UIActionPoolRuntime.cpp \ 493 src/runtime/UIFrameBuffer.cpp \ 493 494 src/runtime/UIIndicatorsPool.cpp \ 494 495 src/runtime/UIStatusBarEditorWindow.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.h
r54105 r54590 1839 1839 }; 1840 1840 1841 class VBoxOverlayFrameBuffer : public UIFrameBuffer1842 {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 1951 1841 #endif 1952 1842 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r54589 r54590 5 5 6 6 /* 7 * Copyright (C) 2010-201 4Oracle Corporation7 * Copyright (C) 2010-2015 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 21 /* Qt includes: */ 22 # include <QImage> 23 # include <QRegion> 22 24 # include <QPainter> 25 # include <QTransform> 23 26 /* GUI includes: */ 24 27 # include "UIFrameBuffer.h" … … 33 36 # include "UIMachineWindow.h" 34 37 # endif /* VBOX_WITH_MASKED_SEAMLESS */ 38 # ifdef VBOX_WITH_VIDEOHWACCEL 39 # include "VBoxFBOverlay.h" 40 # endif /* VBOX_WITH_VIDEOHWACCEL */ 35 41 /* COM includes: */ 36 42 # include "CConsole.h" 37 43 # include "CDisplay.h" 38 44 # include "CFramebuffer.h" 45 # include "CDisplaySourceBitmap.h" 39 46 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 40 47 41 48 /* Other VBox includes: */ 49 #include <iprt/critsect.h> 42 50 #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. */ 60 class ATL_NO_VTABLE UIFrameBufferPrivate : public QObject, 61 public CComObjectRootEx<CComMultiThreadModel>, 62 VBOX_SCRIPTABLE_IMPL(IFramebuffer) 63 { 64 Q_OBJECT; 65 66 signals: 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 77 public: 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 ®ion); 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 265 protected: 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 371 private: 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. */ 382 class VBoxOverlayFrameBuffer : public UIFrameBufferPrivate 383 { 384 Q_OBJECT; 385 386 public: 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 490 private: 491 492 VBoxQGLOverlay mOverlay; 493 UIMachineView *mpView; 494 }; 495 #endif /* VBOX_WITH_VIDEOHWACCEL */ 43 496 44 497 … … 47 500 static CComModule _Module; 48 501 #else /* !Q_WS_WIN */ 49 NS_DECL_CLASSINFO(UIFrameBuffer )50 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(UIFrameBuffer , IFramebuffer)502 NS_DECL_CLASSINFO(UIFrameBufferPrivate) 503 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(UIFrameBufferPrivate, IFramebuffer) 51 504 #endif /* !Q_WS_WIN */ 52 505 53 #ifdef Q_WS_X11 54 # include <QX11Info> 55 # include <X11/Xlib.h> 56 #endif /* Q_WS_X11 */ 57 58 UIFrameBuffer::UIFrameBuffer() 506 507 UIFrameBufferPrivate::UIFrameBufferPrivate() 59 508 : m_uScreenId(0) 60 509 , m_iWidth(0), m_iHeight(0) … … 74 523 } 75 524 76 HRESULT UIFrameBuffer ::init(UIMachineView *pMachineView)77 { 78 LogRel2(("UIFrameBuffer ::init %p\n", this));525 HRESULT UIFrameBufferPrivate::init(UIMachineView *pMachineView) 526 { 527 LogRel2(("UIFrameBufferPrivate::init %p\n", this)); 79 528 80 529 /* Assign mahine-view: */ … … 108 557 } 109 558 110 UIFrameBuffer ::~UIFrameBuffer()111 { 112 LogRel2(("UIFrameBuffer ::~UIFrameBuffer%p\n", this));559 UIFrameBufferPrivate::~UIFrameBufferPrivate() 560 { 561 LogRel2(("UIFrameBufferPrivate::~UIFrameBufferPrivate %p\n", this)); 113 562 114 563 /* Disconnect handlers: */ … … 120 569 } 121 570 122 void UIFrameBuffer ::setView(UIMachineView *pMachineView)571 void UIFrameBufferPrivate::setView(UIMachineView *pMachineView) 123 572 { 124 573 /* Disconnect old handlers: */ … … 141 590 } 142 591 143 void UIFrameBuffer ::attach()592 void UIFrameBufferPrivate::attach() 144 593 { 145 594 display().AttachFramebuffer(m_uScreenId, CFramebuffer(this)); 146 595 } 147 596 148 void UIFrameBuffer ::detach()597 void UIFrameBufferPrivate::detach() 149 598 { 150 599 CFramebuffer frameBuffer = display().QueryFramebuffer(m_uScreenId); … … 153 602 } 154 603 155 UIVisualStateType UIFrameBuffer::visualState() const 156 { 157 return m_pMachineView ? m_pMachineView->visualStateType() : UIVisualStateType_Invalid; 158 } 159 160 void UIFrameBuffer::setMarkAsUnused(bool fUnused) 604 void UIFrameBufferPrivate::setMarkAsUnused(bool fUnused) 161 605 { 162 606 lock(); … … 165 609 } 166 610 167 HRESULT UIFrameBuffer ::FinalConstruct()611 HRESULT UIFrameBufferPrivate::FinalConstruct() 168 612 { 169 613 return 0; 170 614 } 171 615 172 void UIFrameBuffer ::FinalRelease()616 void UIFrameBufferPrivate::FinalRelease() 173 617 { 174 618 return; 175 619 } 176 620 177 STDMETHODIMP UIFrameBuffer ::COMGETTER(Width)(ULONG *puWidth)621 STDMETHODIMP UIFrameBufferPrivate::COMGETTER(Width)(ULONG *puWidth) 178 622 { 179 623 if (!puWidth) … … 183 627 } 184 628 185 STDMETHODIMP UIFrameBuffer ::COMGETTER(Height)(ULONG *puHeight)629 STDMETHODIMP UIFrameBufferPrivate::COMGETTER(Height)(ULONG *puHeight) 186 630 { 187 631 if (!puHeight) … … 191 635 } 192 636 193 STDMETHODIMP UIFrameBuffer ::COMGETTER(BitsPerPixel)(ULONG *puBitsPerPixel)637 STDMETHODIMP UIFrameBufferPrivate::COMGETTER(BitsPerPixel)(ULONG *puBitsPerPixel) 194 638 { 195 639 if (!puBitsPerPixel) … … 199 643 } 200 644 201 STDMETHODIMP UIFrameBuffer ::COMGETTER(BytesPerLine)(ULONG *puBytesPerLine)645 STDMETHODIMP UIFrameBufferPrivate::COMGETTER(BytesPerLine)(ULONG *puBytesPerLine) 202 646 { 203 647 if (!puBytesPerLine) … … 207 651 } 208 652 209 STDMETHODIMP UIFrameBuffer ::COMGETTER(PixelFormat)(ULONG *puPixelFormat)653 STDMETHODIMP UIFrameBufferPrivate::COMGETTER(PixelFormat)(ULONG *puPixelFormat) 210 654 { 211 655 if (!puPixelFormat) … … 215 659 } 216 660 217 STDMETHODIMP UIFrameBuffer ::COMGETTER(HeightReduction)(ULONG *puHeightReduction)661 STDMETHODIMP UIFrameBufferPrivate::COMGETTER(HeightReduction)(ULONG *puHeightReduction) 218 662 { 219 663 if (!puHeightReduction) … … 223 667 } 224 668 225 STDMETHODIMP UIFrameBuffer ::COMGETTER(Overlay)(IFramebufferOverlay **ppOverlay)669 STDMETHODIMP UIFrameBufferPrivate::COMGETTER(Overlay)(IFramebufferOverlay **ppOverlay) 226 670 { 227 671 if (!ppOverlay) … … 231 675 } 232 676 233 STDMETHODIMP UIFrameBuffer ::COMGETTER(WinId)(LONG64 *pWinId)677 STDMETHODIMP UIFrameBufferPrivate::COMGETTER(WinId)(LONG64 *pWinId) 234 678 { 235 679 if (!pWinId) … … 239 683 } 240 684 241 STDMETHODIMP UIFrameBuffer ::COMGETTER(Capabilities)(ComSafeArrayOut(FramebufferCapabilities_T, enmCapabilities))685 STDMETHODIMP UIFrameBufferPrivate::COMGETTER(Capabilities)(ComSafeArrayOut(FramebufferCapabilities_T, enmCapabilities)) 242 686 { 243 687 if (ComSafeArrayOutIsNull(enmCapabilities)) … … 261 705 } 262 706 263 STDMETHODIMP UIFrameBuffer ::NotifyChange(ULONG uScreenId, ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight)707 STDMETHODIMP UIFrameBufferPrivate::NotifyChange(ULONG uScreenId, ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight) 264 708 { 265 709 CDisplaySourceBitmap sourceBitmap; … … 273 717 if (m_fUnused) 274 718 { 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", 276 720 (unsigned long)uScreenId, 277 721 (unsigned long)uX, (unsigned long)uY, … … 300 744 /* Widget resize is NOT thread-safe and *probably* never will be, 301 745 * 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", 303 747 (unsigned long)uScreenId, 304 748 (unsigned long)uX, (unsigned long)uY, … … 316 760 } 317 761 318 STDMETHODIMP UIFrameBuffer ::NotifyUpdate(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight)762 STDMETHODIMP UIFrameBufferPrivate::NotifyUpdate(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight) 319 763 { 320 764 /* Lock access to frame-buffer: */ … … 324 768 if (m_fUnused) 325 769 { 326 LogRel2(("UIFrameBuffer ::NotifyUpdate: Origin=%lux%lu, Size=%lux%lu, Ignored!\n",770 LogRel2(("UIFrameBufferPrivate::NotifyUpdate: Origin=%lux%lu, Size=%lux%lu, Ignored!\n", 327 771 (unsigned long)uX, (unsigned long)uY, 328 772 (unsigned long)uWidth, (unsigned long)uHeight)); … … 337 781 /* Widget update is NOT thread-safe and *seems* never will be, 338 782 * 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", 340 784 (unsigned long)uX, (unsigned long)uY, 341 785 (unsigned long)uWidth, (unsigned long)uHeight)); … … 349 793 } 350 794 351 STDMETHODIMP UIFrameBuffer ::NotifyUpdateImage(ULONG uX, ULONG uY,352 ULONG uWidth, ULONG uHeight,353 ComSafeArrayIn(BYTE, image))795 STDMETHODIMP UIFrameBufferPrivate::NotifyUpdateImage(ULONG uX, ULONG uY, 796 ULONG uWidth, ULONG uHeight, 797 ComSafeArrayIn(BYTE, image)) 354 798 { 355 799 /* Wrapping received data: */ … … 362 806 if (m_fUnused) 363 807 { 364 LogRel2(("UIFrameBuffer ::NotifyUpdateImage: Origin=%lux%lu, Size=%lux%lu, Ignored!\n",808 LogRel2(("UIFrameBufferPrivate::NotifyUpdateImage: Origin=%lux%lu, Size=%lux%lu, Ignored!\n", 365 809 (unsigned long)uX, (unsigned long)uY, 366 810 (unsigned long)uWidth, (unsigned long)uHeight)); … … 389 833 /* Widget update is NOT thread-safe and *seems* never will be, 390 834 * 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", 392 836 (unsigned long)uX, (unsigned long)uY, 393 837 (unsigned long)uWidth, (unsigned long)uHeight)); … … 402 846 } 403 847 404 STDMETHODIMP UIFrameBuffer ::VideoModeSupported(ULONG uWidth, ULONG uHeight, ULONG uBPP, BOOL *pfSupported)848 STDMETHODIMP UIFrameBufferPrivate::VideoModeSupported(ULONG uWidth, ULONG uHeight, ULONG uBPP, BOOL *pfSupported) 405 849 { 406 850 /* Make sure result pointer is valid: */ 407 851 if (!pfSupported) 408 852 { 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", 410 854 (unsigned long)uBPP, (unsigned long)uWidth, (unsigned long)uHeight)); 411 855 … … 419 863 if (m_fUnused) 420 864 { 421 LogRel2(("UIFrameBuffer ::IsVideoModeSupported: Mode: BPP=%lu, Size=%lux%lu, Ignored!\n",865 LogRel2(("UIFrameBufferPrivate::IsVideoModeSupported: Mode: BPP=%lu, Size=%lux%lu, Ignored!\n", 422 866 (unsigned long)uBPP, (unsigned long)uWidth, (unsigned long)uHeight)); 423 867 … … 440 884 && (uHeight > (ULONG)height())) 441 885 *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", 443 887 (unsigned long)uBPP, (unsigned long)uWidth, (unsigned long)uHeight, *pfSupported ? "TRUE" : "FALSE")); 444 888 … … 450 894 } 451 895 452 STDMETHODIMP UIFrameBuffer ::GetVisibleRegion(BYTE *pRectangles, ULONG uCount, ULONG *puCountCopied)896 STDMETHODIMP UIFrameBufferPrivate::GetVisibleRegion(BYTE *pRectangles, ULONG uCount, ULONG *puCountCopied) 453 897 { 454 898 PRTRECT rects = (PRTRECT)pRectangles; … … 463 907 } 464 908 465 STDMETHODIMP UIFrameBuffer ::SetVisibleRegion(BYTE *pRectangles, ULONG uCount)909 STDMETHODIMP UIFrameBufferPrivate::SetVisibleRegion(BYTE *pRectangles, ULONG uCount) 466 910 { 467 911 /* Make sure rectangles were passed: */ 468 912 if (!pRectangles) 469 913 { 470 LogRel2(("UIFrameBuffer ::SetVisibleRegion: Rectangle count=%lu, Invalid pRectangles pointer!\n",914 LogRel2(("UIFrameBufferPrivate::SetVisibleRegion: Rectangle count=%lu, Invalid pRectangles pointer!\n", 471 915 (unsigned long)uCount)); 472 916 … … 480 924 if (m_fUnused) 481 925 { 482 LogRel2(("UIFrameBuffer ::SetVisibleRegion: Rectangle count=%lu, Ignored!\n",926 LogRel2(("UIFrameBufferPrivate::SetVisibleRegion: Rectangle count=%lu, Ignored!\n", 483 927 (unsigned long)uCount)); 484 928 … … 515 959 m_syncVisibleRegion = region; 516 960 /* 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", 518 962 (unsigned long)uCount)); 519 963 emit sigSetVisibleRegion(region); … … 523 967 /* Save the region. */ 524 968 m_pendingSyncVisibleRegion = region; 525 LogRel2(("UIFrameBuffer ::SetVisibleRegion: Rectangle count=%lu, Saved\n",969 LogRel2(("UIFrameBufferPrivate::SetVisibleRegion: Rectangle count=%lu, Saved\n", 526 970 (unsigned long)uCount)); 527 971 } … … 534 978 } 535 979 536 STDMETHODIMP UIFrameBuffer ::ProcessVHWACommand(BYTE *pCommand)980 STDMETHODIMP UIFrameBufferPrivate::ProcessVHWACommand(BYTE *pCommand) 537 981 { 538 982 Q_UNUSED(pCommand); … … 540 984 } 541 985 542 STDMETHODIMP UIFrameBuffer ::Notify3DEvent(ULONG uType, ComSafeArrayIn(BYTE, data))986 STDMETHODIMP UIFrameBufferPrivate::Notify3DEvent(ULONG uType, ComSafeArrayIn(BYTE, data)) 543 987 { 544 988 /* Lock access to frame-buffer: */ … … 548 992 if (m_fUnused) 549 993 { 550 LogRel2(("UIFrameBuffer ::Notify3DEvent: Ignored!\n"));994 LogRel2(("UIFrameBufferPrivate::Notify3DEvent: Ignored!\n")); 551 995 552 996 /* Unlock access to frame-buffer: */ … … 565 1009 * about 3D overlay visibility change: */ 566 1010 BOOL fVisible = eventData[0]; 567 LogRel2(("UIFrameBuffer ::Notify3DEvent: Sending to async-handler: "1011 LogRel2(("UIFrameBufferPrivate::Notify3DEvent: Sending to async-handler: " 568 1012 "(VBOX3D_NOTIFY_EVENT_TYPE_VISIBLE_3DDATA = %s)\n", 569 1013 fVisible ? "TRUE" : "FALSE")); … … 595 1039 } 596 1040 597 void UIFrameBuffer ::handleNotifyChange(int iWidth, int iHeight)598 { 599 LogRel(("UIFrameBuffer ::handleNotifyChange: Size=%dx%d\n", iWidth, iHeight));1041 void UIFrameBufferPrivate::handleNotifyChange(int iWidth, int iHeight) 1042 { 1043 LogRel(("UIFrameBufferPrivate::handleNotifyChange: Size=%dx%d\n", iWidth, iHeight)); 600 1044 601 1045 /* Make sure machine-view is assigned: */ … … 609 1053 { 610 1054 /* Do nothing, change-event already processed: */ 611 LogRel2(("UIFrameBuffer ::handleNotifyChange: Already processed.\n"));1055 LogRel2(("UIFrameBufferPrivate::handleNotifyChange: Already processed.\n")); 612 1056 /* Unlock access to frame-buffer: */ 613 1057 unlock(); … … 628 1072 } 629 1073 630 void UIFrameBuffer ::handlePaintEvent(QPaintEvent *pEvent)631 { 632 LogRel2(("UIFrameBuffer ::handlePaintEvent: Origin=%lux%lu, Size=%dx%d\n",1074 void UIFrameBufferPrivate::handlePaintEvent(QPaintEvent *pEvent) 1075 { 1076 LogRel2(("UIFrameBufferPrivate::handlePaintEvent: Origin=%lux%lu, Size=%dx%d\n", 633 1077 pEvent->rect().x(), pEvent->rect().y(), 634 1078 pEvent->rect().width(), pEvent->rect().height())); … … 667 1111 } 668 1112 669 void UIFrameBuffer ::handleSetVisibleRegion(const QRegion ®ion)1113 void UIFrameBufferPrivate::handleSetVisibleRegion(const QRegion ®ion) 670 1114 { 671 1115 /* Make sure async visible-region has changed: */ … … 687 1131 } 688 1132 689 void UIFrameBuffer ::performResize(int iWidth, int iHeight)690 { 691 LogRel(("UIFrameBuffer ::performResize: Size=%dx%d\n", iWidth, iHeight));1133 void UIFrameBufferPrivate::performResize(int iWidth, int iHeight) 1134 { 1135 LogRel(("UIFrameBufferPrivate::performResize: Size=%dx%d\n", iWidth, iHeight)); 692 1136 693 1137 /* Make sure machine-view is assigned: */ … … 707 1151 if (m_sourceBitmap.isNull()) 708 1152 { 709 LogRel(("UIFrameBuffer ::performResize: "1153 LogRel(("UIFrameBufferPrivate::performResize: " 710 1154 "Using FALLBACK buffer due to source-bitmap is not provided..\n")); 711 1155 … … 721 1165 else 722 1166 { 723 LogRel(("UIFrameBuffer ::performResize: "1167 LogRel(("UIFrameBufferPrivate::performResize: " 724 1168 "Directly using source-bitmap content\n")); 725 1169 … … 777 1221 778 1222 /* 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", 780 1224 (unsigned long)m_syncVisibleRegion.rectCount())); 781 1225 emit sigSetVisibleRegion(m_syncVisibleRegion); … … 785 1229 } 786 1230 787 void UIFrameBuffer ::performRescale()788 { 789 // printf("UIFrameBuffer ::performRescale\n");1231 void UIFrameBufferPrivate::performRescale() 1232 { 1233 // printf("UIFrameBufferPrivate::performRescale\n"); 790 1234 791 1235 /* Make sure machine-view is assigned: */ … … 806 1250 updateCoordinateSystem(); 807 1251 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", 809 1253 // scaleFactor(), scaledSize().width(), scaledSize().height()); 810 1254 } 811 1255 812 void UIFrameBuffer ::prepareConnections()1256 void UIFrameBufferPrivate::prepareConnections() 813 1257 { 814 1258 /* Attach EMT connections: */ … … 827 1271 } 828 1272 829 void UIFrameBuffer ::cleanupConnections()1273 void UIFrameBufferPrivate::cleanupConnections() 830 1274 { 831 1275 /* Detach EMT connections: */ … … 840 1284 } 841 1285 842 void UIFrameBuffer ::updateCoordinateSystem()1286 void UIFrameBufferPrivate::updateCoordinateSystem() 843 1287 { 844 1288 /* Reset to default: */ … … 854 1298 } 855 1299 856 void UIFrameBuffer ::paintDefault(QPaintEvent *pEvent)1300 void UIFrameBufferPrivate::paintDefault(QPaintEvent *pEvent) 857 1301 { 858 1302 /* Scaled image is NULL by default: */ … … 894 1338 } 895 1339 896 void UIFrameBuffer ::paintSeamless(QPaintEvent *pEvent)1340 void UIFrameBufferPrivate::paintSeamless(QPaintEvent *pEvent) 897 1341 { 898 1342 /* Scaled image is NULL by default: */ … … 961 1405 962 1406 /* static */ 963 void UIFrameBuffer ::eraseImageRect(QPainter &painter, const QRect &rect,964 bool fUseUnscaledHiDPIOutput,965 HiDPIOptimizationType hiDPIOptimizationType,966 double dBackingScaleFactor)1407 void UIFrameBufferPrivate::eraseImageRect(QPainter &painter, const QRect &rect, 1408 bool fUseUnscaledHiDPIOutput, 1409 HiDPIOptimizationType hiDPIOptimizationType, 1410 double dBackingScaleFactor) 967 1411 { 968 1412 /* Prepare sub-pixmap: */ … … 1007 1451 1008 1452 /* 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)1453 void UIFrameBufferPrivate::drawImageRect(QPainter &painter, const QImage &image, const QRect &rect, 1454 int iContentsShiftX, int iContentsShiftY, 1455 bool fUseUnscaledHiDPIOutput, 1456 HiDPIOptimizationType hiDPIOptimizationType, 1457 double dBackingScaleFactor) 1014 1458 { 1015 1459 /* Calculate offset: */ … … 1066 1510 } 1067 1511 1512 1513 #ifdef VBOX_WITH_VIDEOHWACCEL 1514 UIFrameBuffer::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 */ 1528 UIFrameBuffer::UIFrameBuffer() 1529 { 1530 m_pFrameBuffer.createObject(); 1531 } 1532 #endif /* !VBOX_WITH_VIDEOHWACCEL */ 1533 1534 UIFrameBuffer::~UIFrameBuffer() 1535 { 1536 m_pFrameBuffer.setNull(); 1537 } 1538 1539 HRESULT UIFrameBuffer::init(UIMachineView *pMachineView) 1540 { 1541 return m_pFrameBuffer->init(pMachineView); 1542 } 1543 1544 void UIFrameBuffer::attach() 1545 { 1546 m_pFrameBuffer->attach(); 1547 } 1548 1549 void UIFrameBuffer::detach() 1550 { 1551 m_pFrameBuffer->detach(); 1552 } 1553 1554 uchar* UIFrameBuffer::address() 1555 { 1556 return m_pFrameBuffer->address(); 1557 } 1558 1559 ulong UIFrameBuffer::width() const 1560 { 1561 return m_pFrameBuffer->width(); 1562 } 1563 1564 ulong UIFrameBuffer::height() const 1565 { 1566 return m_pFrameBuffer->height(); 1567 } 1568 1569 ulong UIFrameBuffer::bitsPerPixel() const 1570 { 1571 return m_pFrameBuffer->bitsPerPixel(); 1572 } 1573 1574 ulong UIFrameBuffer::bytesPerLine() const 1575 { 1576 return m_pFrameBuffer->bytesPerLine(); 1577 } 1578 1579 UIVisualStateType UIFrameBuffer::visualState() const 1580 { 1581 return m_pFrameBuffer->visualState(); 1582 } 1583 1584 void UIFrameBuffer::setView(UIMachineView *pMachineView) 1585 { 1586 m_pFrameBuffer->setView(pMachineView); 1587 } 1588 1589 void UIFrameBuffer::setMarkAsUnused(bool fUnused) 1590 { 1591 m_pFrameBuffer->setMarkAsUnused(fUnused); 1592 } 1593 1594 bool UIFrameBuffer::isAutoEnabled() const 1595 { 1596 return m_pFrameBuffer->isAutoEnabled(); 1597 } 1598 1599 void UIFrameBuffer::setAutoEnabled(bool fAutoEnabled) 1600 { 1601 m_pFrameBuffer->setAutoEnabled(fAutoEnabled); 1602 } 1603 1604 QSize UIFrameBuffer::scaledSize() const 1605 { 1606 return m_pFrameBuffer->scaledSize(); 1607 } 1608 1609 void UIFrameBuffer::setScaledSize(const QSize &size /* = QSize() */) 1610 { 1611 m_pFrameBuffer->setScaledSize(size); 1612 } 1613 1614 int UIFrameBuffer::convertHostXTo(int iX) const 1615 { 1616 return m_pFrameBuffer->convertHostXTo(iX); 1617 } 1618 1619 int UIFrameBuffer::convertHostYTo(int iY) const 1620 { 1621 return m_pFrameBuffer->convertHostXTo(iY); 1622 } 1623 1624 double UIFrameBuffer::scaleFactor() const 1625 { 1626 return m_pFrameBuffer->scaleFactor(); 1627 } 1628 1629 void UIFrameBuffer::setScaleFactor(double dScaleFactor) 1630 { 1631 m_pFrameBuffer->setScaleFactor(dScaleFactor); 1632 } 1633 1634 double UIFrameBuffer::backingScaleFactor() const 1635 { 1636 return m_pFrameBuffer->backingScaleFactor(); 1637 } 1638 1639 void UIFrameBuffer::setBackingScaleFactor(double dBackingScaleFactor) 1640 { 1641 m_pFrameBuffer->setBackingScaleFactor(dBackingScaleFactor); 1642 } 1643 1644 bool UIFrameBuffer::useUnscaledHiDPIOutput() const 1645 { 1646 return m_pFrameBuffer->useUnscaledHiDPIOutput(); 1647 } 1648 1649 void UIFrameBuffer::setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput) 1650 { 1651 m_pFrameBuffer->setUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput); 1652 } 1653 1654 HiDPIOptimizationType UIFrameBuffer::hiDPIOptimizationType() const 1655 { 1656 return m_pFrameBuffer->hiDPIOptimizationType(); 1657 } 1658 1659 void UIFrameBuffer::setHiDPIOptimizationType(HiDPIOptimizationType optimizationType) 1660 { 1661 m_pFrameBuffer->setHiDPIOptimizationType(optimizationType); 1662 } 1663 1664 void UIFrameBuffer::handleNotifyChange(int iWidth, int iHeight) 1665 { 1666 m_pFrameBuffer->handleNotifyChange(iWidth, iHeight); 1667 } 1668 1669 void UIFrameBuffer::handlePaintEvent(QPaintEvent *pEvent) 1670 { 1671 m_pFrameBuffer->handlePaintEvent(pEvent); 1672 } 1673 1674 void UIFrameBuffer::handleSetVisibleRegion(const QRegion ®ion) 1675 { 1676 m_pFrameBuffer->handleSetVisibleRegion(region); 1677 } 1678 1679 void UIFrameBuffer::performResize(int iWidth, int iHeight) 1680 { 1681 m_pFrameBuffer->performResize(iWidth, iHeight); 1682 } 1683 1684 void UIFrameBuffer::performRescale() 1685 { 1686 m_pFrameBuffer->performRescale(); 1687 } 1688 1689 #ifdef VBOX_WITH_VIDEOHWACCEL 1690 void UIFrameBuffer::doProcessVHWACommand(QEvent *pEvent) 1691 { 1692 m_pFrameBuffer->doProcessVHWACommand(pEvent); 1693 } 1694 1695 void UIFrameBuffer::viewportResized(QResizeEvent *pEvent) 1696 { 1697 m_pFrameBuffer->viewportResized(pEvent); 1698 } 1699 1700 void 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 4 4 5 5 /* 6 * Copyright (C) 2010-201 4Oracle Corporation6 * Copyright (C) 2010-2015 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 20 20 /* Qt includes: */ 21 #include <QRegion> 22 #include <QImage> 23 #include <QTransform> 21 #include <QSize> 24 22 25 23 /* GUI includes: */ 26 #include "UIDefs.h"27 24 #include "UIExtraDataDefs.h" 28 25 29 /* COM includes: */30 #include "CDisplay.h"31 #include "CDisplaySourceBitmap.h"32 33 26 /* Other VBox includes: */ 34 #include < iprt/critsect.h>27 #include <VBox/com/ptr.h> 35 28 36 29 /* Forward declarations: */ 30 class UIFrameBufferPrivate; 31 class UIMachineView; 37 32 class QResizeEvent; 38 33 class QPaintEvent; 39 class UIMachineView;34 class QRegion; 40 35 41 36 /** 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) 37 class UIFrameBuffer : public QObject 45 38 { 46 39 Q_OBJECT; 47 40 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 59 41 public: 60 42 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 */ 61 49 /** Frame-buffer constructor. */ 62 50 UIFrameBuffer(); 51 #endif /* !VBOX_WITH_VIDEOHWACCEL */ 52 63 53 /** Frame-buffer destructor. */ 64 54 ~UIFrameBuffer(); … … 66 56 /** Frame-buffer initialization. 67 57 * @param pMachineView defines machine-view this frame-buffer is bounded to. */ 68 virtualHRESULT init(UIMachineView *pMachineView);58 HRESULT init(UIMachineView *pMachineView); 69 59 70 60 /** Assigns machine-view frame-buffer will be bounded to. 71 61 * @param pMachineView defines machine-view this frame-buffer is bounded to. */ 72 v irtual void setView(UIMachineView *pMachineView);62 void setView(UIMachineView *pMachineView); 73 63 74 /** Returns the copy of the IDisplay wrapper. */75 CDisplay display() const { return m_display; }76 64 /** Attach frame-buffer to the Display. */ 77 65 void attach(); … … 80 68 81 69 /** Returns frame-buffer data address. */ 82 uchar *address() { return m_image.bits(); }70 uchar* address(); 83 71 /** Returns frame-buffer width. */ 84 ulong width() const { return m_iWidth; }72 ulong width() const; 85 73 /** Returns frame-buffer height. */ 86 ulong height() const { return m_iHeight; }74 ulong height() const; 87 75 /** Returns frame-buffer bits-per-pixel value. */ 88 ulong bitsPerPixel() const { return m_image.depth(); }76 ulong bitsPerPixel() const; 89 77 /** 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; 93 79 /** Returns the visual-state this frame-buffer is used for. */ 94 80 UIVisualStateType visualState() const; 95 81 96 82 /** Defines whether frame-buffer is <b>unused</b>. 97 * @note Refer to m_fUnused for more information.98 83 * @note Calls to this and any other EMT callback are synchronized (from GUI side). */ 99 84 void setMarkAsUnused(bool fUnused); … … 101 86 /** Returns whether frame-buffer is <b>auto-enabled</b>. 102 87 * @note Refer to m_fAutoEnabled for more information. */ 103 bool isAutoEnabled() const { return m_fAutoEnabled; }88 bool isAutoEnabled() const; 104 89 /** Defines whether frame-buffer is <b>auto-enabled</b>. 105 90 * @note Refer to m_fAutoEnabled for more information. */ 106 void setAutoEnabled(bool fAutoEnabled) { m_fAutoEnabled = fAutoEnabled; }91 void setAutoEnabled(bool fAutoEnabled); 107 92 108 93 /** Returns the frame-buffer's scaled-size. */ 109 QSize scaledSize() const { return m_scaledSize; }94 QSize scaledSize() const; 110 95 /** 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()); 116 97 /** Returns x-origin of the guest (actual) content corresponding to x-origin of host (scaled) content. */ 117 in line int convertHostXTo(int x) const { return m_scaledSize.isValid() ? qRound((double)m_iWidth / m_scaledSize.width() * x) : x; }98 int convertHostXTo(int iX) const; 118 99 /** Returns y-origin of the guest (actual) content corresponding to y-origin of host (scaled) content. */ 119 in line int convertHostYTo(int y) const { return m_scaledSize.isValid() ? qRound((double)m_iHeight / m_scaledSize.height() * y) : y; }100 int convertHostYTo(int iY) const; 120 101 121 102 /** Returns the scale-factor used by the frame-buffer. */ 122 double scaleFactor() const { return m_dScaleFactor; }103 double scaleFactor() const; 123 104 /** Define the scale-factor used by the frame-buffer. */ 124 void setScaleFactor(double dScaleFactor) { m_dScaleFactor = dScaleFactor; }105 void setScaleFactor(double dScaleFactor); 125 106 126 107 /** Returns backing-scale-factor used by HiDPI frame-buffer. */ 127 double backingScaleFactor() const { return m_dBackingScaleFactor; }108 double backingScaleFactor() const; 128 109 /** Defines backing-scale-factor used by HiDPI frame-buffer. */ 129 void setBackingScaleFactor(double dBackingScaleFactor) { m_dBackingScaleFactor = dBackingScaleFactor; }110 void setBackingScaleFactor(double dBackingScaleFactor); 130 111 131 112 /** Returns whether frame-buffer should use unscaled HiDPI output. */ 132 bool useUnscaledHiDPIOutput() const { return m_fUseUnscaledHiDPIOutput; }113 bool useUnscaledHiDPIOutput() const; 133 114 /** Defines whether frame-buffer should use unscaled HiDPI output. */ 134 void setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput) { m_fUseUnscaledHiDPIOutput = fUseUnscaledHiDPIOutput; }115 void setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput); 135 116 136 117 /** Return HiDPI frame-buffer optimization type. */ 137 HiDPIOptimizationType hiDPIOptimizationType() const { return m_hiDPIOptimizationType; }118 HiDPIOptimizationType hiDPIOptimizationType() const; 138 119 /** 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); 226 121 227 122 /** Handles frame-buffer notify-change-event. */ 228 v irtual void handleNotifyChange(int iWidth, int iHeight);123 void handleNotifyChange(int iWidth, int iHeight); 229 124 /** Handles frame-buffer paint-event. */ 230 v irtual void handlePaintEvent(QPaintEvent *pEvent);125 void handlePaintEvent(QPaintEvent *pEvent); 231 126 /** Handles frame-buffer set-visible-region-event. */ 232 v irtual void handleSetVisibleRegion(const QRegion ®ion);127 void handleSetVisibleRegion(const QRegion ®ion); 233 128 234 129 /** Performs frame-buffer resizing. */ 235 v irtual void performResize(int iWidth, int iHeight);130 void performResize(int iWidth, int iHeight); 236 131 /** Performs frame-buffer rescaling. */ 237 v irtual void performRescale();132 void performRescale(); 238 133 239 134 #ifdef VBOX_WITH_VIDEOHWACCEL 240 135 /** Performs Video HW Acceleration command. */ 241 v irtual void doProcessVHWACommand(QEvent* /* pEvent */) {}136 void doProcessVHWACommand(QEvent *pEvent); 242 137 /** Handles viewport resize-event. */ 243 v irtual void viewportResized(QResizeEvent* /* pEvent */) {}138 void viewportResized(QResizeEvent *pEvent); 244 139 /** Handles viewport scroll-event. */ 245 v irtual void viewportScrolled(int /* iX */, int /* iY */) {}140 void viewportScrolled(int iX, int iY); 246 141 #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-buffer309 * 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 between330 * the initial visible-region arriving from EMT thread331 * and actual visible-region appliance on GUI thread332 * 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 /** @} */354 142 355 143 private: 356 144 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; 360 147 }; 361 148 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r54589 r54590 527 527 { 528 528 #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); 546 532 #else /* VBOX_WITH_VIDEOHWACCEL */ 547 /* Create new defaultframe-buffer: */548 m_pFrameBuffer .createObject();533 /* Create new frame-buffer: */ 534 m_pFrameBuffer = new UIFrameBuffer; 549 535 m_pFrameBuffer->init(this); 550 536 #endif /* !VBOX_WITH_VIDEOHWACCEL */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r54554 r54590 270 270 UIMachineWindow *m_pMachineWindow; 271 271 ulong m_uScreenId; 272 ComObjPtr<UIFrameBuffer>m_pFrameBuffer;272 UIFrameBuffer *m_pFrameBuffer; 273 273 KMachineState m_previousState; 274 274 /** HACK: when switching out of fullscreen or seamless we wish to override … … 307 307 friend class UIMachineLogic; 308 308 friend class UIFrameBuffer; 309 friend class UIFrameBufferPrivate; 309 310 friend class VBoxOverlayFrameBuffer; 310 311 }; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r54589 r54590 1420 1420 /* Detach framebuffer from Display: */ 1421 1421 pFrameBuffer->detach(); 1422 /* Release framebuffer reference: */1423 m_frameBufferVector[i].setNull();1422 /* Delete framebuffer reference: */ 1423 delete pFrameBuffer; 1424 1424 } 1425 1425 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r54577 r54590 243 243 void setFrameBuffer(ulong uScreenId, UIFrameBuffer* pFrameBuffer); 244 244 /** Returns existing frame-buffer vector. */ 245 const QVector< ComObjPtr<UIFrameBuffer>>& frameBuffers() const { return m_frameBufferVector; }245 const QVector<UIFrameBuffer*>& frameBuffers() const { return m_frameBufferVector; } 246 246 247 247 /** Updates VRDE Server action state. */ … … 419 419 420 420 /* Frame-buffers vector: */ 421 QVector< ComObjPtr<UIFrameBuffer>> m_frameBufferVector;421 QVector<UIFrameBuffer*> m_frameBufferVector; 422 422 423 423 /* Common variables: */
Note:
See TracChangeset
for help on using the changeset viewer.