Changeset 26781 in vbox
- Timestamp:
- Feb 25, 2010 11:11:32 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 58046
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r26737 r26781 490 490 src/runtime/UIIndicatorsPool.cpp \ 491 491 src/runtime/UIFrameBuffer.cpp \ 492 src/runtime/UIFrameBufferQuartz2D.cpp \ 492 493 src/runtime/UIMachine.cpp \ 493 494 src/runtime/UIMachineLogic.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h
r26709 r26781 431 431 432 432 #endif 433 #if defined (Q_WS_MAC) && defined (VBOX_GUI_USE_QUARTZ2D)434 #include <Carbon/Carbon.h>435 436 class UIFrameBufferQuartz2D : public UIFrameBuffer437 {438 public:439 440 UIFrameBufferQuartz2D(UIMachineView *pMachineView);441 virtual ~UIFrameBufferQuartz2D();442 443 STDMETHOD (NotifyUpdate) (ULONG uX, ULONG uY, ULONG uW, ULONG uH);444 STDMETHOD (SetVisibleRegion) (BYTE *pRectangles, ULONG uCount);445 446 uchar* address() { return m_pDataAddress; }447 ulong bitsPerPixel() { return CGImageGetBitsPerPixel(m_image); }448 ulong bytesPerLine() { return CGImageGetBytesPerRow(m_image); }449 ulong pixelFormat() { return m_uPixelFormat; };450 bool usesGuestVRAM() { return m_pBitmapData == NULL; }451 452 const CGImageRef imageRef() const { return m_image; }453 454 void paintEvent(QPaintEvent *pEvent);455 void resizeEvent(UIResizeEvent *pEvent);456 457 #ifndef QT_MAC_USE_COCOA458 void testAndSetSNCarbonFix();459 #endif /* QT_MAC_USE_COCOA */460 461 private:462 463 void clean();464 465 uchar *m_pDataAddress;466 void *m_pBitmapData;467 ulong m_uPixelFormat;468 CGImageRef m_image;469 typedef struct470 {471 /** The size of this structure expressed in rcts entries. */472 ULONG allocated;473 /** The number of entries in the rcts array. */474 ULONG used;475 /** Variable sized array of the rectangle that makes up the region. */476 CGRect rcts[1];477 } RegionRects;478 /** The current valid region, all access is by atomic cmpxchg or atomic xchg.479 *480 * The protocol for updating and using this has to take into account that481 * the producer (SetVisibleRegion) and consumer (paintEvent) are running482 * on different threads. Therefore the producer will create a new RegionRects483 * structure before atomically replace the existing one. While the consumer484 * will read the value by atomically replace it by NULL, and then when its485 * done try restore it by cmpxchg. If the producer has already put a new486 * region there, it will be discarded (see mRegionUnused).487 */488 RegionRects volatile *mRegion;489 /** For keeping the unused region and thus avoid some RTMemAlloc/RTMemFree calls.490 * This is operated with atomic cmpxchg and atomic xchg. */491 RegionRects volatile *mRegionUnused;492 493 #ifndef QT_MAC_USE_COCOA494 bool mSnowLeoCarbonFix;495 EventHandlerRef mDarwinSNWindowHandlerRef;496 #endif /* QT_MAC_USE_COCOA */497 };498 #endif /* Q_WS_MAC && VBOX_GUI_USE_QUARTZ2D */499 433 500 434 #endif // !___UIFrameBuffer_h___ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.cpp
r26777 r26781 1 1 /* $Id$ */ 2 2 /** @file 3 * Qt GUI (aka VirtualBox) - Quartz2D framebuffer implementation. 3 * 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * UIFrameBufferQuartz2D class implementation 4 6 */ 5 7 6 8 /* 7 * Copyright (C) 2006-20 07Sun Microsystems, Inc.9 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 10 * 9 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 25 27 # include "precomp.h" 26 28 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 29 /* Global includes */ 30 #include <QApplication> 31 27 32 #include <iprt/asm.h> 28 33 29 /* VBox includes */ 30 #include "VBoxFrameBuffer.h" 31 #include "VBoxConsoleView.h" 32 #include "VBoxProblemReporter.h" 33 #include "VBoxGlobal.h" 34 /* Local includes */ 35 #include "UIFrameBufferQuartz2D.h" 36 #include "UIMachineView.h" 34 37 #include "VBoxUtils.h" 35 /* Needed for checking against seamless mode */ 36 #include "VBoxConsoleWnd.h" 37 #include "VBoxIChatTheaterWrapper.h" 38 39 #include <QDesktopWidget> 40 41 #include "iprt/system.h" 38 39 ///* Needed for checking against seamless mode */ 40 //#include "VBoxConsoleWnd.h" 41 //#include "VBoxIChatTheaterWrapper.h" 42 42 43 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 43 44 … … 45 46 //#define OVERLAY_CLIPRECTS 46 47 47 /** @class VBoxQuartz2DFrameBuffer48 /** @class UIFrameBufferQuartz2D 48 49 * 49 * The VBoxQuartz2dFrameBufferclass is a class that implements the IFrameBuffer50 * The UIFrameBufferQuartz2D class is a class that implements the IFrameBuffer 50 51 * interface and uses Apples Quartz2D to store and render VM display data. 51 52 */ … … 57 58 && ::GetEventClass (aInEvent) == kEventClassWindow 58 59 && ::GetEventKind (aInEvent) == kEventWindowBoundsChanged) 59 static_cast< VBoxQuartz2DFrameBuffer*> (aInUserData)->testAndSetSNCarbonFix();60 static_cast<UIFrameBufferQuartz2D *> (aInUserData)->testAndSetSNCarbonFix(); 60 61 61 62 return ::CallNextEventHandler (aInHandlerCallRef, aInEvent); … … 63 64 #endif /* QT_MAC_USE_COCOA */ 64 65 65 VBoxQuartz2DFrameBuffer::VBoxQuartz2DFrameBuffer (VBoxConsoleView *aView)66 : VBoxFrameBuffer(aView)67 , m DataAddress(NULL)68 , m BitmapData(NULL)69 , m PixelFormat(FramebufferPixelFormat_FOURCC_RGB)70 , m Image(NULL)66 UIFrameBufferQuartz2D::UIFrameBufferQuartz2D(UIMachineView *pMachineView) 67 : UIFrameBuffer(pMachineView) 68 , m_pDataAddress(NULL) 69 , m_pBitmapData(NULL) 70 , m_uPixelFormat(FramebufferPixelFormat_FOURCC_RGB) 71 , m_image(NULL) 71 72 , mRegion (NULL) 72 73 , mRegionUnused (NULL) … … 97 98 { kEventClassWindow, kEventWindowBoundsChanged } 98 99 }; 99 ::InstallWindowEventHandler (::darwinToNativeWindow (m View->viewport()), darwinSNWindowHandler, RT_ELEMENTS (eventTypes), &eventTypes[0],100 ::InstallWindowEventHandler (::darwinToNativeWindow (m_pMachineView->viewport()), darwinSNWindowHandler, RT_ELEMENTS (eventTypes), &eventTypes[0], 100 101 this, &mDarwinSNWindowHandlerRef); 101 102 /* Initialize it now */ … … 104 105 #endif /* QT_MAC_USE_COCOA */ 105 106 106 VBoxResizeEvent event(FramebufferPixelFormat_Opaque,107 107 UIResizeEvent event(FramebufferPixelFormat_Opaque, 108 NULL, 0, 0, 640, 480); 108 109 resizeEvent (&event); 109 110 } 110 111 111 VBoxQuartz2DFrameBuffer::~VBoxQuartz2DFrameBuffer()112 UIFrameBufferQuartz2D::~UIFrameBufferQuartz2D() 112 113 { 113 114 Log (("Quartz2D: Deleting\n")); … … 123 124 124 125 /** @note This method is called on EMT from under this object's lock */ 125 STDMETHODIMP VBoxQuartz2DFrameBuffer::NotifyUpdate (ULONG aX, ULONG aY,126 STDMETHODIMP UIFrameBufferQuartz2D::NotifyUpdate (ULONG aX, ULONG aY, 126 127 ULONG aW, ULONG aH) 127 128 { 128 129 /* Log (("Quartz2D: NotifyUpdate %d,%d %dx%d\n", aX, aY, aW, aH));*/ 129 130 130 QApplication::postEvent (m View,131 new VBoxRepaintEvent (aX, aY, aW, aH));131 QApplication::postEvent (m_pMachineView, 132 new UIRepaintEvent (aX, aY, aW, aH)); 132 133 return S_OK; 133 134 } 134 135 135 STDMETHODIMP VBoxQuartz2DFrameBuffer::SetVisibleRegion (BYTE *aRectangles, ULONG aCount)136 STDMETHODIMP UIFrameBufferQuartz2D::SetVisibleRegion (BYTE *aRectangles, ULONG aCount) 136 137 { 137 138 PRTRECT rects = (PRTRECT)aRectangles; … … 202 203 RTMemFree (pvOld); 203 204 204 QApplication::postEvent (m View, new VBoxSetRegionEvent (reg));205 QApplication::postEvent (m_pMachineView, new UISetRegionEvent (reg)); 205 206 206 207 return S_OK; 207 208 } 208 209 209 void VBoxQuartz2DFrameBuffer::paintEvent (QPaintEvent *aEvent)210 void UIFrameBufferQuartz2D::paintEvent (QPaintEvent *aEvent) 210 211 { 211 212 /* For debugging /Developer/Applications/Performance Tools/Quartz … … 213 214 * updated.*/ 214 215 215 Assert (m Image);216 217 VBoxConsoleWnd *main = qobject_cast <VBoxConsoleWnd *> (vboxGlobal().mainWindow());218 Assert (VALID_PTR (main));219 QWidget* viewport = m View->viewport();216 Assert (m_image); 217 218 // VBoxConsoleWnd *main = qobject_cast <VBoxConsoleWnd *> (vboxGlobal().mainWindow()); 219 // Assert (VALID_PTR (main)); 220 QWidget* viewport = m_pMachineView->viewport(); 220 221 Assert (VALID_PTR (viewport)); 221 222 /* Get the dimensions of the viewport */ … … 230 231 231 232 /* We handle the seamless mode as a special case. */ 232 if (main->isTrueSeamless()) 233 // if (main->isTrueSeamless()) 234 if (0) 233 235 { 234 236 /* Here we paint the windows without any wallpaper. … … 238 240 * Currently this subimage is the whole screen. */ 239 241 CGImageRef subImage; 240 if (!m View->pauseShot().isNull())241 { 242 CGImageRef pauseImg = ::darwinToCGImageRef (&m View->pauseShot());243 subImage = CGImageCreateWithImageInRect (pauseImg, CGRectMake (m View->contentsX(), mView->contentsY(), mView->visibleWidth(), mView->visibleHeight()));242 if (!m_pMachineView->pauseShot().isNull()) 243 { 244 CGImageRef pauseImg = ::darwinToCGImageRef (&m_pMachineView->pauseShot()); 245 subImage = CGImageCreateWithImageInRect (pauseImg, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight())); 244 246 CGImageRelease (pauseImg); 245 247 } … … 251 253 if (mSnowLeoCarbonFix) 252 254 { 253 CGImageRef copy = CGImageCreateCopy (m Image);254 subImage = CGImageCreateWithImageInRect (copy, CGRectMake (m View->contentsX(), mView->contentsY(), mView->visibleWidth(), mView->visibleHeight()));255 CGImageRef copy = CGImageCreateCopy (m_image); 256 subImage = CGImageCreateWithImageInRect (copy, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight())); 255 257 CGImageRelease (copy); 256 258 }else 257 259 #endif /* QT_MAC_USE_COCOA */ 258 subImage = CGImageCreateWithImageInRect (m Image, CGRectMake (mView->contentsX(), mView->contentsY(), mView->visibleWidth(), mView->visibleHeight()));260 subImage = CGImageCreateWithImageInRect (m_image, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight())); 259 261 } 260 262 Assert (VALID_PTR (subImage)); … … 315 317 * of the bounding box of the current paint event */ 316 318 QRect ir = aEvent->rect(); 317 QRect is = QRect (ir.x() + m View->contentsX(), ir.y() + mView->contentsY(), ir.width(), ir.height());319 QRect is = QRect (ir.x() + m_pMachineView->contentsX(), ir.y() + m_pMachineView->contentsY(), ir.width(), ir.height()); 318 320 CGImageRef subImage; 319 if (!m View->pauseShot().isNull())320 { 321 CGImageRef pauseImg = ::darwinToCGImageRef (&m View->pauseShot());321 if (!m_pMachineView->pauseShot().isNull()) 322 { 323 CGImageRef pauseImg = ::darwinToCGImageRef (&m_pMachineView->pauseShot()); 322 324 subImage = CGImageCreateWithImageInRect (pauseImg, ::darwinToCGRect (is)); 323 325 CGImageRelease (pauseImg); … … 329 331 if (mSnowLeoCarbonFix) 330 332 { 331 CGImageRef copy = CGImageCreateCopy (m Image);333 CGImageRef copy = CGImageCreateCopy (m_image); 332 334 subImage = CGImageCreateWithImageInRect (copy, ::darwinToCGRect (is)); 333 335 CGImageRelease (copy); 334 336 }else 335 337 #endif /* QT_MAC_USE_COCOA */ 336 subImage = CGImageCreateWithImageInRect (m Image, ::darwinToCGRect (is));338 subImage = CGImageCreateWithImageInRect (m_image, ::darwinToCGRect (is)); 337 339 } 338 340 Assert (VALID_PTR (subImage)); … … 359 361 } 360 362 361 void VBoxQuartz2DFrameBuffer::resizeEvent (VBoxResizeEvent *aEvent)363 void UIFrameBufferQuartz2D::resizeEvent (UIResizeEvent *aEvent) 362 364 { 363 365 #if 0 … … 371 373 clean(); 372 374 373 m Wdt= aEvent->width();374 m Hgt = aEvent->height();375 m_width = aEvent->width(); 376 m_height = aEvent->height(); 375 377 376 378 bool remind = false; … … 386 388 // printf ("VRAM\n"); 387 389 /* Create the image copy of the framebuffer */ 388 CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, aEvent->VRAM(), aEvent->bitsPerPixel() / 8 * m Wdt * mHgt, NULL);389 m Image = CGImageCreate (mWdt, mHgt, 8, aEvent->bitsPerPixel(), aEvent->bytesPerLine(), cs,390 CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, aEvent->VRAM(), aEvent->bitsPerPixel() / 8 * m_width * m_height, NULL); 391 m_image = CGImageCreate (m_width, m_height, 8, aEvent->bitsPerPixel(), aEvent->bytesPerLine(), cs, 390 392 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, 391 393 kCGRenderingIntentDefault); 392 m DataAddress = aEvent->VRAM();394 m_pDataAddress = aEvent->VRAM(); 393 395 CGDataProviderRelease (dp); 394 396 } … … 400 402 * Read somewhere that an alignment of 16 is 401 403 * best for optimal performance. So why not. */ 402 // int bitmapBytesPerRow = RT_ALIGN (m Wdt* 4, 16);403 int bitmapBytesPerRow = m Wdt* 4;404 int bitmapByteCount = (bitmapBytesPerRow * m Hgt);405 m BitmapData = RTMemAlloc (bitmapByteCount);406 CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, m BitmapData, bitmapByteCount, NULL);407 m Image = CGImageCreate (mWdt, mHgt, 8, 32, bitmapBytesPerRow, cs,404 // int bitmapBytesPerRow = RT_ALIGN (m_width * 4, 16); 405 int bitmapBytesPerRow = m_width * 4; 406 int bitmapByteCount = (bitmapBytesPerRow * m_height); 407 m_pBitmapData = RTMemAlloc (bitmapByteCount); 408 CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, m_pBitmapData, bitmapByteCount, NULL); 409 m_image = CGImageCreate (m_width, m_height, 8, 32, bitmapBytesPerRow, cs, 408 410 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, 409 411 kCGRenderingIntentDefault); 410 m DataAddress = static_cast <uchar*> (mBitmapData);412 m_pDataAddress = static_cast <uchar*> (m_pBitmapData); 411 413 CGDataProviderRelease (dp); 412 414 } 413 415 CGColorSpaceRelease (cs); 414 416 #ifdef VBOX_WITH_ICHAT_THEATER 415 setImageRef (m Image);417 setImageRef (m_image); 416 418 #endif 417 419 … … 433 435 } 434 436 435 void VBoxQuartz2DFrameBuffer::clean()436 { 437 if (m Image)438 { 439 CGImageRelease (m Image);440 m Image = NULL;441 } 442 if (m BitmapData)443 { 444 RTMemFree (m BitmapData);445 m BitmapData = NULL;437 void UIFrameBufferQuartz2D::clean() 438 { 439 if (m_image) 440 { 441 CGImageRelease (m_image); 442 m_image = NULL; 443 } 444 if (m_pBitmapData) 445 { 446 RTMemFree (m_pBitmapData); 447 m_pBitmapData = NULL; 446 448 } 447 449 if (mRegion) … … 458 460 459 461 #ifndef QT_MAC_USE_COCOA 460 void VBoxQuartz2DFrameBuffer::testAndSetSNCarbonFix()461 { 462 QWidget* viewport = m View->viewport();462 void UIFrameBufferQuartz2D::testAndSetSNCarbonFix() 463 { 464 QWidget* viewport = m_pMachineView->viewport(); 463 465 Assert (VALID_PTR (viewport)); 464 466 QDesktopWidget dw; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.h
r26777 r26781 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * UIFrameBuffer class and subclasses declarations4 * UIFrameBufferQuartz2D class declarations 5 5 */ 6 6 … … 21 21 */ 22 22 23 #ifndef ___UIFrameBuffer _h___24 #define ___UIFrameBuffer _h___23 #ifndef ___UIFrameBufferQuartz2D_h___ 24 #define ___UIFrameBufferQuartz2D_h___ 25 25 26 /* Global includes */ 27 //#include <QImage> 28 #include <QPixmap> 29 //#include <QMutex> 30 #include <QPaintEvent> 31 //#include <QMoveEvent> 32 //#if defined (VBOX_GUI_USE_QGL) 33 //#include "VBoxFBOverlay.h" 34 //#endif 26 #include <QtGlobal> 35 27 36 /* Local includes */ 37 #include "COMDefs.h" 38 #include <iprt/critsect.h> 28 #if defined (Q_WS_MAC) && defined (VBOX_GUI_USE_QUARTZ2D) 39 29 40 //#if defined (VBOX_GUI_USE_SDL) 41 //#include <SDL.h> 42 //#include <signal.h> 43 //#endif 30 #include "UIFrameBuffer.h" 44 31 45 //#if defined (Q_WS_WIN) && defined (VBOX_GUI_USE_DDRAW)46 // VBox/cdefs.h defines these:47 //#undef LOWORD48 //#undef HIWORD49 //#undef LOBYTE50 //#undef HIBYTE51 //#include <ddraw.h>52 //#endif53 54 class UIMachineView;55 56 /**57 * Frame buffer resize event.58 */59 class UIResizeEvent : public QEvent60 {61 public:62 63 UIResizeEvent(ulong uPixelFormat, uchar *pVRAM,64 ulong uBitsPerPixel, ulong uBytesPerLine,65 ulong uWidth, ulong uHeight)66 : QEvent((QEvent::Type)VBoxDefs::ResizeEventType)67 , m_uPixelFormat(uPixelFormat), m_pVRAM(pVRAM), m_uBitsPerPixel(uBitsPerPixel)68 , m_uBytesPerLine(uBytesPerLine), m_uWidth(uWidth), m_uHeight(uHeight) {}69 ulong pixelFormat() { return m_uPixelFormat; }70 uchar *VRAM() { return m_pVRAM; }71 ulong bitsPerPixel() { return m_uBitsPerPixel; }72 ulong bytesPerLine() { return m_uBytesPerLine; }73 ulong width() { return m_uWidth; }74 ulong height() { return m_uHeight; }75 76 private:77 78 ulong m_uPixelFormat;79 uchar *m_pVRAM;80 ulong m_uBitsPerPixel;81 ulong m_uBytesPerLine;82 ulong m_uWidth;83 ulong m_uHeight;84 };85 86 /**87 * Frame buffer repaint event.88 */89 class UIRepaintEvent : public QEvent90 {91 public:92 93 UIRepaintEvent(int iX, int iY, int iW, int iH)94 : QEvent((QEvent::Type)VBoxDefs::RepaintEventType)95 , m_iX(iX), m_iY(iY), m_iW(iW), m_iH(iH) {}96 int x() { return m_iX; }97 int y() { return m_iY; }98 int width() { return m_iW; }99 int height() { return m_iH; }100 101 private:102 103 int m_iX, m_iY, m_iW, m_iH;104 };105 106 /**107 * Frame buffer set region event.108 */109 class UISetRegionEvent : public QEvent110 {111 public:112 113 UISetRegionEvent(const QRegion ®ion)114 : QEvent((QEvent::Type)VBoxDefs::SetRegionEventType)115 , m_region(region) {}116 QRegion region() { return m_region; }117 118 private:119 120 QRegion m_region;121 };122 123 /**124 * Common IFramebuffer implementation for all methods used by GUI to maintain125 * the VM display video memory.126 *127 * Note that although this class can be called from multiple threads128 * (in particular, the GUI thread and EMT) it doesn't protect access to every129 * data field using its mutex lock. This is because all synchronization between130 * the GUI and the EMT thread is supposed to be done using the131 * IFramebuffer::NotifyUpdate() and IFramebuffer::RequestResize() methods132 * (in particular, the \a aFinished parameter of these methods is responsible133 * for the synchronization). These methods are always called on EMT and134 * therefore always follow one another but never in parallel.135 *136 * Using this object's mutex lock (exposed also in IFramebuffer::Lock() and137 * IFramebuffer::Unlock() implementations) usually makes sense only if some138 * third-party thread (i.e. other than GUI or EMT) needs to make sure that139 * *no* VM display update or resize event can occur while it is accessing140 * IFramebuffer properties or the underlying display memory storage area.141 *142 * See IFramebuffer documentation for more info.143 */144 class UIFrameBuffer : VBOX_SCRIPTABLE_IMPL(IFramebuffer)145 {146 public:147 148 UIFrameBuffer(UIMachineView *aView);149 virtual ~UIFrameBuffer();150 151 NS_DECL_ISUPPORTS152 153 #if defined (Q_OS_WIN32)154 STDMETHOD_(ULONG, AddRef)()155 {156 return ::InterlockedIncrement(&m_iRefCnt);157 }158 159 STDMETHOD_(ULONG, Release)()160 {161 long cnt = ::InterlockedDecrement(&m_iRefCnt);162 if (cnt == 0)163 delete this;164 return cnt;165 }166 #endif167 168 VBOX_SCRIPTABLE_DISPATCH_IMPL(IFramebuffer)169 170 /* IFramebuffer COM methods */171 STDMETHOD(COMGETTER(Address)) (BYTE **ppAddress);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(UsesGuestVRAM)) (BOOL *pbUsesGuestVRAM);178 STDMETHOD(COMGETTER(HeightReduction)) (ULONG *puHeightReduction);179 STDMETHOD(COMGETTER(Overlay)) (IFramebufferOverlay **ppOverlay);180 STDMETHOD(COMGETTER(WinId)) (ULONG64 *pWinId);181 182 STDMETHOD(Lock)();183 STDMETHOD(Unlock)();184 185 STDMETHOD(RequestResize) (ULONG uScreenId, ULONG uPixelFormat,186 BYTE *pVRAM, ULONG uBitsPerPixel, ULONG uBytesPerLine,187 ULONG uWidth, ULONG uHeight,188 BOOL *pbFinished);189 190 STDMETHOD(VideoModeSupported) (ULONG uWidth, ULONG uHeight, ULONG uBPP,191 BOOL *pbSupported);192 193 STDMETHOD(GetVisibleRegion)(BYTE *pRectangles, ULONG uCount, ULONG *puCountCopied);194 STDMETHOD(SetVisibleRegion)(BYTE *pRectangles, ULONG uCount);195 196 STDMETHOD(ProcessVHWACommand)(BYTE *pCommand);197 198 ulong width() { return m_width; }199 ulong height() { return m_height; }200 201 virtual ulong pixelFormat()202 {203 return FramebufferPixelFormat_FOURCC_RGB;204 }205 206 virtual bool usesGuestVRAM()207 {208 return false;209 }210 211 void lock() { RTCritSectEnter(&m_critSect); }212 void unlock() { RTCritSectLeave(&m_critSect); }213 214 virtual uchar *address() = 0;215 virtual ulong bitsPerPixel() = 0;216 virtual ulong bytesPerLine() = 0;217 218 /**219 * Called on the GUI thread (from VBoxConsoleView) when some part of the220 * VM display viewport needs to be repainted on the host screen.221 */222 virtual void paintEvent(QPaintEvent *pEvent) = 0;223 224 /**225 * Called on the GUI thread (from VBoxConsoleView) after it gets a226 * UIResizeEvent posted from the RequestResize() method implementation.227 */228 virtual void resizeEvent(UIResizeEvent *pEvent)229 {230 m_width = pEvent->width();231 m_height = pEvent->height();232 }233 234 /**235 * Called on the GUI thread (from VBoxConsoleView) when the VM console236 * window is moved.237 */238 virtual void moveEvent(QMoveEvent * /* pEvent */) {}239 240 #ifdef VBOX_WITH_VIDEOHWACCEL241 /* this method is called from the GUI thread242 * to perform the actual Video HW Acceleration command processing243 * the event is framebuffer implementation specific */244 virtual void doProcessVHWACommand(QEvent * pEvent);245 246 virtual void viewportResized(QResizeEvent * /* pEvent */) {}247 248 virtual void viewportScrolled(int /* iX */, int /* iY */) {}249 #endif250 251 protected:252 253 UIMachineView *m_pMachineView;254 RTCRITSECT m_critSect;255 int m_width;256 int m_height;257 uint64_t m_uWinId;258 259 #if defined (Q_OS_WIN32)260 private:261 262 long m_iRefCnt;263 #endif264 };265 266 #if defined (VBOX_GUI_USE_QIMAGE)267 class UIFrameBufferQImage : public UIFrameBuffer268 {269 public:270 271 UIFrameBufferQImage(UIMachineView *pMachineView);272 273 STDMETHOD(NotifyUpdate) (ULONG uX, ULONG uY, ULONG uW, ULONG uH);274 275 ulong pixelFormat() { return m_uPixelFormat; }276 bool usesGuestVRAM() { return m_bUsesGuestVRAM; }277 278 uchar *address() { return m_img.bits(); }279 ulong bitsPerPixel() { return m_img.depth(); }280 ulong bytesPerLine() { return m_img.bytesPerLine(); }281 282 void paintEvent (QPaintEvent *pEvent);283 void resizeEvent (UIResizeEvent *pEvent);284 285 private:286 287 QPixmap m_PM;288 QImage m_img;289 ulong m_uPixelFormat;290 bool m_bUsesGuestVRAM;291 };292 #endif293 294 #if 0295 #if defined (VBOX_GUI_USE_QGL)296 class UIFrameBufferQGL : public UIFrameBuffer297 {298 public:299 300 UIFrameBufferQGL(UIMachineView *pMachineView);301 302 STDMETHOD(NotifyUpdate) (ULONG uX, ULONG uY, ULONG uW, ULONG uH);303 #ifdef VBOXQGL_PROF_BASE304 STDMETHOD(RequestResize) (ULONG uScreenId, ULONG uPixelFormat,305 BYTE *pVRAM, ULONG uBitsPerPixel, ULONG uBytesPerLine,306 ULONG uWidth, ULONG uHeight, BOOL *pbFinished);307 #endif308 309 #ifdef VBOX_WITH_VIDEOHWACCEL310 STDMETHOD(ProcessVHWACommand)(BYTE *pbCommand);311 #endif312 313 ulong pixelFormat() { return vboxWidget()->vboxPixelFormat(); }314 bool usesGuestVRAM() { return vboxWidget()->vboxUsesGuestVRAM(); }315 316 uchar *address() { return vboxWidget()->vboxAddress(); }317 ulong bitsPerPixel() { return vboxWidget()->vboxBitsPerPixel(); }318 ulong bytesPerLine() { return vboxWidget()->vboxBytesPerLine(); }319 320 void paintEvent (QPaintEvent *pEvent);321 void resizeEvent (UIResizeEvent *pEvent);322 void doProcessVHWACommand(QEvent *pEvent);323 324 private:325 326 class VBoxGLWidget* vboxWidget();327 328 class VBoxVHWACommandElementProcessor m_cmdPipe;329 };330 #endif331 332 #if defined (VBOX_GUI_USE_SDL)333 class UIFrameBufferSDL : public UIFrameBuffer334 {335 public:336 337 UIFrameBufferSDL (VBoxConsoleView *pMachineView);338 virtual ~UIFrameBufferSDL();339 340 STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY, ULONG aW, ULONG aH);341 342 uchar* address()343 {344 SDL_Surface *surf = m_pSurfVRAM ? m_pSurfVRAM : m_pScreen;345 return surf ? (uchar*) (uintptr_t) surf->pixels : 0;346 }347 348 ulong bitsPerPixel()349 {350 SDL_Surface *surf = m_pSurfVRAM ? m_pSurfVRAM : m_pScreen;351 return surf ? surf->format->BitsPerPixel : 0;352 }353 354 ulong bytesPerLine()355 {356 SDL_Surface *surf = m_pSurfVRAM ? m_pSurfVRAM : m_pScreen;357 return surf ? surf->pitch : 0;358 }359 360 ulong pixelFormat()361 {362 return m_uPixelFormat;363 }364 365 bool usesGuestVRAM()366 {367 return m_pSurfVRAM != NULL;368 }369 370 void paintEvent(QPaintEvent *pEvent);371 void resizeEvent(UIResizeEvent *pEvent);372 373 private:374 375 SDL_Surface *m_pScreen;376 SDL_Surface *m_pSurfVRAM;377 378 ulong m_uPixelFormat;379 };380 #endif381 382 #if defined (VBOX_GUI_USE_DDRAW)383 class UIFrameBufferDDRAW : public UIFrameBuffer384 {385 public:386 387 UIFrameBufferDDRAW(UIMachineView *pMachineView);388 virtual ~UIFrameBufferDDRAW();389 390 STDMETHOD(NotifyUpdate) (ULONG uX, ULONG uY, ULONG uW, ULONG uH);391 392 uchar* address() { return (uchar*) m_surfaceDesc.lpSurface; }393 ulong bitsPerPixel() { return m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount; }394 ulong bytesPerLine() { return (ulong) m_surfaceDesc.lPitch; }395 396 ulong pixelFormat() { return m_uPixelFormat; };397 398 bool usesGuestVRAM() { return m_bUsesGuestVRAM; }399 400 void paintEvent(QPaintEvent *pEvent);401 void resizeEvent(UIResizeEvent *pEvent);402 void moveEvent(QMoveEvent *pEvent);403 404 private:405 406 void releaseObjects();407 408 bool createSurface(ULONG uPixelFormat, uchar *pvVRAM,409 ULONG uBitsPerPixel, ULONG uBytesPerLine,410 ULONG uWidth, ULONG uHeight);411 void deleteSurface();412 void drawRect(ULONG uX, ULONG uY, ULONG uW, ULONG uH);413 void getWindowPosition(void);414 415 LPDIRECTDRAW7 m_DDRAW;416 LPDIRECTDRAWCLIPPER m_clipper;417 LPDIRECTDRAWSURFACE7 m_surface;418 DDSURFACEDESC2 m_surfaceDesc;419 LPDIRECTDRAWSURFACE7 m_primarySurface;420 421 ulong m_uPixelFormat;422 423 bool m_bUsesGuestVRAM;424 425 int m_iWndX;426 int m_iWndY;427 428 bool m_bSynchronousUpdates;429 };430 #endif431 432 #endif433 #if defined (Q_WS_MAC) && defined (VBOX_GUI_USE_QUARTZ2D)434 32 #include <Carbon/Carbon.h> 435 33 … … 441 39 virtual ~UIFrameBufferQuartz2D(); 442 40 443 STDMETHOD (NotifyUpdate)(ULONG uX, ULONG uY, ULONG uW, ULONG uH);444 STDMETHOD (SetVisibleRegion)(BYTE *pRectangles, ULONG uCount);41 STDMETHOD(NotifyUpdate)(ULONG uX, ULONG uY, ULONG uW, ULONG uH); 42 STDMETHOD(SetVisibleRegion)(BYTE *pRectangles, ULONG uCount); 445 43 446 44 uchar* address() { return m_pDataAddress; } … … 498 96 #endif /* Q_WS_MAC && VBOX_GUI_USE_QUARTZ2D */ 499 97 500 #endif // !___UIFrameBuffer _h___98 #endif // !___UIFrameBufferQuartz2D_h___ 501 99 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r26773 r26781 1017 1017 1018 1018 // TODO: Call for singleton information dialog for this machine! 1019 //VBoxVMInformationDlg::createInformationDlg(session(), machineWindowWrapper()->machineWindow());1019 // VBoxVMInformationDlg::createInformationDlg(session(), machineWindowWrapper()->machineWindow()); 1020 1020 } 1021 1021 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r26773 r26781 33 33 #include "VBoxProblemReporter.h" 34 34 #include "UIFrameBuffer.h" 35 #include "UIFrameBufferQuartz2D.h" 35 36 #include "UISession.h" 36 37 #include "UIActionsPool.h" … … 459 460 #endif 460 461 #endif 461 #if 0 // TODO: Enable Quartz2D frame buffer!462 462 #if defined (VBOX_GUI_USE_QUARTZ2D) 463 463 case VBoxDefs::Quartz2DMode: 464 464 /* Indicate that we are doing all drawing stuff ourself: */ 465 pViewport->setAttribute(Qt::WA_PaintOnScreen);466 # ifdef VBOX_WITH_VIDEOHWACCEL467 m_pFrameBuffer = m_fAccelerate2DVideo ? new VBoxOverlayFrameBuffer<VBoxQuartz2DFrameBuffer>(this, &machineWindowWrapper()->session()) : new UIFrameBufferQuartz2D(this);468 # else465 // pViewport->setAttribute(Qt::WA_PaintOnScreen); 466 //# ifdef VBOX_WITH_VIDEOHWACCEL 467 // m_pFrameBuffer = m_fAccelerate2DVideo ? new VBoxOverlayFrameBuffer<VBoxQuartz2DFrameBuffer>(this, &machineWindowWrapper()->session()) : new UIFrameBufferQuartz2D(this); 468 //# else 469 469 m_pFrameBuffer = new UIFrameBufferQuartz2D(this); 470 # endif470 //# endif 471 471 break; 472 #endif473 472 #endif 474 473 default: … … 720 719 } 721 720 # endif 722 delete mDockIconPreview; 721 // TODO_NEW_CORE 722 // delete mDockIconPreview; 723 723 mDockIconPreview = NULL; 724 724 #endif … … 1011 1011 1012 1012 #ifdef Q_WS_MAC 1013 mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height()); 1013 // TODO_NEW_CORE 1014 // mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height()); 1014 1015 #endif /* Q_WS_MAC */ 1015 1016 … … 2053 2054 #ifdef Q_WS_MAC 2054 2055 /* Update the dock icon if we are in the running state */ 2055 if (isRunning()) 2056 updateDockIcon(); 2056 // TODO_NEW_CORE 2057 // if (isRunning()) 2058 // updateDockIcon(); 2057 2059 #endif 2058 2060 return; … … 2060 2062 2061 2063 #ifdef VBOX_GUI_USE_QUARTZ2D 2062 if (mode() == VBoxDefs::Quartz2DMode && m_pFrameBuffer) 2063 { 2064 m_pFrameBuffer->paintEvent(pPaintEvent); 2065 updateDockIcon(); 2066 } 2067 else 2068 #endif 2069 { 2070 /* We have a snapshot for the paused state: */ 2071 QRect r = pPaintEvent->rect().intersect (viewport()->rect()); 2072 /* We have to disable paint on screen if we are using the regular painter */ 2073 bool paintOnScreen = viewport()->testAttribute(Qt::WA_PaintOnScreen); 2074 viewport()->setAttribute(Qt::WA_PaintOnScreen, false); 2075 QPainter pnt(viewport()); 2076 pnt.drawPixmap(r.x(), r.y(), m_pauseShot, r.x() + contentsX(), r.y() + contentsY(), r.width(), r.height()); 2077 /* Restore the attribute to its previous state */ 2078 viewport()->setAttribute(Qt::WA_PaintOnScreen, paintOnScreen); 2064 // TODO_NEW_CORE 2065 // if (mode() == VBoxDefs::Quartz2DMode && m_pFrameBuffer) 2066 // { 2067 // m_pFrameBuffer->paintEvent(pPaintEvent); 2068 // updateDockIcon(); 2069 // } 2070 // else 2071 #endif 2072 // { 2073 // /* We have a snapshot for the paused state: */ 2074 // QRect r = pPaintEvent->rect().intersect (viewport()->rect()); 2075 // /* We have to disable paint on screen if we are using the regular painter */ 2076 // bool paintOnScreen = viewport()->testAttribute(Qt::WA_PaintOnScreen); 2077 // viewport()->setAttribute(Qt::WA_PaintOnScreen, false); 2078 // QPainter pnt(viewport()); 2079 // pnt.drawPixmap(r.x(), r.y(), m_pauseShot, r.x() + contentsX(), r.y() + contentsY(), r.width(), r.height()); 2080 // /* Restore the attribute to its previous state */ 2081 // viewport()->setAttribute(Qt::WA_PaintOnScreen, paintOnScreen); 2079 2082 #ifdef Q_WS_MAC 2080 updateDockIcon();2081 #endif 2082 }2083 // updateDockIcon(); 2084 #endif 2085 // } 2083 2086 } 2084 2087 … … 3245 3248 void UIMachineView::updateDockIcon() 3246 3249 { 3247 if (mDockIconEnabled)3248 { 3249 if (!m_pauseShot.isNull()) 3250 { 3251 CGImageRef pauseImg = ::darwinToCGImageRef (&m_pauseShot); 3252 /* Use the pause image as background */ 3253 mDockIconPreview->updateDockPreview (pauseImg); 3254 CGImageRelease(pauseImg);3255 } 3256 else 3257 { 3258 # if defined (VBOX_GUI_USE_QUARTZ2D) 3259 // TODO_NEW_CORE 3250 // TODO_NEW_CORE 3251 // if (mDockIconEnabled) 3252 // { 3253 // if (!m_pauseShot.isNull()) 3254 // { 3255 // CGImageRef pauseImg = ::darwinToCGImageRef (&m_pauseShot); 3256 // /* Use the pause image as background */ 3257 // mDockIconPreview->updateDockPreview (pauseImg); 3258 // CGImageRelease (pauseImg); 3259 // } 3260 // else 3261 // { 3262 //# if defined (VBOX_GUI_USE_QUARTZ2D) 3260 3263 // if (mode() == VBoxDefs::Quartz2DMode) 3261 3264 // { 3262 /* If the render mode is Quartz2D we could use the CGImageRef3263 * of the framebuffer for the dock icon creation. This saves3264 * some conversion time. */3265 // mDockIconPreview->updateDockPreview (static_cast <VBoxQuartz2DFrameBuffer *>(m_pFrameBuffer)->imageRef());3265 // /* If the render mode is Quartz2D we could use the CGImageRef 3266 // * of the framebuffer for the dock icon creation. This saves 3267 // * some conversion time. */ 3268 // mDockIconPreview->updateDockPreview(static_cast<UIFrameBufferQuartz2D*>(m_pFrameBuffer)->imageRef()); 3266 3269 // } 3267 3270 // else 3268 # endif 3269 /* In image mode we have to create the image ref out of the 3270 * framebuffer */ 3271 // TODO_NEW_CORE 3272 // mDockIconPreview->updateDockPreview (m_pFrameBuffer); 3273 } 3274 } 3271 //# endif 3272 // /* In image mode we have to create the image ref out of the 3273 // * framebuffer */ 3274 // mDockIconPreview->updateDockPreview(m_pFrameBuffer); 3275 // } 3276 // } 3275 3277 } 3276 3278 … … 3280 3282 * & we are in an state where the framebuffer is likely valid. Otherwise to 3281 3283 * the overlay stuff only. */ 3282 if (mDockIconEnabled && 3283 (machineState() == KMachineState_Running || 3284 machineState() == KMachineState_Paused || 3285 machineState() == KMachineState_Teleporting || 3286 machineState() == KMachineState_LiveSnapshotting || 3287 machineState() == KMachineState_Restoring || 3288 machineState() == KMachineState_TeleportingPausedVM || 3289 machineState() == KMachineState_TeleportingIn || 3290 machineState() == KMachineState_Saving)) 3291 updateDockIcon(); 3292 else 3293 mDockIconPreview->updateDockOverlay(); 3284 // TODO_NEW_CORE 3285 // if (mDockIconEnabled && 3286 // (machineState() == KMachineState_Running || 3287 // machineState() == KMachineState_Paused || 3288 // machineState() == KMachineState_Teleporting || 3289 // machineState() == KMachineState_LiveSnapshotting || 3290 // machineState() == KMachineState_Restoring || 3291 // machineState() == KMachineState_TeleportingPausedVM || 3292 // machineState() == KMachineState_TeleportingIn || 3293 // machineState() == KMachineState_Saving)) 3294 // updateDockIcon(); 3295 // else 3296 // mDockIconPreview->updateDockOverlay(); 3294 3297 } 3295 3298
Note:
See TracChangeset
for help on using the changeset viewer.