Changeset 66328 in vbox
- Timestamp:
- Mar 29, 2017 11:13:13 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 114261
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/DisplayImpl.h
r65410 r66328 34 34 #include "DisplaySourceBitmapWrap.h" 35 35 36 // #define NEW_RESIZE 37 36 38 class Console; 37 39 struct VIDEORECCONTEXT; … … 156 158 157 159 // public methods only for internal purposes 160 #ifndef NEW_RESIZE 158 161 int i_handleDisplayResize(unsigned uScreenId, uint32_t bpp, void *pvVRAM, uint32_t cbLine, 159 162 uint32_t w, uint32_t h, uint16_t flags); 163 #else 164 int i_handleDisplayResize(unsigned uScreenId, uint32_t bpp, void *pvVRAM, 165 uint32_t cbLine, uint32_t w, uint32_t h, uint16_t flags, 166 uint32_t xOrigin, uint32_t yOrigin, bool fVGAResize); 167 #endif 160 168 void i_handleDisplayUpdate(unsigned uScreenId, int x, int y, int w, int h); 161 169 void i_handleUpdateVMMDevSupportsGraphics(bool fSupportsGraphics); … … 302 310 BitmapFormat_T aBitmapFormat, 303 311 ULONG *pcbOut); 312 #ifdef NEW_RESIZE 313 int processVBVAResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM, bool fResetInputMapping); 314 #endif 304 315 305 316 #ifdef VBOX_WITH_CRHGSMI -
trunk/src/VBox/Main/src-client/DisplayImpl.cpp
r65418 r66328 902 902 * @thread EMT 903 903 */ 904 #ifndef NEW_RESIZE 904 905 int Display::i_handleDisplayResize(unsigned uScreenId, uint32_t bpp, void *pvVRAM, 905 906 uint32_t cbLine, uint32_t w, uint32_t h, uint16_t flags) 907 #else 908 int Display::i_handleDisplayResize(unsigned uScreenId, uint32_t bpp, void *pvVRAM, 909 uint32_t cbLine, uint32_t w, uint32_t h, uint16_t flags, 910 uint32_t xOrigin, uint32_t yOrigin, bool fVGAResize) 911 #endif 906 912 { 907 913 LogRel(("Display::handleDisplayResize: uScreenId=%d pvVRAM=%p w=%d h=%d bpp=%d cbLine=0x%X flags=0x%X\n", uScreenId, 908 914 pvVRAM, w, h, bpp, cbLine, flags)); 909 915 916 #ifndef NEW_RESIZE 910 917 if (uScreenId >= mcMonitors) 911 918 return VINF_SUCCESS; … … 994 1001 #endif 995 1002 1003 #else /* NEW_RESIZE */ 1004 1005 /* Caller must not hold the object lock. */ 1006 AssertReturn(!isWriteLockOnCurrentThread(), VERR_INVALID_STATE); 1007 1008 /* Make sure that the VGA device does not access the source bitmap. */ 1009 if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN && mpDrv) 1010 { 1011 mpDrv->pUpPort->pfnSetRenderVRAM(mpDrv->pUpPort, false); 1012 1013 mpDrv->IConnector.pbData = NULL; 1014 mpDrv->IConnector.cbScanline = 0; 1015 mpDrv->IConnector.cBits = 32; /* DevVGA does not work with cBits == 0. */ 1016 mpDrv->IConnector.cx = 0; 1017 mpDrv->IConnector.cy = 0; 1018 } 1019 1020 /* Update maFramebuffers[uScreenId] under lock. */ 1021 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1022 1023 if (uScreenId >= mcMonitors) 1024 return VINF_SUCCESS; 1025 1026 DISPLAYFBINFO *pFBInfo = &maFramebuffers[uScreenId]; 1027 1028 /* Reset the update mode. */ 1029 pFBInfo->updateImage.pSourceBitmap.setNull(); 1030 pFBInfo->updateImage.pu8Address = NULL; 1031 pFBInfo->updateImage.cbLine = 0; 1032 1033 /* Release the current source bitmap. */ 1034 pFBInfo->pSourceBitmap.setNull(); 1035 1036 /* Update the video mode information. */ 1037 pFBInfo->w = w; 1038 pFBInfo->h = h; 1039 pFBInfo->u16BitsPerPixel = (uint16_t)bpp; 1040 pFBInfo->pu8FramebufferVRAM = (uint8_t *)pvVRAM; 1041 pFBInfo->u32LineSize = cbLine; 1042 pFBInfo->flags = flags; 1043 if (!fVGAResize) 1044 { 1045 pFBInfo->xOrigin = xOrigin; 1046 pFBInfo->yOrigin = yOrigin; 1047 pFBInfo->fDisabled = RT_BOOL(flags & VBVA_SCREEN_F_DISABLED); 1048 pFBInfo->fVBVAForceResize = false; 1049 } 1050 1051 /* Prepare local vars for the notification code below. */ 1052 ComPtr<IFramebuffer> pFramebuffer = pFBInfo->pFramebuffer; 1053 1054 alock.release(); 1055 1056 if (!pFramebuffer.isNull()) 1057 { 1058 HRESULT hr = pFramebuffer->NotifyChange(uScreenId, 0, 0, w, h); /** @todo origin */ 1059 LogFunc(("NotifyChange hr %08X\n", hr)); 1060 NOREF(hr); 1061 } 1062 1063 /* Inform the VRDP server about the change of display parameters. */ 1064 LogRelFlowFunc(("Calling VRDP\n")); 1065 mParent->i_consoleVRDPServer()->SendResize(); 1066 1067 /* And re-send the seamless rectangles if necessary. */ 1068 if (mfSeamlessEnabled) 1069 i_handleSetVisibleRegion(mcRectVisibleRegion, mpRectVisibleRegion); 1070 1071 #ifdef VBOX_WITH_VIDEOREC 1072 videoCaptureScreenChanged(uScreenId); 1073 #endif 1074 1075 #endif /* NEW_RESIZE */ 1076 996 1077 LogRelFlowFunc(("[%d]: default format %d\n", uScreenId, pFBInfo->fDefaultFormat)); 997 1078 … … 1054 1135 return; */ 1055 1136 1137 #ifndef NEW_RESIZE 1056 1138 i_checkCoordBounds(&x, &y, &w, &h, maFramebuffers[uScreenId].w, 1057 1139 maFramebuffers[uScreenId].h); … … 1096 1178 } 1097 1179 } 1180 #else /* NEW_RESIZE */ 1181 DISPLAYFBINFO *pFBInfo = &maFramebuffers[uScreenId]; 1182 AutoReadLock alockr(this COMMA_LOCKVAL_SRC_POS); 1183 1184 ComPtr<IFramebuffer> pFramebuffer = pFBInfo->pFramebuffer; 1185 ComPtr<IDisplaySourceBitmap> pSourceBitmap = pFBInfo->updateImage.pSourceBitmap; 1186 1187 alockr.release(); 1188 1189 if (RT_LIKELY(!pFramebuffer.isNull())) 1190 { 1191 if (RT_LIKELY(!RT_BOOL(pFBInfo->u32Caps & FramebufferCapabilities_UpdateImage))) 1192 { 1193 i_checkCoordBounds(&x, &y, &w, &h, pFBInfo->w, pFBInfo->h); 1194 1195 if (w != 0 && h != 0) 1196 { 1197 pFramebuffer->NotifyUpdate(x, y, w, h); 1198 } 1199 } 1200 else 1201 { 1202 if (RT_LIKELY(!pSourceBitmap.isNull())) 1203 { /* likely */ } 1204 else 1205 { 1206 /* Create a source bitmap if UpdateImage mode is used. */ 1207 HRESULT hr = QuerySourceBitmap(uScreenId, pSourceBitmap.asOutParam()); 1208 if (SUCCEEDED(hr)) 1209 { 1210 BYTE *pAddress = NULL; 1211 ULONG ulWidth = 0; 1212 ULONG ulHeight = 0; 1213 ULONG ulBitsPerPixel = 0; 1214 ULONG ulBytesPerLine = 0; 1215 BitmapFormat_T bitmapFormat = BitmapFormat_Opaque; 1216 1217 hr = pSourceBitmap->QueryBitmapInfo(&pAddress, 1218 &ulWidth, 1219 &ulHeight, 1220 &ulBitsPerPixel, 1221 &ulBytesPerLine, 1222 &bitmapFormat); 1223 if (SUCCEEDED(hr)) 1224 { 1225 AutoWriteLock alockw(this COMMA_LOCKVAL_SRC_POS); 1226 1227 if (pFBInfo->updateImage.pSourceBitmap.isNull()) 1228 { 1229 pFBInfo->updateImage.pSourceBitmap = pSourceBitmap; 1230 pFBInfo->updateImage.pu8Address = pAddress; 1231 pFBInfo->updateImage.cbLine = ulBytesPerLine; 1232 } 1233 1234 pSourceBitmap = pFBInfo->updateImage.pSourceBitmap; 1235 1236 alockw.release(); 1237 } 1238 } 1239 } 1240 1241 if (RT_LIKELY(!pSourceBitmap.isNull())) 1242 { 1243 BYTE *pbAddress = NULL; 1244 ULONG ulWidth = 0; 1245 ULONG ulHeight = 0; 1246 ULONG ulBitsPerPixel = 0; 1247 ULONG ulBytesPerLine = 0; 1248 BitmapFormat_T bitmapFormat = BitmapFormat_Opaque; 1249 1250 HRESULT hr = pSourceBitmap->QueryBitmapInfo(&pbAddress, 1251 &ulWidth, 1252 &ulHeight, 1253 &ulBitsPerPixel, 1254 &ulBytesPerLine, 1255 &bitmapFormat); 1256 if (SUCCEEDED(hr)) 1257 { 1258 /* Make sure that the requested update is within the source bitmap dimensions. */ 1259 i_checkCoordBounds(&x, &y, &w, &h, ulWidth, ulHeight); 1260 1261 if (w != 0 && h != 0) 1262 { 1263 const size_t cbData = w * h * 4; 1264 com::SafeArray<BYTE> image(cbData); 1265 1266 uint8_t *pu8Dst = image.raw(); 1267 const uint8_t *pu8Src = pbAddress + ulBytesPerLine * y + x * 4; 1268 1269 int i; 1270 for (i = y; i < y + h; ++i) 1271 { 1272 memcpy(pu8Dst, pu8Src, w * 4); 1273 pu8Dst += w * 4; 1274 pu8Src += ulBytesPerLine; 1275 } 1276 1277 pFramebuffer->NotifyUpdateImage(x, y, w, h, ComSafeArrayAsInParam(image)); 1278 } 1279 } 1280 } 1281 } 1282 } 1283 #endif /* NEW_RESIZE */ 1098 1284 1099 1285 #ifndef VBOX_WITH_HGSMI … … 1582 1768 if (!pFBInfo->fDisabled) 1583 1769 { 1770 #ifndef NEW_RESIZE 1584 1771 i_handleDisplayResize(uScreenId, 32, 1585 1772 pFBInfo->pu8FramebufferVRAM, … … 1588 1775 pFBInfo->h, 1589 1776 pFBInfo->flags); 1777 #else 1778 i_handleDisplayResize(uScreenId, 32, 1779 pFBInfo->pu8FramebufferVRAM, 1780 pFBInfo->u32LineSize, 1781 pFBInfo->w, 1782 pFBInfo->h, 1783 pFBInfo->flags, 1784 pFBInfo->xOrigin, 1785 pFBInfo->yOrigin, 1786 false); 1787 #endif 1590 1788 } 1591 1789 } … … 1661 1859 if (mpDrv) 1662 1860 { 1861 #ifndef NEW_RESIZE 1663 1862 /* Setup the new framebuffer. */ 1664 1863 i_handleDisplayResize(aScreenId, pFBInfo->u16BitsPerPixel, … … 1668 1867 pFBInfo->h, 1669 1868 pFBInfo->flags); 1869 #else 1870 /* Inform the framebuffer about the actual screen size. */ 1871 HRESULT hr = aFramebuffer->NotifyChange(aScreenId, 0, 0, pFBInfo->w, pFBInfo->h); /** @todo origin */ 1872 LogFunc(("NotifyChange hr %08X\n", hr)); NOREF(hr); 1873 1874 /* Re-send the seamless rectangles if necessary. */ 1875 if (mfSeamlessEnabled) 1876 i_handleSetVisibleRegion(mcRectVisibleRegion, mpRectVisibleRegion); 1877 #endif 1670 1878 } 1671 1879 … … 2854 3062 if (pFBInfo->pSourceBitmap.isNull()) 2855 3063 { 3064 #ifndef NEW_RESIZE 2856 3065 /* Create a new object. */ 2857 3066 ComObjPtr<DisplaySourceBitmap> obj; … … 2896 3105 pFBInfo->fDefaultFormat = fDefaultFormat; 2897 3106 } 3107 #else /* NEW_RESIZE */ 3108 /* Create a new object. */ 3109 ComObjPtr<DisplaySourceBitmap> obj; 3110 hr = obj.createObject(); 3111 if (SUCCEEDED(hr)) 3112 hr = obj->init(this, aScreenId, pFBInfo); 3113 3114 if (SUCCEEDED(hr)) 3115 { 3116 pFBInfo->pSourceBitmap = obj; 3117 pFBInfo->fDefaultFormat = !obj->i_usesVRAM(); 3118 3119 if (aScreenId == VBOX_VIDEO_PRIMARY_SCREEN) 3120 { 3121 /* Start buffer updates. */ 3122 BYTE *pAddress = NULL; 3123 ULONG ulWidth = 0; 3124 ULONG ulHeight = 0; 3125 ULONG ulBitsPerPixel = 0; 3126 ULONG ulBytesPerLine = 0; 3127 BitmapFormat_T bitmapFormat = BitmapFormat_Opaque; 3128 3129 pFBInfo->pSourceBitmap->QueryBitmapInfo(&pAddress, 3130 &ulWidth, 3131 &ulHeight, 3132 &ulBitsPerPixel, 3133 &ulBytesPerLine, 3134 &bitmapFormat); 3135 3136 mpDrv->IConnector.pbData = pAddress; 3137 mpDrv->IConnector.cbScanline = ulBytesPerLine; 3138 mpDrv->IConnector.cBits = ulBitsPerPixel; 3139 mpDrv->IConnector.cx = ulWidth; 3140 mpDrv->IConnector.cy = ulHeight; 3141 3142 fSetRenderVRAM = pFBInfo->fDefaultFormat; 3143 } 3144 3145 /* Make sure that the bitmap contains the latest image. */ 3146 fInvalidate = pFBInfo->fDefaultFormat; 3147 } 3148 #endif /* NEW_RESIZE */ 2898 3149 } 2899 3150 … … 3091 3342 } 3092 3343 3344 #ifndef NEW_RESIZE 3093 3345 int rc = pThis->i_handleDisplayResize(VBOX_VIDEO_PRIMARY_SCREEN, bpp, pvVRAM, cbLine, cx, cy, VBVA_SCREEN_F_ACTIVE); 3346 #else 3347 int rc = pThis->i_handleDisplayResize(VBOX_VIDEO_PRIMARY_SCREEN, bpp, pvVRAM, cbLine, cx, cy, 3348 VBVA_SCREEN_F_ACTIVE, 0, 0, true); 3349 #endif 3094 3350 3095 3351 /* Restore the flag. */ … … 4088 4344 Display *pThis = pDrv->pDisplay; 4089 4345 4346 #ifndef NEW_RESIZE 4090 4347 DISPLAYFBINFO *pFBInfo = &pThis->maFramebuffers[pScreen->u32ViewIndex]; 4091 4348 … … 4227 4484 (uint8_t *)pvVRAM + pScreen->u32StartOffset, 4228 4485 pScreen->u32LineSize, pScreen->u32Width, pScreen->u32Height, pScreen->u16Flags); 4229 } 4486 #else /* NEW_RESIZE */ 4487 return pThis->processVBVAResize(pView, pScreen, pvVRAM, fResetInputMapping); 4488 #endif /* NEW_RESIZE */ 4489 } 4490 4491 #ifdef NEW_RESIZE 4492 int Display::processVBVAResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM, bool fResetInputMapping) 4493 { 4494 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 4495 4496 DISPLAYFBINFO *pFBInfo = &maFramebuffers[pScreen->u32ViewIndex]; 4497 4498 if (pScreen->u16Flags & VBVA_SCREEN_F_DISABLED) 4499 { 4500 /* Ask the framebuffer to resize using a default format. The framebuffer will be black. 4501 * So if the frontend does not support GuestMonitorChangedEventType_Disabled event, 4502 * the VM window will be black. */ 4503 uint32_t u32Width = pFBInfo->w ? pFBInfo->w : 640; 4504 uint32_t u32Height = pFBInfo->h ? pFBInfo->h : 480; 4505 int32_t xOrigin = pFBInfo->xOrigin; 4506 int32_t yOrigin = pFBInfo->yOrigin; 4507 4508 alock.release(); 4509 4510 i_notifyCroglResize(pView, pScreen, pvVRAM); 4511 4512 i_handleDisplayResize(pScreen->u32ViewIndex, 0, (uint8_t *)NULL, 0, 4513 u32Width, u32Height, pScreen->u16Flags, xOrigin, yOrigin, false); 4514 4515 fireGuestMonitorChangedEvent(mParent->i_getEventSource(), 4516 GuestMonitorChangedEventType_Disabled, 4517 pScreen->u32ViewIndex, 4518 0, 0, 0, 0); 4519 return VINF_SUCCESS; 4520 } 4521 4522 VBVAINFOSCREEN screenInfo; 4523 RT_ZERO(screenInfo); 4524 4525 if (pScreen->u16Flags & VBVA_SCREEN_F_BLANK2) 4526 { 4527 /* Init a local VBVAINFOSCREEN structure, which will be used instead of 4528 * the original pScreen. Set VBVA_SCREEN_F_BLANK, which will force 4529 * the code below to choose the "blanking" branches. 4530 */ 4531 screenInfo.u32ViewIndex = pScreen->u32ViewIndex; 4532 screenInfo.i32OriginX = pFBInfo->xOrigin; 4533 screenInfo.i32OriginY = pFBInfo->yOrigin; 4534 screenInfo.u32StartOffset = 0; /* Irrelevant */ 4535 screenInfo.u32LineSize = pFBInfo->u32LineSize; 4536 screenInfo.u32Width = pFBInfo->w; 4537 screenInfo.u32Height = pFBInfo->h; 4538 screenInfo.u16BitsPerPixel = pFBInfo->u16BitsPerPixel; 4539 screenInfo.u16Flags = pScreen->u16Flags | VBVA_SCREEN_F_BLANK; 4540 4541 pScreen = &screenInfo; 4542 } 4543 4544 /* Resize if VBVA was just enabled or display was in disabled state. 4545 * Also if there is no framebuffer, a resize will be required, because the framebuffer was/will be changed. 4546 */ 4547 bool fResize = pFBInfo->fVBVAForceResize || pFBInfo->fDisabled || pFBInfo->pFramebuffer.isNull(); 4548 4549 /* If the screen blanked state is changing, then do a resize request to make sure that the framebuffer 4550 * is notified and requests a new source bitmap. 4551 */ 4552 fResize = fResize || RT_BOOL((pScreen->u16Flags ^ pFBInfo->flags) & VBVA_SCREEN_F_BLANK); 4553 4554 /* Check if this is a real resize or a notification about the screen origin. 4555 * The guest uses this VBVAResize call for both. 4556 */ 4557 fResize = fResize 4558 || pFBInfo->u16BitsPerPixel != pScreen->u16BitsPerPixel 4559 || pFBInfo->pu8FramebufferVRAM != (uint8_t *)pvVRAM + pScreen->u32StartOffset 4560 || pFBInfo->u32LineSize != pScreen->u32LineSize 4561 || pFBInfo->w != pScreen->u32Width 4562 || pFBInfo->h != pScreen->u32Height; 4563 4564 bool fNewOrigin = pFBInfo->xOrigin != pScreen->i32OriginX 4565 || pFBInfo->yOrigin != pScreen->i32OriginY; 4566 4567 /* The event for disabled->enabled transition. */ 4568 const bool fGuestMonitorChangedEvent = pFBInfo->fDisabled; 4569 4570 if (fResetInputMapping) 4571 { 4572 /// @todo Rename to m* and verify whether some kind of lock is required. 4573 xInputMappingOrigin = 0; 4574 yInputMappingOrigin = 0; 4575 cxInputMapping = 0; 4576 cyInputMapping = 0; 4577 } 4578 4579 alock.release(); 4580 4581 if (fNewOrigin || fResize) 4582 i_notifyCroglResize(pView, pScreen, pvVRAM); 4583 4584 if (fGuestMonitorChangedEvent) 4585 fireGuestMonitorChangedEvent(mParent->i_getEventSource(), 4586 GuestMonitorChangedEventType_Enabled, 4587 pScreen->u32ViewIndex, 4588 pScreen->i32OriginX, pScreen->i32OriginY, 4589 pScreen->u32Width, pScreen->u32Height); 4590 4591 if (fNewOrigin) 4592 fireGuestMonitorChangedEvent(mParent->i_getEventSource(), 4593 GuestMonitorChangedEventType_NewOrigin, 4594 pScreen->u32ViewIndex, 4595 pScreen->i32OriginX, pScreen->i32OriginY, 4596 0, 0); 4597 4598 if (!fResize) 4599 { 4600 /* No parameters of the framebuffer have actually changed. */ 4601 if (fNewOrigin) 4602 { 4603 /* VRDP server still need this notification. */ 4604 LogRelFlowFunc(("Calling VRDP\n")); 4605 mParent->i_consoleVRDPServer()->SendResize(); 4606 } 4607 return VINF_SUCCESS; 4608 } 4609 4610 /* Do a regular resize. */ 4611 return i_handleDisplayResize(pScreen->u32ViewIndex, pScreen->u16BitsPerPixel, 4612 (uint8_t *)pvVRAM + pScreen->u32StartOffset, 4613 pScreen->u32LineSize, pScreen->u32Width, pScreen->u32Height, pScreen->u16Flags, 4614 pScreen->i32OriginX, pScreen->i32OriginY, false); 4615 } 4616 #endif /* NEW_RESIZE */ 4230 4617 4231 4618 DECLCALLBACK(int) Display::i_displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha, -
trunk/src/VBox/Main/src-client/DisplayImplLegacy.cpp
r63563 r66328 957 957 } 958 958 959 #ifndef NEW_RESIZE 959 960 i_handleDisplayResize(uScreenId, pScreen->bitsPerPixel, 960 961 (uint8_t *)pvVRAM + pFBInfo->u32Offset, … … 962 963 pScreen->u16Width, pScreen->u16Height, 963 964 VBVA_SCREEN_F_ACTIVE); 965 #else 966 i_handleDisplayResize(uScreenId, pScreen->bitsPerPixel, 967 (uint8_t *)pvVRAM + pFBInfo->u32Offset, 968 pScreen->u32LineSize, 969 pScreen->u16Width, pScreen->u16Height, 970 VBVA_SCREEN_F_ACTIVE, 971 pScreen->xOrigin, pScreen->yOrigin, false); 972 #endif 964 973 } 965 974 }
Note:
See TracChangeset
for help on using the changeset viewer.