Changeset 53363 in vbox for trunk/src/VBox
- Timestamp:
- Nov 20, 2014 5:13:53 PM (10 years ago)
- 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 298 298 || m_previousState != KMachineState_Teleporting)) 299 299 { 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: */ 302 303 viewport()->update(); 303 304 } … … 309 310 if (screenId() == 0) 310 311 { 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: */ 313 315 viewport()->update(); 314 316 } … … 323 325 if (m_pFrameBuffer) 324 326 { 325 /* Reset the pixmap to free memory: */326 resetPause Shot();327 /* Reset pause-pixmap: */ 328 resetPausePixmap(); 327 329 /* Ask for full guest display update (it will also update 328 330 * the viewport through IFramebuffer::NotifyUpdate): */ … … 687 689 } 688 690 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); 691 void UIMachineView::resetPausePixmap() 692 { 693 /* Reset pixmap: */ 694 m_pausePixmap = QPixmap(); 695 } 696 697 void 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: */ 695 705 if (vboxGlobal().isSeparateProcess()) 696 706 { 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: */ 700 710 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: */ 703 714 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 728 void 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); 725 752 } 726 753 … … 810 837 { 811 838 /* Use pause-image if exists: */ 812 if (! m_pauseShot.isNull())813 return darwinToCGImageRef(& m_pauseShot);839 if (!pausePixmap().isNull()) 840 return darwinToCGImageRef(&pausePixmap()); 814 841 815 842 /* Create the image ref out of the frame-buffer: */ … … 956 983 { 957 984 /* Use pause-image if exists: */ 958 if (! m_pauseShot.isNull())985 if (!pausePixmap().isNull()) 959 986 { 960 987 /* We have a snapshot for the paused state: */ 961 988 QRect rect = pPaintEvent->rect().intersect(viewport()->rect()); 962 989 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())); 965 992 #ifdef Q_WS_MAC 966 993 /* Update the dock icon: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r53076 r53363 173 173 ulong screenId() const { return m_uScreenId; } 174 174 UIFrameBuffer* frameBuffer() const { return m_pFrameBuffer; } 175 const QPixmap& pauseShot() const { return m_pauseShot; }176 175 /** Atomically store the maximum guest resolution which we currently wish 177 176 * to handle for @a maxGuestSize() to read. Should be called if anything … … 193 192 void storeGuestSizeHint(const QSize &size); 194 193 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 199 203 /** The available area on the current screen for application windows. */ 200 204 virtual QRect workingArea() const = 0; … … 269 273 #endif /* VBOX_WITH_VIDEOHWACCEL */ 270 274 271 QPixmap m_pauseShot; 275 /** Holds the pause-pixmap. */ 276 QPixmap m_pausePixmap; 272 277 273 278 /* Friend classes: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp
r53076 r53363 71 71 } 72 72 73 void UIMachineViewScale::takePause ShotLive()73 void UIMachineViewScale::takePausePixmapLive() 74 74 { 75 75 /* Take a screen snapshot. Note that TakeScreenShot() always needs a 32bpp image: */ … … 82 82 } 83 83 84 void UIMachineViewScale::takePause ShotSnapshot()84 void UIMachineViewScale::takePausePixmapSnapshot() 85 85 { 86 86 ULONG width = 0, height = 0; … … 97 97 } 98 98 99 void UIMachineViewScale::resetPause Shot()99 void UIMachineViewScale::resetPausePixmap() 100 100 { 101 101 /* Call the base class */ 102 UIMachineView::resetPause Shot();102 UIMachineView::resetPausePixmap(); 103 103 104 104 if (m_pPauseImage) … … 118 118 QImage tmpImg = m_pPauseImage->scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 119 119 dimImage(tmpImg); 120 m_pause Shot= QPixmap::fromImage(tmpImg);120 m_pausePixmap = QPixmap::fromImage(tmpImg); 121 121 } 122 122 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h
r52727 r53363 37 37 virtual ~UIMachineViewScale(); 38 38 39 virtual void takePause ShotLive();40 virtual void takePause ShotSnapshot();41 virtual void resetPause Shot();39 virtual void takePausePixmapLive(); 40 virtual void takePausePixmapSnapshot(); 41 virtual void resetPausePixmap(); 42 42 void scalePauseShot(); 43 43
Note:
See TracChangeset
for help on using the changeset viewer.