Changeset 51481 in vbox for trunk/src/VBox
- Timestamp:
- Jun 2, 2014 9:19:31 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 94083
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQImage.cpp
r51459 r51481 7 7 8 8 /* 9 * Copyright (C) 2010-201 3Oracle Corporation9 * Copyright (C) 2010-2014 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 39 39 #include "CMachine.h" 40 40 #include "CConsole.h" 41 #include "CDisplay.h" 41 42 42 43 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 74 75 m_height = pEvent->height(); 75 76 76 /* Check if we support the pixel format and can use the guest VRAM directly: */ 77 bool bRemind = false; 78 bool bFallback = false; 79 ulong bitsPerLine = pEvent->bytesPerLine() * 8; 80 if (pEvent->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB) 81 { 82 QImage::Format format; 83 switch (pEvent->bitsPerPixel()) 84 { 85 /* 32-, 8- and 1-bpp are the only depths supported by QImage: */ 86 case 32: 87 format = QImage::Format_RGB32; 88 break; 89 case 8: 90 format = QImage::Format_Indexed8; 91 bRemind = true; 92 break; 93 case 1: 94 format = QImage::Format_Mono; 95 bRemind = true; 96 break; 97 default: 98 format = QImage::Format_Invalid; 99 bRemind = true; 100 bFallback = true; 101 break; 102 } 103 104 if (!bFallback) 105 { 106 /* QImage only supports 32-bit aligned scan lines... */ 107 Assert((pEvent->bytesPerLine() & 3) == 0); 108 bFallback = ((pEvent->bytesPerLine() & 3) != 0); 109 } 110 if (!bFallback) 111 { 112 /* ...and the scan lines ought to be a whole number of pixels. */ 113 Assert((bitsPerLine & (pEvent->bitsPerPixel() - 1)) == 0); 114 bFallback = ((bitsPerLine & (pEvent->bitsPerPixel() - 1)) != 0); 115 } 116 if (!bFallback) 117 { 118 /* Make sure constraints are also passed: */ 119 Assert(bitsPerLine / pEvent->bitsPerPixel() >= m_width); 120 bFallback = RT_BOOL(bitsPerLine / pEvent->bitsPerPixel() < m_width); 121 } 122 if (!bFallback) 123 { 124 /* Finally compose image using VRAM directly: */ 125 LogRel(("UIFrameBufferQImage::resizeEvent: Resizing to directly use VGA device content..\n")); 126 m_img = QImage((uchar *)pEvent->VRAM(), m_width, m_height, bitsPerLine / 8, format); 127 m_uPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 128 } 77 /* Get the screen bitmap. */ 78 if (!m_sourceBitmap.isNull()) 79 { 80 BYTE *pAddress = NULL; 81 ULONG ulWidth = 0; 82 ULONG ulHeight = 0; 83 ULONG ulBitsPerPixel = 0; 84 ULONG ulBytesPerLine = 0; 85 ULONG ulPixelFormat = 0; 86 87 m_sourceBitmap.QueryBitmapInfo(pAddress, 88 ulWidth, 89 ulHeight, 90 ulBitsPerPixel, 91 ulBytesPerLine, 92 ulPixelFormat); 93 94 Assert(ulBitsPerPixel == 32); 95 NOREF(ulPixelFormat); 96 97 LogRel(("UIFrameBufferQImage::resizeEvent: Resizing to directly use VGA device content..\n")); 98 m_img = QImage(pAddress, ulWidth, ulHeight, ulBytesPerLine, QImage::Format_RGB32); 99 m_uPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 100 101 /* Check whether guest color depth differs from the bitmap color depth. */ 102 ULONG ulGuestBitsPerPixel = 0; 103 LONG xOrigin = 0; 104 LONG yOrigin = 0; 105 CDisplay display = m_pMachineView->uisession()->session().GetConsole().GetDisplay(); 106 display.GetScreenResolution(m_pMachineView->screenId(), 107 ulWidth, ulHeight, ulGuestBitsPerPixel, xOrigin, yOrigin); 108 109 /* Remind if requested: */ 110 if ( ulGuestBitsPerPixel != ulBitsPerPixel 111 && m_pMachineView->uisession()->isGuestAdditionsActive()) 112 popupCenter().remindAboutWrongColorDepth(m_pMachineView->machineWindow(), 113 ulGuestBitsPerPixel, ulBitsPerPixel); 114 else 115 popupCenter().forgetAboutWrongColorDepth(m_pMachineView->machineWindow()); 129 116 } 130 117 else 131 bFallback = true;132 133 /* Fallback if requested: */134 if (bFallback)135 118 { 136 119 LogRel(("UIFrameBufferQImage::resizeEvent: Resizing to FALLBACK buffer due to format is invalid..\n")); 137 120 goFallback(); 138 121 } 139 140 /* Remind if requested: */141 if (bRemind && m_pMachineView->uisession()->isGuestAdditionsActive())142 popupCenter().remindAboutWrongColorDepth(m_pMachineView->machineWindow(),143 pEvent->bitsPerPixel(), 32);144 else145 popupCenter().forgetAboutWrongColorDepth(m_pMachineView->machineWindow());146 122 147 123 /* Enable screen updates: */ … … 391 367 { 392 368 /* We calling for fallback when we: 393 * 1. don't support either the pixel format or the color depth;369 * 1. Display did not provide the source bitmap; 394 370 * 2. or the machine is in the state which breaks link between 395 371 * the framebuffer and the actual video-memory: */ 396 if (!m_sourceBitmap.isNull()) 397 { 398 BYTE *pAddress = NULL; 399 ULONG ulWidth = 0; 400 ULONG ulHeight = 0; 401 ULONG ulBitsPerPixel = 0; 402 ULONG ulBytesPerLine = 0; 403 ULONG ulPixelFormat = 0; 404 405 m_sourceBitmap.QueryBitmapInfo(pAddress, 406 ulWidth, 407 ulHeight, 408 ulBitsPerPixel, 409 ulBytesPerLine, 410 ulPixelFormat); 411 412 m_img = QImage(pAddress, ulWidth, ulHeight, ulBytesPerLine, QImage::Format_RGB32); 413 m_uPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 414 } 415 } 416 372 m_img = QImage(m_width, m_height, QImage::Format_RGB32); 373 m_img.fill(0); 374 m_uPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 375 } 376
Note:
See TracChangeset
for help on using the changeset viewer.