VirtualBox

Changeset 53363 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 20, 2014 5:13:53 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: 6278: Preparing to support for scaled video-output: Pause screen-shot stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r53076 r53363  
    298298                    || m_previousState != KMachineState_Teleporting))
    299299            {
    300                 takePauseShotLive();
    301                 /* Fully repaint to pick up m_pauseShot: */
     300                /* Take live pause-pixmap: */
     301                takePausePixmapLive();
     302                /* Fully repaint to pick up pause-pixmap: */
    302303                viewport()->update();
    303304            }
     
    309310            if (screenId() == 0)
    310311            {
    311                 takePauseShotSnapshot();
    312                 /* Fully repaint to pick up m_pauseShot: */
     312                /* Take snapshot pause-pixmap: */
     313                takePausePixmapSnapshot();
     314                /* Fully repaint to pick up pause-pixmap: */
    313315                viewport()->update();
    314316            }
     
    323325                if (m_pFrameBuffer)
    324326                {
    325                     /* Reset the pixmap to free memory: */
    326                     resetPauseShot();
     327                    /* Reset pause-pixmap: */
     328                    resetPausePixmap();
    327329                    /* Ask for full guest display update (it will also update
    328330                     * the viewport through IFramebuffer::NotifyUpdate): */
     
    687689}
    688690
    689 void UIMachineView::takePauseShotLive()
    690 {
    691     /* Take a screen snapshot. Note that TakeScreenShot() always needs a 32bpp image: */
    692     QImage shot = QImage(m_pFrameBuffer->width(), m_pFrameBuffer->height(), QImage::Format_RGB32);
    693     /* If TakeScreenShot fails or returns no image, just show a black image. */
    694     shot.fill(0);
     691void UIMachineView::resetPausePixmap()
     692{
     693    /* Reset pixmap: */
     694    m_pausePixmap = QPixmap();
     695}
     696
     697void UIMachineView::takePausePixmapLive()
     698{
     699    /* Prepare a screen-shot: */
     700    QImage screenShot = QImage(m_pFrameBuffer->width(), m_pFrameBuffer->height(), QImage::Format_RGB32);
     701    /* Which will be a 'black image' by default. */
     702    screenShot.fill(0);
     703
     704    /* For separate process: */
    695705    if (vboxGlobal().isSeparateProcess())
    696706    {
    697         QVector<BYTE> screenData = display().TakeScreenShotToArray(screenId(), shot.width(), shot.height(), KBitmapFormat_BGR0);
    698 
    699         /* Make sure screen-data is OK: */
     707        /* Take screen-data to array: */
     708        const QVector<BYTE> screenData = display().TakeScreenShotToArray(screenId(), screenShot.width(), screenShot.height(), KBitmapFormat_BGR0);
     709        /* And copy that data to screen-shot if it is Ok: */
    700710        if (display().isOk() && !screenData.isEmpty())
    701             memcpy(shot.bits(), screenData.data(), shot.width() * shot.height() * 4);
    702     }
     711            memcpy(screenShot.bits(), screenData.data(), screenShot.width() * screenShot.height() * 4);
     712    }
     713    /* For the same process: */
    703714    else
    704         display().TakeScreenShot(screenId(), shot.bits(), shot.width(), shot.height(), KBitmapFormat_BGR0);
    705     /* TakeScreenShot() may fail if, e.g. the Paused notification was delivered
    706      * after the machine execution was resumed. It's not fatal: */
    707     if (display().isOk())
    708         dimImage(shot);
    709     m_pauseShot = QPixmap::fromImage(shot);
    710 }
    711 
    712 void UIMachineView::takePauseShotSnapshot()
    713 {
    714     ULONG width = 0, height = 0;
    715     QVector<BYTE> screenData = machine().ReadSavedScreenshotPNGToArray(0, width, height);
    716     if (screenData.size() != 0)
    717     {
    718         ULONG guestOriginX = 0, guestOriginY = 0, guestWidth = 0, guestHeight = 0;
    719         BOOL fEnabled = true;
    720         machine().QuerySavedGuestScreenInfo(m_uScreenId, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
    721         QImage shot = QImage::fromData(screenData.data(), screenData.size(), "PNG").scaled(guestWidth > 0 ? QSize(guestWidth, guestHeight) : guestSizeHint());
    722         dimImage(shot);
    723         m_pauseShot = QPixmap::fromImage(shot);
    724     }
     715    {
     716        /* Take the screen-shot directly: */
     717        display().TakeScreenShot(screenId(), screenShot.bits(), screenShot.width(), screenShot.height(), KBitmapFormat_BGR0);
     718    }
     719
     720    /* Dim screen-shot if it is Ok: */
     721    if (display().isOk() && !screenShot.isNull())
     722        dimImage(screenShot);
     723
     724    /* Finally copy the screen-shot to pause-pixmap: */
     725    m_pausePixmap = QPixmap::fromImage(screenShot);
     726}
     727
     728void UIMachineView::takePausePixmapSnapshot()
     729{
     730    /* Acquire the screen-data from the saved-state: */
     731    ULONG uWidth = 0, uHeight = 0;
     732    const QVector<BYTE> screenData = machine().ReadSavedScreenshotPNGToArray(0, uWidth, uHeight);
     733
     734    /* Make sure there is saved-state screen-data: */
     735    if (screenData.isEmpty())
     736        return;
     737
     738    /* Acquire the screen-data properties from the saved-state: */
     739    ULONG uGuestOriginX = 0, uGuestOriginY = 0, uGuestWidth = 0, uGuestHeight = 0;
     740    BOOL fEnabled = true;
     741    machine().QuerySavedGuestScreenInfo(m_uScreenId, uGuestOriginX, uGuestOriginY, uGuestWidth, uGuestHeight, fEnabled);
     742
     743    /* Create a screen-shot on the basis of the screen-data we have in saved-state: */
     744    QImage screenShot = QImage::fromData(screenData.data(), screenData.size(), "PNG").scaled(uGuestWidth > 0 ? QSize(uGuestWidth, uGuestHeight) : guestSizeHint());
     745
     746    /* Dim screen-shot if it is Ok: */
     747    if (machine().isOk() && !screenShot.isNull())
     748        dimImage(screenShot);
     749
     750    /* Finally copy the screen-shot to pause-pixmap: */
     751    m_pausePixmap = QPixmap::fromImage(screenShot);
    725752}
    726753
     
    810837{
    811838    /* Use pause-image if exists: */
    812     if (!m_pauseShot.isNull())
    813         return darwinToCGImageRef(&m_pauseShot);
     839    if (!pausePixmap().isNull())
     840        return darwinToCGImageRef(&pausePixmap());
    814841
    815842    /* Create the image ref out of the frame-buffer: */
     
    956983{
    957984    /* Use pause-image if exists: */
    958     if (!m_pauseShot.isNull())
     985    if (!pausePixmap().isNull())
    959986    {
    960987        /* We have a snapshot for the paused state: */
    961988        QRect rect = pPaintEvent->rect().intersect(viewport()->rect());
    962989        QPainter painter(viewport());
    963         painter.drawPixmap(rect, m_pauseShot, QRect(rect.x() + contentsX(), rect.y() + contentsY(),
    964                                                     rect.width(), rect.height()));
     990        painter.drawPixmap(rect, pausePixmap(), QRect(rect.x() + contentsX(), rect.y() + contentsY(),
     991                                                      rect.width(), rect.height()));
    965992#ifdef Q_WS_MAC
    966993        /* Update the dock icon: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r53076 r53363  
    173173    ulong screenId() const { return m_uScreenId; }
    174174    UIFrameBuffer* frameBuffer() const { return m_pFrameBuffer; }
    175     const QPixmap& pauseShot() const { return m_pauseShot; }
    176175    /** Atomically store the maximum guest resolution which we currently wish
    177176     * to handle for @a maxGuestSize() to read.  Should be called if anything
     
    193192    void storeGuestSizeHint(const QSize &size);
    194193
    195     /* Protected helpers: */
    196     virtual void takePauseShotLive();
    197     virtual void takePauseShotSnapshot();
    198     virtual void resetPauseShot() { m_pauseShot = QPixmap(); }
     194    /** Returns the pause-pixmap: */
     195    const QPixmap& pausePixmap() const { return m_pausePixmap; }
     196    /** Resets the pause-pixmap. */
     197    virtual void resetPausePixmap();
     198    /** Acquires live pause-pixmap. */
     199    virtual void takePausePixmapLive();
     200    /** Acquires snapshot pause-pixmap. */
     201    virtual void takePausePixmapSnapshot();
     202
    199203    /** The available area on the current screen for application windows. */
    200204    virtual QRect workingArea() const = 0;
     
    269273#endif /* VBOX_WITH_VIDEOHWACCEL */
    270274
    271     QPixmap m_pauseShot;
     275    /** Holds the pause-pixmap. */
     276    QPixmap m_pausePixmap;
    272277
    273278    /* Friend classes: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp

    r53076 r53363  
    7171}
    7272
    73 void UIMachineViewScale::takePauseShotLive()
     73void UIMachineViewScale::takePausePixmapLive()
    7474{
    7575    /* Take a screen snapshot. Note that TakeScreenShot() always needs a 32bpp image: */
     
    8282}
    8383
    84 void UIMachineViewScale::takePauseShotSnapshot()
     84void UIMachineViewScale::takePausePixmapSnapshot()
    8585{
    8686    ULONG width = 0, height = 0;
     
    9797}
    9898
    99 void UIMachineViewScale::resetPauseShot()
     99void UIMachineViewScale::resetPausePixmap()
    100100{
    101101    /* Call the base class */
    102     UIMachineView::resetPauseShot();
     102    UIMachineView::resetPausePixmap();
    103103
    104104    if (m_pPauseImage)
     
    118118            QImage tmpImg = m_pPauseImage->scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    119119            dimImage(tmpImg);
    120             m_pauseShot = QPixmap::fromImage(tmpImg);
     120            m_pausePixmap = QPixmap::fromImage(tmpImg);
    121121        }
    122122    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h

    r52727 r53363  
    3737    virtual ~UIMachineViewScale();
    3838
    39     virtual void takePauseShotLive();
    40     virtual void takePauseShotSnapshot();
    41     virtual void resetPauseShot();
     39    virtual void takePausePixmapLive();
     40    virtual void takePausePixmapSnapshot();
     41    virtual void resetPausePixmap();
    4242    void scalePauseShot();
    4343
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette