VirtualBox

Ignore:
Timestamp:
Feb 13, 2023 3:06:38 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: Runtime UI: Reworking CDisplay wrapper usage step-by-step; This one is about CDisplay::TakeScreenShotToArray/TakeScreenShot stuff.

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

Legend:

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

    r98547 r98548  
    454454                                             xOrigin, yOrigin, uWidth, uHeight,
    455455                                             uBitsPerPixel);
     456}
     457
     458bool UIMachine::acquireScreenShot(ulong uScreenId, ulong uWidth, ulong uHeight, KBitmapFormat enmFormat, uchar *pBits)
     459{
     460    return uisession()->acquireScreenShot(uScreenId, uWidth, uHeight, enmFormat, pBits);
    456461}
    457462
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98547 r98548  
    289289                                  long &xOrigin, long &yOrigin, ulong &uWidth, ulong &uHeight,
    290290                                  ulong &uBitsPerPixel);
     291        /** Acquires screen-shot for guest-screen with passed uScreenId. */
     292        bool acquireScreenShot(ulong uScreenId, ulong uWidth, ulong uHeight, KBitmapFormat enmFormat, uchar *pBits);
    291293    /** @} */
    292294
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r98520 r98548  
    8888#include "CAudioAdapter.h"
    8989#include "CAudioSettings.h"
    90 #include "CDisplay.h"
    9190#include "CEmulatedUSB.h"
    9291#include "CGraphicsAdapter.h"
     
    297296{
    298297    return uisession()->console();
    299 }
    300 
    301 CDisplay& UIMachineLogic::display() const
    302 {
    303     return uisession()->display();
    304298}
    305299
     
    31353129        uMaxHeight  = RT_MAX(uMaxHeight, uHeight);
    31363130        QImage shot = QImage(uWidth, uHeight, QImage::Format_RGB32);
    3137         /* For separate process: */
    3138         if (uiCommon().isSeparateProcess())
    3139         {
    3140             /* Take screen-data to array first: */
    3141             const QVector<BYTE> screenData = display().TakeScreenShotToArray(uScreenIndex, shot.width(), shot.height(), KBitmapFormat_BGR0);
    3142             /* And copy that data to screen-shot if it is Ok: */
    3143             if (display().isOk() && !screenData.isEmpty())
    3144                 memcpy(shot.bits(), screenData.data(), shot.width() * shot.height() * 4);
    3145         }
    3146         /* For the same process: */
    3147         else
    3148         {
    3149             /* Take the screen-shot directly: */
    3150             display().TakeScreenShot(uScreenIndex, shot.bits(), shot.width(), shot.height(), KBitmapFormat_BGR0);
    3151         }
     3131        uimachine()->acquireScreenShot(uScreenIndex, shot.width(), shot.height(), KBitmapFormat_BGR0, shot.bits());
    31523132        images << shot;
    31533133    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r98516 r98548  
    5757class CMachine;
    5858class CConsole;
    59 class CDisplay;
    6059class CGuest;
    6160class CMouse;
     
    123122    /** Returns the session's console reference. */
    124123    CConsole& console() const;
    125     /** Returns the console's display reference. */
    126     CDisplay& display() const;
    127124    /** Returns the console's guest reference. */
    128125    CGuest& guest() const;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98547 r98548  
    452452    uHeight = uGuestHeight;
    453453    uBitsPerPixel = uGuestBitsPerPixel;
     454    return fSuccess;
     455}
     456
     457bool UISession::acquireScreenShot(ulong uScreenId, ulong uWidth, ulong uHeight, KBitmapFormat enmFormat, uchar *pBits)
     458{
     459    CDisplay comDisplay = display();
     460    bool fSuccess = false;
     461    /* For separate process: */
     462    if (uiCommon().isSeparateProcess())
     463    {
     464        /* Take screen-data to array first: */
     465        const QVector<BYTE> screenData = comDisplay.TakeScreenShotToArray(uScreenId, uWidth, uHeight, enmFormat);
     466        fSuccess = comDisplay.isOk();
     467        if (!fSuccess)
     468            UINotificationMessage::cannotAcquireDisplayParameter(comDisplay);
     469        else
     470        {
     471            /* And copy that data to screen-shot if it is Ok: */
     472            if (!screenData.isEmpty())
     473                memcpy(pBits, screenData.data(), uWidth * uHeight * 4);
     474        }
     475    }
     476    /* For the same process: */
     477    else
     478    {
     479        /* Take the screen-shot directly: */
     480        comDisplay.TakeScreenShot(uScreenId, pBits, uWidth, uHeight, enmFormat);
     481        fSuccess = comDisplay.isOk();
     482        if (!fSuccess)
     483            UINotificationMessage::cannotAcquireDisplayParameter(comDisplay);
     484    }
    454485    return fSuccess;
    455486}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98547 r98548  
    307307                                  long &xOrigin, long &yOrigin, ulong &uWidth, ulong &uHeight,
    308308                                  ulong &uBitsPerPixel);
     309        /** Acquires screen-shot for guest-screen with passed uScreenId. */
     310        bool acquireScreenShot(ulong uScreenId, ulong uWidth, ulong uHeight, KBitmapFormat enmFormat, uchar *pBits);
    309311    /** @} */
    310312
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