Changeset 51493 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 2, 2014 4:30:27 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r51484 r51493 561 561 src/runtime/UIConsoleEventHandler.cpp \ 562 562 src/runtime/UIFrameBuffer.cpp \ 563 src/runtime/UIFrameBufferQImage.cpp \564 563 src/runtime/UIIndicatorsPool.cpp \ 565 564 src/runtime/UIKeyboardHandler.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.h
r51487 r51493 1819 1819 }; 1820 1820 1821 /* th ese two additional class V, class R areto workaround the [VBox|UI] duplication,1822 * @todo: remove themonce VBox stuff is removed */1823 template <class T, class V , class R>1821 /* this additional class V is to workaround the [VBox|UI] duplication, 1822 * @todo: remove it once VBox stuff is removed */ 1823 template <class T, class V> 1824 1824 class VBoxOverlayFrameBuffer : public T 1825 1825 { … … 1886 1886 } 1887 1887 1888 void resizeEvent (R *re)1889 { 1890 T::resizeEvent (re);1891 mOverlay.onResizeEventPostprocess 1888 void resizeEvent(int iWidth, int iHeight) 1889 { 1890 T::resizeEvent(iWidth, iHeight); 1891 mOverlay.onResizeEventPostprocess(VBoxFBSizeInfo(this), 1892 1892 QPoint(mpView->contentsX(), mpView->contentsY())); 1893 1893 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r51487 r51493 19 19 # include "precomp.h" 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 /* Qt includes: */ 22 # include <QPainter> 21 23 /* GUI includes: */ 22 24 # include "UIFrameBuffer.h" 25 # include "UISession.h" 26 # include "UIMachineLogic.h" 27 # include "UIMachineWindow.h" 23 28 # include "UIMachineView.h" 24 # include "UI MessageCenter.h"29 # include "UIPopupCenter.h" 25 30 # include "VBoxGlobal.h" 26 31 # ifndef VBOX_WITH_TRANSLUCENT_SEAMLESS … … 43 48 44 49 UIFrameBuffer::UIFrameBuffer(UIMachineView *pMachineView) 45 : m_pMachineView(pMachineView) 46 , m_width(0), m_height(0) 50 : m_iWidth(0), m_iHeight(0) 51 , m_pMachineView(pMachineView) 52 , m_iWinId(0) 53 , m_fUpdatesAllowed(true) 47 54 , m_fUnused(false) 48 55 , m_fAutoEnabled(false) 49 , m_fIsUpdatesAllowed(true)50 56 #ifdef Q_OS_WIN 51 57 , m_iRefCnt(0) … … 57 63 AssertMsg(m_pMachineView, ("UIMachineView must not be NULL\n")); 58 64 /* Cache window ID: */ 59 m_ winId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0;65 m_iWinId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0; 60 66 61 67 /* Initialize critical-section: */ … … 66 72 if (m_pMachineView) 67 73 prepareConnections(); 74 75 /* Resize frame-buffer to default size: */ 76 resizeEvent(640, 480); 68 77 } 69 78 … … 87 96 m_pMachineView = pMachineView; 88 97 /* Recache window ID: */ 89 m_ winId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0;98 m_iWinId = (m_pMachineView && m_pMachineView->viewport()) ? (LONG64)m_pMachineView->viewport()->winId() : 0; 90 99 91 100 /* Connect new handlers: */ … … 177 186 if (!pWinId) 178 187 return E_POINTER; 179 *pWinId = m_ winId;188 *pWinId = m_iWinId; 180 189 return S_OK; 181 190 } … … 223 232 (unsigned long)uX, (unsigned long)uY, 224 233 (unsigned long)uWidth, (unsigned long)uHeight)); 225 emit sigNotifyChange(u ScreenId, uWidth, uHeight);234 emit sigNotifyChange(uWidth, uHeight); 226 235 227 236 /* Unlock access to frame-buffer: */ … … 242 251 uX = qMax(0, (int)uX - 1); 243 252 uY = qMax(0, (int)uY - 1); 244 uWidth = qMin( (int)m_width, (int)uWidth + 2);245 uHeight = qMin( (int)m_height, (int)uHeight + 2);253 uWidth = qMin(m_iWidth, (int)uWidth + 2); 254 uHeight = qMin(m_iHeight, (int)uHeight + 2); 246 255 247 256 /* Lock access to frame-buffer: */ … … 455 464 } 456 465 457 void UIFrameBuffer::notifyChange() 458 { 466 void UIFrameBuffer::notifyChange(int iWidth, int iHeight) 467 { 468 LogRel(("UIFrameBuffer::notifyChange: Size=%dx%d\n", iWidth, iHeight)); 469 470 /* Make sure machine-view is assigned: */ 471 AssertPtrReturnVoid(m_pMachineView); 472 459 473 /* Lock access to frame-buffer: */ 460 474 lock(); 461 475 462 /* If there is NO pending source 476 /* If there is NO pending source-bitmap: */ 463 477 if (m_pendingSourceBitmap.isNull()) 464 478 { 465 479 /* Do nothing, change-event already processed: */ 466 LogRel Flow(("UIFrameBuffer::notifyChange: Already processed.\n"));480 LogRel2(("UIFrameBuffer::notifyChange: Already processed.\n")); 467 481 /* Unlock access to frame-buffer: */ 468 482 unlock(); … … 472 486 473 487 /* Disable screen updates: */ 474 m_f IsUpdatesAllowed = false;488 m_fUpdatesAllowed = false; 475 489 476 490 /* Release the current bitmap and keep the pending one: */ … … 481 495 unlock(); 482 496 483 /* Acquire source bitmap: */484 BYTE *pAddress = NULL;485 ULONG ulWidth = 0;486 ULONG ulHeight = 0;487 ULONG ulBitsPerPixel = 0;488 ULONG ulBytesPerLine = 0;489 ULONG ulPixelFormat = 0;490 m_sourceBitmap.QueryBitmapInfo(pAddress,491 ulWidth,492 ulHeight,493 ulBitsPerPixel,494 ulBytesPerLine,495 ulPixelFormat);496 497 497 /* Perform frame-buffer resize: */ 498 UIResizeEvent e(FramebufferPixelFormat_Opaque, pAddress, 499 ulBitsPerPixel, ulBytesPerLine, ulWidth, ulHeight); 500 resizeEvent(&e); 498 resizeEvent(iWidth, iHeight); 499 } 500 501 void UIFrameBuffer::resizeEvent(int iWidth, int iHeight) 502 { 503 LogRel(("UIFrameBuffer::resizeEvent: Size=%dx%d\n", iWidth, iHeight)); 504 505 /* Make sure machine-view is assigned: */ 506 AssertPtrReturnVoid(m_pMachineView); 507 508 /* Invalidate visible-region (if necessary): */ 509 if (m_pMachineView->machineLogic()->visualStateType() == UIVisualStateType_Seamless && 510 (m_iWidth != iWidth || m_iHeight != iHeight)) 511 { 512 lock(); 513 m_syncVisibleRegion = QRegion(); 514 m_asyncVisibleRegion = QRegion(); 515 unlock(); 516 } 517 518 /* If source-bitmap invalid: */ 519 if (m_sourceBitmap.isNull()) 520 { 521 LogRel(("UIFrameBuffer::resizeEvent: " 522 "Using FALLBACK buffer due to source-bitmap is not provided..\n")); 523 524 /* Remember new size came from hint: */ 525 m_iWidth = iWidth; 526 m_iHeight = iHeight; 527 528 /* And go fallback: */ 529 goFallback(); 530 } 531 /* If source-bitmap valid: */ 532 else 533 { 534 LogRel(("UIFrameBuffer::resizeEvent: " 535 "Directly using source-bitmap content..\n")); 536 537 /* Acquire source-bitmap attributes: */ 538 BYTE *pAddress = NULL; 539 ULONG ulWidth = 0; 540 ULONG ulHeight = 0; 541 ULONG ulBitsPerPixel = 0; 542 ULONG ulBytesPerLine = 0; 543 ULONG ulPixelFormat = 0; 544 m_sourceBitmap.QueryBitmapInfo(pAddress, 545 ulWidth, 546 ulHeight, 547 ulBitsPerPixel, 548 ulBytesPerLine, 549 ulPixelFormat); 550 Assert(ulBitsPerPixel == 32); 551 552 /* Remember new actual size: */ 553 m_iWidth = (int)ulWidth; 554 m_iHeight = (int)ulHeight; 555 556 /* Recreate QImage on the basis of source-bitmap content: */ 557 m_image = QImage(pAddress, m_iWidth, m_iHeight, ulBytesPerLine, QImage::Format_RGB32); 558 559 /* Check whether guest color depth differs from the bitmap color depth: */ 560 ULONG ulGuestBitsPerPixel = 0; 561 LONG xOrigin = 0; 562 LONG yOrigin = 0; 563 CDisplay display = m_pMachineView->uisession()->session().GetConsole().GetDisplay(); 564 display.GetScreenResolution(m_pMachineView->screenId(), 565 ulWidth, ulHeight, ulGuestBitsPerPixel, xOrigin, yOrigin); 566 567 /* Remind user if necessary: */ 568 if ( ulGuestBitsPerPixel != ulBitsPerPixel 569 && m_pMachineView->uisession()->isGuestAdditionsActive()) 570 popupCenter().remindAboutWrongColorDepth(m_pMachineView->machineWindow(), 571 ulGuestBitsPerPixel, ulBitsPerPixel); 572 else 573 popupCenter().forgetAboutWrongColorDepth(m_pMachineView->machineWindow()); 574 } 575 576 /* Enable screen updates: */ 577 lock(); 578 m_fUpdatesAllowed = true; 579 unlock(); 580 } 581 582 void UIFrameBuffer::paintEvent(QPaintEvent *pEvent) 583 { 584 LogRel2(("UIFrameBuffer::paintEvent: Origin=%lux%lu, Size=%dx%d\n", 585 pEvent->rect().x(), pEvent->rect().y(), 586 pEvent->rect().width(), pEvent->rect().height())); 587 588 /* On mode switch the enqueued paint-event may still come 589 * while the machine-view is already null (before the new machine-view set), 590 * ignore paint-event in that case. */ 591 if (!m_pMachineView) 592 return; 593 594 /* Lock access to frame-buffer: */ 595 lock(); 596 597 /* But if updates disabled: */ 598 if (!m_fUpdatesAllowed) 599 { 600 /* Unlock access to frame-buffer: */ 601 unlock(); 602 /* And return immediately: */ 603 return; 604 } 605 606 /* If the machine is NOT in 'running', 'paused' or 'saving' state, 607 * the link between the framebuffer and the video memory is broken. 608 * We should go fallback in that case. 609 * We should acquire actual machine-state to exclude 610 * situations when the state was changed already but 611 * GUI didn't received event about that or didn't processed it yet. */ 612 KMachineState machineState = m_pMachineView->uisession()->session().GetConsole().GetState(); 613 if (/* running */ 614 machineState != KMachineState_Running 615 && machineState != KMachineState_Teleporting 616 && machineState != KMachineState_LiveSnapshotting 617 && machineState != KMachineState_DeletingSnapshotOnline 618 /* paused */ 619 && machineState != KMachineState_Paused 620 && machineState != KMachineState_TeleportingPausedVM 621 /* saving */ 622 && machineState != KMachineState_Saving 623 /* guru */ 624 && machineState != KMachineState_Stuck 625 ) 626 { 627 LogRel(("UIFrameBuffer::paintEvent: " 628 "Using FALLBACK buffer due to machine-state become invalid: " 629 "%d.\n", (int)machineState)); 630 631 /* Go fallback: */ 632 goFallback(); 633 } 634 635 /* Depending on visual-state type: */ 636 switch (m_pMachineView->machineLogic()->visualStateType()) 637 { 638 case UIVisualStateType_Seamless: 639 paintSeamless(pEvent); 640 break; 641 case UIVisualStateType_Scale: 642 paintScaled(pEvent); 643 break; 644 default: 645 paintDefault(pEvent); 646 break; 647 } 648 649 /* Unlock access to frame-buffer: */ 650 unlock(); 501 651 } 502 652 … … 533 683 void UIFrameBuffer::prepareConnections() 534 684 { 535 connect(this, SIGNAL(sigNotifyChange( ulong,int, int)),536 m_pMachineView, SLOT(sltHandleNotifyChange( ulong,int, int)),685 connect(this, SIGNAL(sigNotifyChange(int, int)), 686 m_pMachineView, SLOT(sltHandleNotifyChange(int, int)), 537 687 Qt::QueuedConnection); 538 688 connect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)), … … 549 699 void UIFrameBuffer::cleanupConnections() 550 700 { 551 disconnect(this, SIGNAL(sigNotifyChange( ulong,int, int)),552 m_pMachineView, SLOT(sltHandleNotifyChange( ulong,int, int)));701 disconnect(this, SIGNAL(sigNotifyChange(int, int)), 702 m_pMachineView, SLOT(sltHandleNotifyChange(int, int))); 553 703 disconnect(this, SIGNAL(sigNotifyUpdate(int, int, int, int)), 554 704 m_pMachineView, SLOT(sltHandleNotifyUpdate(int, int, int, int))); … … 559 709 } 560 710 711 void UIFrameBuffer::paintDefault(QPaintEvent *pEvent) 712 { 713 /* Get rectangle to paint: */ 714 QRect paintRect = pEvent->rect().intersected(m_image.rect()).intersected(m_pMachineView->viewport()->geometry()); 715 if (paintRect.isEmpty()) 716 return; 717 718 /* Create painter: */ 719 QPainter painter(m_pMachineView->viewport()); 720 721 /* Draw image rectangle: */ 722 drawImageRect(painter, m_image, paintRect, 723 m_pMachineView->contentsX(), m_pMachineView->contentsY(), 724 hiDPIOptimizationType(), backingScaleFactor()); 725 } 726 727 void UIFrameBuffer::paintSeamless(QPaintEvent *pEvent) 728 { 729 /* Get rectangle to paint: */ 730 QRect paintRect = pEvent->rect().intersected(m_image.rect()).intersected(m_pMachineView->viewport()->geometry()); 731 if (paintRect.isEmpty()) 732 return; 733 734 /* Create painter: */ 735 QPainter painter(m_pMachineView->viewport()); 736 737 /* Determine the region to erase: */ 738 lock(); 739 QRegion regionToErase = (QRegion)paintRect - m_syncVisibleRegion; 740 unlock(); 741 if (!regionToErase.isEmpty()) 742 { 743 /* Optimize composition-mode: */ 744 painter.setCompositionMode(QPainter::CompositionMode_Clear); 745 /* Erase required region, slowly, rectangle-by-rectangle: */ 746 foreach (const QRect &rect, regionToErase.rects()) 747 painter.eraseRect(rect); 748 /* Restore composition-mode: */ 749 painter.setCompositionMode(QPainter::CompositionMode_SourceOver); 750 } 751 752 /* Determine the region to paint: */ 753 lock(); 754 QRegion regionToPaint = (QRegion)paintRect & m_syncVisibleRegion; 755 unlock(); 756 if (!regionToPaint.isEmpty()) 757 { 758 /* Paint required region, slowly, rectangle-by-rectangle: */ 759 foreach (const QRect &rect, regionToPaint.rects()) 760 { 761 #if defined(VBOX_WITH_TRANSLUCENT_SEAMLESS) && defined(Q_WS_WIN) 762 /* Replace translucent background with black one, 763 * that is necessary for window with Qt::WA_TranslucentBackground: */ 764 painter.setCompositionMode(QPainter::CompositionMode_Source); 765 painter.fillRect(rect, QColor(Qt::black)); 766 painter.setCompositionMode(QPainter::CompositionMode_SourceAtop); 767 #endif /* VBOX_WITH_TRANSLUCENT_SEAMLESS && Q_WS_WIN */ 768 769 /* Draw image rectangle: */ 770 drawImageRect(painter, m_image, rect, 771 m_pMachineView->contentsX(), m_pMachineView->contentsY(), 772 hiDPIOptimizationType(), backingScaleFactor()); 773 } 774 } 775 } 776 777 void UIFrameBuffer::paintScaled(QPaintEvent *pEvent) 778 { 779 /* Scaled image is NULL by default: */ 780 QImage scaledImage; 781 /* But if scaled-factor is set and current image is NOT null: */ 782 if (m_scaledSize.isValid() && !m_image.isNull()) 783 { 784 /* We are doing a deep copy of the image to make sure it will not be 785 * detached during scale process, otherwise we can get a frozen frame-buffer. */ 786 scaledImage = m_image.copy(); 787 /* And scaling the image to predefined scaled-factor: */ 788 scaledImage = scaledImage.scaled(m_scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 789 } 790 /* Finally we are choosing image to paint from: */ 791 QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage; 792 793 /* Get rectangle to paint: */ 794 QRect paintRect = pEvent->rect().intersected(sourceImage.rect()).intersected(m_pMachineView->viewport()->geometry()); 795 if (paintRect.isEmpty()) 796 return; 797 798 /* Create painter: */ 799 QPainter painter(m_pMachineView->viewport()); 800 801 /* Draw image rectangle: */ 802 drawImageRect(painter, sourceImage, paintRect, 803 m_pMachineView->contentsX(), m_pMachineView->contentsY(), 804 hiDPIOptimizationType(), backingScaleFactor()); 805 } 806 807 /* static */ 808 void UIFrameBuffer::drawImageRect(QPainter &painter, const QImage &image, const QRect &rect, 809 int iContentsShiftX, int iContentsShiftY, 810 HiDPIOptimizationType hiDPIOptimizationType, 811 double dBackingScaleFactor) 812 { 813 /* Calculate offset: */ 814 size_t offset = (rect.x() + iContentsShiftX) * image.depth() / 8 + 815 (rect.y() + iContentsShiftY) * image.bytesPerLine(); 816 817 /* Restrain boundaries: */ 818 int iSubImageWidth = qMin(rect.width(), image.width() - rect.x() - iContentsShiftX); 819 int iSubImageHeight = qMin(rect.height(), image.height() - rect.y() - iContentsShiftY); 820 821 /* Create sub-image (no copy involved): */ 822 QImage subImage = QImage(image.bits() + offset, 823 iSubImageWidth, iSubImageHeight, 824 image.bytesPerLine(), image.format()); 825 826 #ifndef QIMAGE_FRAMEBUFFER_WITH_DIRECT_OUTPUT 827 /* Create sub-pixmap on the basis of sub-image above (1st copy involved): */ 828 QPixmap subPixmap = QPixmap::fromImage(subImage); 829 830 /* If HiDPI 'backing scale factor' defined: */ 831 if (dBackingScaleFactor > 1.0) 832 { 833 /* Should we optimize HiDPI output for performance? */ 834 if (hiDPIOptimizationType == HiDPIOptimizationType_Performance) 835 { 836 /* Fast scale sub-pixmap (2nd copy involved): */ 837 subPixmap = subPixmap.scaled(subPixmap.size() * dBackingScaleFactor, 838 Qt::IgnoreAspectRatio, Qt::FastTransformation); 839 # ifdef Q_WS_MAC 840 # ifdef VBOX_GUI_WITH_HIDPI 841 /* Mark sub-pixmap as HiDPI: */ 842 subPixmap.setDevicePixelRatio(dBackingScaleFactor); 843 # endif /* VBOX_GUI_WITH_HIDPI */ 844 # endif /* Q_WS_MAC */ 845 } 846 } 847 848 /* Draw sub-pixmap: */ 849 painter.drawPixmap(rect.x(), rect.y(), subPixmap); 850 #else /* QIMAGE_FRAMEBUFFER_WITH_DIRECT_OUTPUT */ 851 /* If HiDPI 'backing scale factor' defined: */ 852 if (dBackingScaleFactor > 1.0) 853 { 854 /* Should we optimize HiDPI output for performance? */ 855 if (hiDPIOptimizationType == HiDPIOptimizationType_Performance) 856 { 857 /* Create fast-scaled-sub-image (1st copy involved): */ 858 QImage scaledSubImage = subImage.scaled(subImage.size() * dBackingScaleFactor, 859 Qt::IgnoreAspectRatio, Qt::FastTransformation); 860 # ifdef Q_WS_MAC 861 # ifdef VBOX_GUI_WITH_HIDPI 862 /* Mark sub-pixmap as HiDPI: */ 863 scaledSubImage.setDevicePixelRatio(dBackingScaleFactor); 864 # endif /* VBOX_GUI_WITH_HIDPI */ 865 # endif /* Q_WS_MAC */ 866 /* Directly draw scaled-sub-image: */ 867 painter.drawImage(rect.x(), rect.y(), scaledSubImage); 868 return; 869 } 870 } 871 /* Directly draw sub-image: */ 872 painter.drawImage(rect.x(), rect.y(), subImage); 873 #endif /* QIMAGE_FRAMEBUFFER_WITH_DIRECT_OUTPUT */ 874 } 875 876 void UIFrameBuffer::goFallback() 877 { 878 /* We are going for FALLBACK buffer when: 879 * 1. Display did not provide the source-bitmap; 880 * 2. or the machine is in the state which breaks link between 881 * the framebuffer and the actual video-memory: */ 882 m_image = QImage(m_iWidth, m_iHeight, QImage::Format_RGB32); 883 m_image.fill(0); 884 } 885 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h
r51487 r51493 20 20 /* Qt includes: */ 21 21 #include <QRegion> 22 #include <QImage> 22 23 23 24 /* GUI includes: */ … … 37 38 class UIMachineView; 38 39 39 /** Frame-buffer resize-event. */40 class UIResizeEvent : public QEvent41 {42 public:43 44 UIResizeEvent(ulong uPixelFormat, uchar *pVRAM,45 ulong uBitsPerPixel, ulong uBytesPerLine,46 ulong uWidth, ulong uHeight)47 : QEvent((QEvent::Type)ResizeEventType)48 , m_uPixelFormat(uPixelFormat), m_pVRAM(pVRAM), m_uBitsPerPixel(uBitsPerPixel)49 , m_uBytesPerLine(uBytesPerLine), m_uWidth(uWidth), m_uHeight(uHeight) {}50 ulong pixelFormat() { return m_uPixelFormat; }51 uchar *VRAM() { return m_pVRAM; }52 ulong bitsPerPixel() { return m_uBitsPerPixel; }53 ulong bytesPerLine() { return m_uBytesPerLine; }54 ulong width() { return m_uWidth; }55 ulong height() { return m_uHeight; }56 57 private:58 59 ulong m_uPixelFormat;60 uchar *m_pVRAM;61 ulong m_uBitsPerPixel;62 ulong m_uBytesPerLine;63 ulong m_uWidth;64 ulong m_uHeight;65 };66 67 40 /** Common IFramebuffer implementation used to maintain VM display video memory. */ 68 41 class UIFrameBuffer : public QObject, VBOX_SCRIPTABLE_IMPL(IFramebuffer) … … 73 46 74 47 /** Notifies listener about guest-screen resolution changes. */ 75 void sigNotifyChange( ulong uScreenId,int iWidth, int iHeight);48 void sigNotifyChange(int iWidth, int iHeight); 76 49 /** Notifies listener about guest-screen updates. */ 77 50 void sigNotifyUpdate(int iX, int iY, int iWidth, int iHeight); … … 190 163 191 164 /** Returns frame-buffer data address. */ 192 virtual uchar *address() = 0;165 uchar *address() { return m_image.bits(); } 193 166 /** Returns frame-buffer width. */ 194 ulong width() { return m_ width; }167 ulong width() { return m_iWidth; } 195 168 /** Returns frame-buffer height. */ 196 ulong height() { return m_ height; }169 ulong height() { return m_iHeight; } 197 170 /** Returns frame-buffer bits-per-pixel value. */ 198 virtual ulong bitsPerPixel() = 0;171 ulong bitsPerPixel() { return m_image.depth(); } 199 172 /** Returns frame-buffer bytes-per-line value. */ 200 virtual ulong bytesPerLine() = 0;173 ulong bytesPerLine() { return m_image.bytesPerLine(); } 201 174 /** Returns default frame-buffer pixel-format. */ 202 virtualulong pixelFormat() { return FramebufferPixelFormat_FOURCC_RGB; }175 ulong pixelFormat() { return FramebufferPixelFormat_FOURCC_RGB; } 203 176 204 177 /** Locks frame-buffer access. */ … … 212 185 void setScaledSize(const QSize &size = QSize()) { m_scaledSize = size; } 213 186 /** Returns x-origin of the host (scaled) content corresponding to x-origin of guest (actual) content. */ 214 inline int convertGuestXTo(int x) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.width() / m_ width * x) : x; }187 inline int convertGuestXTo(int x) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.width() / m_iWidth * x) : x; } 215 188 /** Returns y-origin of the host (scaled) content corresponding to y-origin of guest (actual) content. */ 216 inline int convertGuestYTo(int y) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.height() / m_ height * y) : y; }189 inline int convertGuestYTo(int y) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.height() / m_iHeight * y) : y; } 217 190 /** Returns x-origin of the guest (actual) content corresponding to x-origin of host (scaled) content. */ 218 inline int convertHostXTo(int x) const { return m_scaledSize.isValid() ? qRound((double)m_ width / m_scaledSize.width() * x) : x; }191 inline int convertHostXTo(int x) const { return m_scaledSize.isValid() ? qRound((double)m_iWidth / m_scaledSize.width() * x) : x; } 219 192 /** Returns y-origin of the guest (actual) content corresponding to y-origin of host (scaled) content. */ 220 inline int convertHostYTo(int y) const { return m_scaledSize.isValid() ? qRound((double)m_ height / m_scaledSize.height() * y) : y; }193 inline int convertHostYTo(int y) const { return m_scaledSize.isValid() ? qRound((double)m_iHeight / m_scaledSize.height() * y) : y; } 221 194 222 195 /** Handles frame-buffer notify-change-event. */ 223 v oid notifyChange();196 virtual void notifyChange(int iWidth, int iHeight); 224 197 /** Handles frame-buffer resize-event. */ 225 virtual void resizeEvent( UIResizeEvent *pEvent) = 0;198 virtual void resizeEvent(int iWidth, int iHeight); 226 199 /** Handles frame-buffer paint-event. */ 227 virtual void paintEvent(QPaintEvent *pEvent) = 0;200 virtual void paintEvent(QPaintEvent *pEvent); 228 201 /** Handles frame-buffer apply-visible-region-event. */ 229 v oid applyVisibleRegion(const QRegion ®ion);202 virtual void applyVisibleRegion(const QRegion ®ion); 230 203 231 204 #ifdef VBOX_WITH_VIDEOHWACCEL … … 250 223 protected: 251 224 252 /** Machine-view this frame-buffer is bounded to. */ 225 /** Prepare connections routine. */ 226 void prepareConnections(); 227 /** Cleanup connections routine. */ 228 void cleanupConnections(); 229 230 /** Default paint routine. */ 231 void paintDefault(QPaintEvent *pEvent); 232 /** Paint routine for seamless mode. */ 233 void paintSeamless(QPaintEvent *pEvent); 234 /** Paint routine for scaled mode. */ 235 void paintScaled(QPaintEvent *pEvent); 236 237 /** Draws corresponding @a rect of passed @a image with @a painter. */ 238 static void drawImageRect(QPainter &painter, const QImage &image, const QRect &rect, 239 int iContentsShiftX, int iContentsShiftY, 240 HiDPIOptimizationType hiDPIOptimizationType, 241 double dBackingScaleFactor); 242 243 /** Recreates own clean QImage buffer. */ 244 void goFallback(); 245 246 /** Holds the QImage buffer. */ 247 QImage m_image; 248 /** Holds frame-buffer width. */ 249 int m_iWidth; 250 /** Holds frame-buffer height. */ 251 int m_iHeight; 252 253 /** Source bitmap from IDisplay. */ 254 CDisplaySourceBitmap m_sourceBitmap; 255 /** Source bitmap from IDisplay (acquired but not yet applied). */ 256 CDisplaySourceBitmap m_pendingSourceBitmap; 257 258 /** Holds machine-view this frame-buffer is bounded to. */ 253 259 UIMachineView *m_pMachineView; 254 /** Cached window ID. */ 255 int64_t m_winId; 256 /** RTCRITSECT object to protect frame-buffer access. */ 257 mutable RTCRITSECT m_critSect; 258 /** Frame-buffer width. */ 259 ulong m_width; 260 /** Frame-buffer height. */ 261 ulong m_height; 262 /** Frame-buffer scaled size. */ 263 QSize m_scaledSize; 260 /** Holds window ID this frame-buffer referring to. */ 261 int64_t m_iWinId; 262 263 /** Reflects whether screen-updates are allowed. */ 264 bool m_fUpdatesAllowed; 265 264 266 /** Defines whether frame-buffer is <b>unused</b>. 265 267 * <b>Unused</b> status determines whether frame-buffer should ignore EMT events or not. */ 266 268 bool m_fUnused; 269 267 270 /** Defines whether frame-buffer is <b>auto-enabled</b>. 268 271 * <b>Auto-enabled</b> status means that guest-screen corresponding to this frame-buffer … … 272 275 bool m_fAutoEnabled; 273 276 274 /** Source bitmap from IDisplay. */ 275 CDisplaySourceBitmap m_sourceBitmap; 276 /** Source bitmap from IDisplay (acquired but not yet applied). */ 277 CDisplaySourceBitmap m_pendingSourceBitmap; 278 /** Reflects whether screen-updates are allowed. */ 279 bool m_fIsUpdatesAllowed; 280 277 /** RTCRITSECT object to protect frame-buffer access. */ 278 mutable RTCRITSECT m_critSect; 279 280 #ifdef Q_OS_WIN 281 /** Windows: Holds the reference counter. */ 282 long m_iRefCnt; 283 #endif /* Q_OS_WIN */ 284 285 /** @name Scaled mode related variables. 286 * @{ */ 287 /** Holds frame-buffer scaled size. */ 288 QSize m_scaledSize; 289 /** @} */ 290 291 /** @name Seamless mode related variables. 292 * @{ */ 281 293 /* To avoid a seamless flicker which caused by the latency between 282 294 * the initial visible-region arriving from EMT thread … … 290 302 * because NotifyUpdate doesn't take into account these changes. */ 291 303 QRegion m_asyncVisibleRegion; 292 293 private: 294 295 /** Prepare connections routine. */ 296 void prepareConnections(); 297 /** Cleanup connections routine. */ 298 void cleanupConnections(); 299 300 #ifdef Q_OS_WIN 301 /** Windows: Holds the reference counter. */ 302 long m_iRefCnt; 303 #endif /* Q_OS_WIN */ 304 304 /** @} */ 305 306 /** @name HiDPI screens related variables. 307 * @{ */ 305 308 /** Holds HiDPI frame-buffer optimization type. */ 306 309 HiDPIOptimizationType m_hiDPIOptimizationType; 307 308 310 /** Holds backing scale factor used by HiDPI frame-buffer. */ 309 311 double m_dBackingScaleFactor; 312 /** @} */ 310 313 }; 311 314 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r51487 r51493 35 35 #include "UIMessageCenter.h" 36 36 #include "UIFrameBuffer.h" 37 #include "UIFrameBufferQImage.h"38 37 #include "VBoxFBOverlay.h" 39 38 #include "UISession.h" … … 217 216 } 218 217 219 void UIMachineView::sltHandleNotifyChange( ulong uScreenId,int iWidth, int iHeight)218 void UIMachineView::sltHandleNotifyChange(int iWidth, int iHeight) 220 219 { 221 220 LogRelFlow(("UIMachineView::HandleNotifyChange: Screen=%d, Size=%dx%d.\n", … … 237 236 238 237 /* Perform frame-buffer mode-change: */ 239 frameBuffer()->notifyChange( );238 frameBuffer()->notifyChange(iWidth, iHeight); 240 239 241 240 /* Scale-mode doesn't need this.. */ … … 410 409 * this [VBox|UI] duplication 411 410 * @todo: they are to be removed once VBox stuff is gone */ 412 pFrameBuffer = new VBoxOverlayFrameBuffer<UIFrameBuffer QImage, UIMachineView, UIResizeEvent>(this, &session(), (uint32_t)screenId());411 pFrameBuffer = new VBoxOverlayFrameBuffer<UIFrameBuffer, UIMachineView>(this, &session(), (uint32_t)screenId()); 413 412 } 414 413 else 415 pFrameBuffer = new UIFrameBuffer QImage(this);414 pFrameBuffer = new UIFrameBuffer(this); 416 415 # else /* VBOX_WITH_VIDEOHWACCEL */ 417 pFrameBuffer = new UIFrameBuffer QImage(this);416 pFrameBuffer = new UIFrameBuffer(this); 418 417 # endif /* !VBOX_WITH_VIDEOHWACCEL */ 419 418 pFrameBuffer->setHiDPIOptimizationType(uisession()->hiDPIOptimizationType()); … … 468 467 } 469 468 /* If we have a valid size, resize the framebuffer. */ 470 if ( size.width() > 0 471 && size.height() > 0) 472 { 473 UIResizeEvent event(FramebufferPixelFormat_Opaque, NULL, 0, 0, size.width(), size.height()); 474 frameBuffer()->resizeEvent(&event); 475 } 469 if (size.width() > 0 && size.height() > 0) 470 frameBuffer()->resizeEvent(size.width(), size.height()); 476 471 } 477 472 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r51487 r51493 97 97 98 98 /* Handler: Frame-buffer NotifyChange stuff: */ 99 virtual void sltHandleNotifyChange( ulong uScreenId,int iWidth, int iHeight);99 virtual void sltHandleNotifyChange(int iWidth, int iHeight); 100 100 101 101 /* Handler: Frame-buffer NotifyUpdate stuff: */ … … 263 263 friend class UIMachineLogic; 264 264 friend class UIFrameBuffer; 265 friend class UIFrameBufferQImage; 266 template<class, class, class> friend class VBoxOverlayFrameBuffer; 265 template<class, class> friend class VBoxOverlayFrameBuffer; 267 266 }; 268 267 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp
r51484 r51493 30 30 #include "UIMachineViewScale.h" 31 31 #include "UIFrameBuffer.h" 32 #include "UIFrameBufferQImage.h"33 32 34 33 /* COM includes: */
Note:
See TracChangeset
for help on using the changeset viewer.