Index: /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp	(revision 53371)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp	(revision 53372)
@@ -136,4 +136,5 @@
 const char* UIExtraDataDefs::GUI_GuruMeditationHandler = "GUI/GuruMeditationHandler";
 const char* UIExtraDataDefs::GUI_HidLedsSync = "GUI/HidLedsSync";
+const char* UIExtraDataDefs::GUI_ScaleFactor = "GUI/ScaleFactor";
 
 /* Virtual Machine: Information dialog: */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h	(revision 53371)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h	(revision 53372)
@@ -237,4 +237,6 @@
         /** Holds whether machine should perform HID LEDs synchronization. */
         extern const char* GUI_HidLedsSync;
+        /** Holds the scale-factor. */
+        extern const char* GUI_ScaleFactor;
     /** @} */
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp	(revision 53371)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp	(revision 53372)
@@ -1792,4 +1792,5 @@
            << GUI_GuruMeditationHandler
            << GUI_HidLedsSync
+           << GUI_ScaleFactor
            << GUI_InformationWindowGeometry
            << GUI_DefaultCloseAction << GUI_RestrictedCloseActions
@@ -3255,4 +3256,21 @@
     /* 'True' unless feature restricted: */
     return !isFeatureRestricted(GUI_HidLedsSync, strID);
+}
+
+double UIExtraDataManager::scaleFactor(const QString &strID)
+{
+    /* Get corresponding extra-data value: */
+    const QString strValue = extraDataString(GUI_ScaleFactor, strID);
+
+    /* Try to convert loaded data to double: */
+    bool fOk = false;
+    double dValue = strValue.toDouble(&fOk);
+
+    /* Invent the default value: */
+    if (!fOk || !dValue)
+        dValue = 1;
+
+    /* Return value: */
+    return dValue;
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h	(revision 53371)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h	(revision 53372)
@@ -450,4 +450,7 @@
         /** Returns whether machine should perform HID LEDs synchronization. */
         bool hidLedsSyncState(const QString &strID);
+
+        /** Returns scale-factor. */
+        double scaleFactor(const QString &strID);
     /** @} */
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp	(revision 53371)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp	(revision 53372)
@@ -28,4 +28,5 @@
 # include "UIMachineView.h"
 # include "UIPopupCenter.h"
+# include "UIExtraDataManager.h"
 # include "VBoxGlobal.h"
 # ifdef VBOX_WITH_MASKED_SEAMLESS
@@ -61,4 +62,5 @@
     , m_fUnused(false)
     , m_fAutoEnabled(false)
+    , m_dScaleFactor(gEDataManager->scaleFactor(vboxGlobal().managedVMUuid()))
     , m_hiDPIOptimizationType(HiDPIOptimizationType_None)
     , m_dBackingScaleFactor(1.0)
@@ -469,4 +471,8 @@
         rect.setRight(rects->xRight - 1);
         rect.setBottom(rects->yBottom - 1);
+        /* Tune according scale-factor: */
+        // TODO: Take rounding into account..
+        rect.moveTo(rect.topLeft() * m_dScaleFactor);
+        rect.setSize(rect.size() * m_dScaleFactor);
         /* Append region: */
         region += rect;
@@ -719,7 +725,4 @@
             paintSeamless(pEvent);
             break;
-        case UIVisualStateType_Scale:
-            paintScaled(pEvent);
-            break;
         default:
             paintDefault(pEvent);
@@ -791,6 +794,20 @@
 void UIFrameBuffer::paintDefault(QPaintEvent *pEvent)
 {
+    /* Scaled image is NULL by default: */
+    QImage scaledImage;
+    /* But if scaled-factor is set and current image is NOT null: */
+    if (m_scaledSize.isValid() && !m_image.isNull())
+    {
+        /* We are doing a deep copy of the image to make sure it will not be
+         * detached during scale process, otherwise we can get a frozen frame-buffer. */
+        scaledImage = m_image.copy();
+        /* And scaling the image to predefined scaled-factor: */
+        scaledImage = scaledImage.scaled(m_scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+    }
+    /* Finally we are choosing image to paint from: */
+    const QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage;
+
     /* Get rectangle to paint: */
-    QRect paintRect = pEvent->rect().intersected(m_image.rect()).intersected(m_pMachineView->viewport()->geometry());
+    QRect paintRect = pEvent->rect().intersected(sourceImage.rect()).intersected(m_pMachineView->viewport()->geometry());
     if (paintRect.isEmpty())
         return;
@@ -800,5 +817,5 @@
 
     /* Draw image rectangle: */
-    drawImageRect(painter, m_image, paintRect,
+    drawImageRect(painter, sourceImage, paintRect,
                   m_pMachineView->contentsX(), m_pMachineView->contentsY(),
                   hiDPIOptimizationType(), backingScaleFactor());
@@ -807,6 +824,20 @@
 void UIFrameBuffer::paintSeamless(QPaintEvent *pEvent)
 {
+    /* Scaled image is NULL by default: */
+    QImage scaledImage;
+    /* But if scaled-factor is set and current image is NOT null: */
+    if (m_scaledSize.isValid() && !m_image.isNull())
+    {
+        /* We are doing a deep copy of the image to make sure it will not be
+         * detached during scale process, otherwise we can get a frozen frame-buffer. */
+        scaledImage = m_image.copy();
+        /* And scaling the image to predefined scaled-factor: */
+        scaledImage = scaledImage.scaled(m_scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+    }
+    /* Finally we are choosing image to paint from: */
+    const QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage;
+
     /* Get rectangle to paint: */
-    QRect paintRect = pEvent->rect().intersected(m_image.rect()).intersected(m_pMachineView->viewport()->geometry());
+    QRect paintRect = pEvent->rect().intersected(sourceImage.rect()).intersected(m_pMachineView->viewport()->geometry());
     if (paintRect.isEmpty())
         return;
@@ -851,39 +882,9 @@
 
             /* Draw image rectangle: */
-            drawImageRect(painter, m_image, rect,
+            drawImageRect(painter, sourceImage, rect,
                           m_pMachineView->contentsX(), m_pMachineView->contentsY(),
                           hiDPIOptimizationType(), backingScaleFactor());
         }
     }
-}
-
-void UIFrameBuffer::paintScaled(QPaintEvent *pEvent)
-{
-    /* Scaled image is NULL by default: */
-    QImage scaledImage;
-    /* But if scaled-factor is set and current image is NOT null: */
-    if (m_scaledSize.isValid() && !m_image.isNull())
-    {
-        /* We are doing a deep copy of the image to make sure it will not be
-         * detached during scale process, otherwise we can get a frozen frame-buffer. */
-        scaledImage = m_image.copy();
-        /* And scaling the image to predefined scaled-factor: */
-        scaledImage = scaledImage.scaled(m_scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
-    }
-    /* Finally we are choosing image to paint from: */
-    QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage;
-
-    /* Get rectangle to paint: */
-    QRect paintRect = pEvent->rect().intersected(sourceImage.rect()).intersected(m_pMachineView->viewport()->geometry());
-    if (paintRect.isEmpty())
-        return;
-
-    /* Create painter: */
-    QPainter painter(m_pMachineView->viewport());
-
-    /* Draw image rectangle: */
-    drawImageRect(painter, sourceImage, paintRect,
-                  m_pMachineView->contentsX(), m_pMachineView->contentsY(),
-                  hiDPIOptimizationType(), backingScaleFactor());
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h	(revision 53371)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h	(revision 53372)
@@ -234,6 +234,4 @@
     /** Paint routine for seamless mode. */
     void paintSeamless(QPaintEvent *pEvent);
-    /** Paint routine for scaled mode. */
-    void paintScaled(QPaintEvent *pEvent);
 
     /** Draws corresponding @a rect of passed @a image with @a painter. */
@@ -277,7 +275,9 @@
     mutable RTCRITSECT m_critSect;
 
-    /** @name Scaled mode related variables.
+    /** @name Scale-factor related variables.
      * @{ */
-    /** Holds frame-buffer scaled size. */
+    /** Holds the scale-factor used by the scaled-size. */
+    const double m_dScaleFactor;
+    /** Holds the frame-buffer's scaled-size. */
     QSize m_scaledSize;
     /** @} */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 53371)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 53372)
@@ -185,4 +185,8 @@
     AssertMsg(newSize.isValid(), ("Size should be valid!\n"));
 
+    /* Take the scale-factor into account: */
+    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
+    newSize /= dScaleFactor;
+
     /* Expand current limitations: */
     setMaxGuestSize(newSize);
@@ -224,4 +228,11 @@
             frameBuffer()->setScaledSize(size());
         }
+        /* Adjust other modes to current NotifyChange event size: */
+        else
+        {
+            /* Assign new frame-buffer logical-size taking the scale-factor into account: */
+            const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
+            frameBuffer()->setScaledSize(dScaleFactor == 1 ? QSize() : QSize(iWidth * dScaleFactor, iHeight * dScaleFactor));
+        }
 
         /* Perform frame-buffer mode-change: */
@@ -271,6 +282,23 @@
 void UIMachineView::sltHandleNotifyUpdate(int iX, int iY, int iWidth, int iHeight)
 {
-    /* Update corresponding viewport part: */
-    viewport()->update(iX - contentsX(), iY - contentsY(), iWidth, iHeight);
+    /* Take the scale-factor into account: */
+    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
+    if (dScaleFactor == 1)
+    {
+        /* Just update corresponding viewport part: */
+        viewport()->update(iX - contentsX(), iY - contentsY(), iWidth, iHeight);
+    }
+    else
+    {
+        /* Calculate corresponding viewport part: */
+        QRect rect(iX * dScaleFactor - 1 - contentsX(),
+                   iY * dScaleFactor - 1 - contentsY(),
+                   iWidth  * dScaleFactor + 2 * dScaleFactor + 1,
+                   iHeight * dScaleFactor + 2 * dScaleFactor + 1);
+        /* Limit the resulting part by the viewport rectangle: */
+        rect &= viewport()->rect();
+        /* Update corresponding viewport part: */
+        viewport()->update(rect);
+    }
 }
 
@@ -392,4 +420,7 @@
 void UIMachineView::prepareFrameBuffer()
 {
+    /* Take scale-factor into account: */
+    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
+
     /* Prepare frame-buffer: */
     UIFrameBuffer *pFrameBuffer = uisession()->frameBuffer(screenId());
@@ -422,5 +453,7 @@
 # endif /* !VBOX_WITH_VIDEOHWACCEL */
         m_pFrameBuffer->setHiDPIOptimizationType(uisession()->hiDPIOptimizationType());
-
+        m_pFrameBuffer->setScaledSize(dScaleFactor == 1 ? QSize() :
+                                      QSize(m_pFrameBuffer->width() * dScaleFactor,
+                                            m_pFrameBuffer->height() * dScaleFactor));
         uisession()->setFrameBuffer(screenId(), m_pFrameBuffer);
     }
@@ -463,5 +496,10 @@
     /* If we have a valid size, resize the framebuffer. */
     if (size.width() > 0 && size.height() > 0)
+    {
         frameBuffer()->resizeEvent(size.width(), size.height());
+        frameBuffer()->setScaledSize(dScaleFactor == 1 ? QSize() :
+                                     QSize(frameBuffer()->width() * dScaleFactor,
+                                           frameBuffer()->height() * dScaleFactor));
+    }
 }
 
@@ -609,4 +647,8 @@
     QSize size(m_pFrameBuffer->width(), m_pFrameBuffer->height());
 
+    /* Take the scale-factor into account: */
+    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
+    size *= dScaleFactor;
+
 #ifdef VBOX_WITH_DEBUGGER_GUI
     // TODO: Fix all DEBUGGER stuff!
@@ -689,4 +731,8 @@
         size = QSize(800, 600);
 
+    /* Take the scale-factor into account: */
+    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
+    size *= dScaleFactor;
+
     /* Return size: */
     return size;
@@ -704,6 +750,7 @@
 void UIMachineView::resetPausePixmap()
 {
-    /* Reset pixmap: */
+    /* Reset pixmap(s): */
     m_pausePixmap = QPixmap();
+    m_pausePixmapScaled = QPixmap();
 }
 
@@ -737,4 +784,7 @@
     /* Finally copy the screen-shot to pause-pixmap: */
     m_pausePixmap = QPixmap::fromImage(screenShot);
+
+    /* Update scaled pause pixmap: */
+    updateScaledPausePixmap();
 }
 
@@ -763,4 +813,22 @@
     /* Finally copy the screen-shot to pause-pixmap: */
     m_pausePixmap = QPixmap::fromImage(screenShot);
+
+    /* Update scaled pause pixmap: */
+    updateScaledPausePixmap();
+}
+
+void UIMachineView::updateScaledPausePixmap()
+{
+    /* Make sure pause pixmap is not null: */
+    if (pausePixmap().isNull())
+        return;
+
+    /* Make sure scaled-size is not null: */
+    const QSize scaledSize = frameBuffer()->scaledSize();
+    if (!scaledSize.isValid())
+        return;
+
+    /* Update pause pixmap finally: */
+    m_pausePixmapScaled = pausePixmap().scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
 }
 
@@ -1001,6 +1069,12 @@
         QRect rect = pPaintEvent->rect().intersect(viewport()->rect());
         QPainter painter(viewport());
-        painter.drawPixmap(rect, pausePixmap(), QRect(rect.x() + contentsX(), rect.y() + contentsY(),
-                                                      rect.width(), rect.height()));
+        /* Take the scale-factor into account: */
+        const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
+        if (dScaleFactor == 1)
+            painter.drawPixmap(rect, pausePixmap(), QRect(rect.x() + contentsX(), rect.y() + contentsY(),
+                                                          rect.width(), rect.height()));
+        else
+            painter.drawPixmap(rect, pausePixmapScaled(), QRect(rect.x() + contentsX(), rect.y() + contentsY(),
+                                                                rect.width(), rect.height()));
 #ifdef Q_WS_MAC
         /* Update the dock icon: */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h	(revision 53371)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h	(revision 53372)
@@ -194,10 +194,14 @@
     /** Returns the pause-pixmap: */
     const QPixmap& pausePixmap() const { return m_pausePixmap; }
+    /** Returns the scaled pause-pixmap: */
+    const QPixmap& pausePixmapScaled() const { return m_pausePixmapScaled; }
     /** Resets the pause-pixmap. */
-    virtual void resetPausePixmap();
+    void resetPausePixmap();
     /** Acquires live pause-pixmap. */
-    virtual void takePausePixmapLive();
+    void takePausePixmapLive();
     /** Acquires snapshot pause-pixmap. */
-    virtual void takePausePixmapSnapshot();
+    void takePausePixmapSnapshot();
+    /** Updates the scaled pause-pixmap. */
+    void updateScaledPausePixmap();
 
     /** The available area on the current screen for application windows. */
@@ -275,4 +279,6 @@
     /** Holds the pause-pixmap. */
     QPixmap m_pausePixmap;
+    /** Holds the scaled pause-pixmap. */
+    QPixmap m_pausePixmapScaled;
 
     /* Friend classes: */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp	(revision 53371)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp	(revision 53372)
@@ -53,5 +53,4 @@
 #endif
                     )
-    , m_pPauseImage(0)
 {
     /* Resend the last resize hint if necessary: */
@@ -71,56 +70,4 @@
 }
 
-void UIMachineViewScale::takePausePixmapLive()
-{
-    /* Take a screen snapshot. Note that TakeScreenShot() always needs a 32bpp image: */
-    QImage shot = QImage(m_pFrameBuffer->width(), m_pFrameBuffer->height(), QImage::Format_RGB32);
-    /* If TakeScreenShot fails or returns no image, just show a black image. */
-    shot.fill(0);
-    display().TakeScreenShot(screenId(), shot.bits(), shot.width(), shot.height(), KBitmapFormat_BGR0);
-    m_pPauseImage = new QImage(shot);
-    scalePauseShot();
-}
-
-void UIMachineViewScale::takePausePixmapSnapshot()
-{
-    ULONG width = 0, height = 0;
-    QVector<BYTE> screenData = machine().ReadSavedScreenshotPNGToArray(0, width, height);
-    if (screenData.size() != 0)
-    {
-        ULONG guestOriginX = 0, guestOriginY = 0, guestWidth = 0, guestHeight = 0;
-        BOOL fEnabled = true;
-        machine().QuerySavedGuestScreenInfo(m_uScreenId, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
-        QImage shot = QImage::fromData(screenData.data(), screenData.size(), "PNG").scaled(guestWidth > 0 ? QSize(guestWidth, guestHeight) : guestSizeHint());
-        m_pPauseImage = new QImage(shot);
-        scalePauseShot();
-    }
-}
-
-void UIMachineViewScale::resetPausePixmap()
-{
-    /* Call the base class */
-    UIMachineView::resetPausePixmap();
-
-    if (m_pPauseImage)
-    {
-        delete m_pPauseImage;
-        m_pPauseImage = 0;
-    }
-}
-
-void UIMachineViewScale::scalePauseShot()
-{
-    if (m_pPauseImage)
-    {
-        QSize scaledSize = frameBuffer()->scaledSize();
-        if (scaledSize.isValid())
-        {
-            QImage tmpImg = m_pPauseImage->scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
-            dimImage(tmpImg);
-            m_pausePixmap = QPixmap::fromImage(tmpImg);
-        }
-    }
-}
-
 void UIMachineViewScale::sltPerformGuestScale()
 {
@@ -129,6 +76,6 @@
     frameBuffer()->setScaledSize(viewport()->size());
 
-    /* Scale the pause image if necessary */
-    scalePauseShot();
+    /* Scale the pause-pixmap: */
+    updateScaledPausePixmap();
 
     /* Update viewport: */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h	(revision 53371)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h	(revision 53372)
@@ -37,9 +37,4 @@
     virtual ~UIMachineViewScale();
 
-    virtual void takePausePixmapLive();
-    virtual void takePausePixmapSnapshot();
-    virtual void resetPausePixmap();
-    void scalePauseShot();
-
 private slots:
 
@@ -70,7 +65,4 @@
     void updateSliders();
 
-    /* Private members: */
-    QImage *m_pPauseImage;
-
     /* Friend classes: */
     friend class UIMachineView;
