Changeset 71073 in vbox
- Timestamp:
- Feb 20, 2018 5:14:17 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 4 edited
-
UIFrameBuffer.cpp (modified) (1 diff)
-
UIMachineView.cpp (modified) (18 diffs)
-
UIMouseHandler.cpp (modified) (1 diff)
-
scale/UIMachineViewScale.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r71057 r71073 1320 1320 m_transform = m_transform.scale(scaleFactor(), scaleFactor()); 1321 1321 1322 /* Apply the device-pixel-ratio if necessary: */ 1323 if (useUnscaledHiDPIOutput() && devicePixelRatio() > 1.0) 1324 m_transform = m_transform.scale(1.0 / devicePixelRatio(), 1.0 / devicePixelRatio()); 1322 /* Take the device-pixel-ratio into account: */ 1323 if (!useUnscaledHiDPIOutput()) 1324 m_transform = m_transform.scale(devicePixelRatio(), devicePixelRatio()); 1325 m_transform = m_transform.scale(1.0 / devicePixelRatio(), 1.0 / devicePixelRatio()); 1325 1326 } 1326 1327 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r71056 r71073 367 367 QSize scaledSize = size(); 368 368 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 369 if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput()) 370 scaledSize *= dDevicePixelRatio; 369 scaledSize *= dDevicePixelRatio; 370 if (!frameBuffer()->useUnscaledHiDPIOutput()) 371 scaledSize /= dDevicePixelRatio; 371 372 frameBuffer()->setScaledSize(scaledSize); 372 373 … … 452 453 453 454 /* Take the device-pixel-ratio into account: */ 454 if (frameBuffer()->useUnscaledHiDPIOutput()) 455 { 456 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 457 if (dDevicePixelRatio > 1.0) 458 { 459 rect.moveTo((int)floor((double)rect.x() / dDevicePixelRatio) - 1, 460 (int)floor((double)rect.y() / dDevicePixelRatio) - 1); 461 rect.setSize(QSize((int)ceil((double)rect.width() / dDevicePixelRatio) + 2, 462 (int)ceil((double)rect.height() / dDevicePixelRatio) + 2)); 463 } 455 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 456 if (!frameBuffer()->useUnscaledHiDPIOutput() && dDevicePixelRatio != 1.0) 457 { 458 rect.moveTo((int)floor((double)rect.x() * dDevicePixelRatio) - 1, 459 (int)floor((double)rect.y() * dDevicePixelRatio) - 1); 460 rect.setSize(QSize((int)ceil((double)rect.width() * dDevicePixelRatio) + 2, 461 (int)ceil((double)rect.height() * dDevicePixelRatio) + 2)); 462 } 463 if (dDevicePixelRatio != 1.0) 464 { 465 rect.moveTo((int)floor((double)rect.x() / dDevicePixelRatio) - 1, 466 (int)floor((double)rect.y() / dDevicePixelRatio) - 1); 467 rect.setSize(QSize((int)ceil((double)rect.width() / dDevicePixelRatio) + 2, 468 (int)ceil((double)rect.height() / dDevicePixelRatio) + 2)); 464 469 } 465 470 … … 512 517 (uint32_t)(dScaleFactorFor3D * VBOX_OGL_SCALE_FACTOR_MULTIPLIER), 513 518 (uint32_t)(dScaleFactorFor3D * VBOX_OGL_SCALE_FACTOR_MULTIPLIER)); 519 display().NotifyHiDPIOutputPolicyChange(fUseUnscaledHiDPIOutput); 514 520 } 515 521 … … 551 557 /* Propagate the unscaled HiDPI output mode to 3D service if necessary: */ 552 558 if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable()) 553 {554 559 display().NotifyHiDPIOutputPolicyChange(fUseUnscaledHiDPIOutput); 555 }556 560 557 561 /* Handle scale attributes change: */ … … 794 798 795 799 #ifdef VBOX_WITH_DRAG_AND_DROP 796 /* Enable drag & drop .*/800 /* Enable drag & drop: */ 797 801 setAcceptDrops(true); 798 802 799 /* Create the drag and drop handler instance. 800 * At the moment we only support one instance per machine window. */ 803 /* Create the drag and drop handler instance: */ 801 804 m_pDnDHandler = new UIDnDHandler(uisession(), this /* pParent */); 802 805 #endif /* VBOX_WITH_DRAG_AND_DROP */ … … 1059 1062 QSize scaledSize = size(); 1060 1063 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1061 if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput()) 1062 scaledSize *= dDevicePixelRatio; 1064 scaledSize *= dDevicePixelRatio; 1065 if (!frameBuffer()->useUnscaledHiDPIOutput()) 1066 scaledSize /= dDevicePixelRatio; 1063 1067 frameBuffer()->setScaledSize(scaledSize); 1064 1068 } … … 1122 1126 } 1123 1127 1128 /* Take the device-pixel-ratio into account: */ 1129 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1130 if (!frameBuffer()->useUnscaledHiDPIOutput() && dDevicePixelRatio != 1.0) 1131 screenShot = screenShot.scaled(screenShot.size() * dDevicePixelRatio, 1132 Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 1133 1124 1134 /* Dim screen-shot if it is Ok: */ 1125 1135 if (display().isOk() && !screenShot.isNull()) … … 1128 1138 /* Finally copy the screen-shot to pause-pixmap: */ 1129 1139 m_pausePixmap = QPixmap::fromImage(screenShot); 1130 /* Adjust device-pixel-ratio if necessary: */ 1131 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1132 if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput()) 1133 m_pausePixmap.setDevicePixelRatio(dDevicePixelRatio); 1140 1141 /* Take the device-pixel-ratio into account: */ 1142 m_pausePixmap.setDevicePixelRatio(frameBuffer()->devicePixelRatio()); 1134 1143 1135 1144 /* Update scaled pause pixmap: */ … … 1152 1161 machine().QuerySavedGuestScreenInfo(m_uScreenId, uGuestOriginX, uGuestOriginY, uGuestWidth, uGuestHeight, fEnabled); 1153 1162 1163 /* Calculate effective size: */ 1164 QSize effectiveSize = uGuestWidth > 0 ? QSize(uGuestWidth, uGuestHeight) : guestScreenSizeHint(); 1165 1166 /* Take the device-pixel-ratio into account: */ 1167 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1168 if (!frameBuffer()->useUnscaledHiDPIOutput()) 1169 effectiveSize *= dDevicePixelRatio; 1170 1154 1171 /* Create a screen-shot on the basis of the screen-data we have in saved-state: */ 1155 QImage screenShot = QImage::fromData(screenData.data(), screenData.size(), "PNG").scaled( uGuestWidth > 0 ? QSize(uGuestWidth, uGuestHeight) : guestScreenSizeHint());1172 QImage screenShot = QImage::fromData(screenData.data(), screenData.size(), "PNG").scaled(effectiveSize); 1156 1173 1157 1174 /* Dim screen-shot if it is Ok: */ … … 1161 1178 /* Finally copy the screen-shot to pause-pixmap: */ 1162 1179 m_pausePixmap = QPixmap::fromImage(screenShot); 1163 /* Adjust device-pixel-ratio if necessary: */ 1164 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1165 if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput()) 1166 m_pausePixmap.setDevicePixelRatio(dDevicePixelRatio); 1180 1181 /* Take the device-pixel-ratio into account: */ 1182 m_pausePixmap.setDevicePixelRatio(frameBuffer()->devicePixelRatio()); 1167 1183 1168 1184 /* Update scaled pause pixmap: */ … … 1177 1193 1178 1194 /* Make sure scaled-size is not null: */ 1179 constQSize scaledSize = frameBuffer()->scaledSize();1195 QSize scaledSize = frameBuffer()->scaledSize(); 1180 1196 if (!scaledSize.isValid()) 1181 1197 return; 1182 1198 1199 /* Take the device-pixel-ratio into account: */ 1200 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1201 if (!frameBuffer()->useUnscaledHiDPIOutput()) 1202 scaledSize *= dDevicePixelRatio; 1203 1183 1204 /* Update pause pixmap finally: */ 1184 1205 m_pausePixmapScaled = pausePixmap().scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 1185 /* Adjust device-pixel-ratio if necessary: */ 1186 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1187 if (dDevicePixelRatio > 1.0 && frameBuffer()->useUnscaledHiDPIOutput()) 1188 m_pausePixmapScaled.setDevicePixelRatio(dDevicePixelRatio); 1206 1207 /* Take the device-pixel-ratio into account: */ 1208 m_pausePixmapScaled.setDevicePixelRatio(frameBuffer()->devicePixelRatio()); 1189 1209 } 1190 1210 … … 1210 1230 1211 1231 /* Take the device-pixel-ratio into account: */ 1212 if (frameBuffer()->useUnscaledHiDPIOutput()) 1213 { 1214 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1215 if (dDevicePixelRatio > 1.0) 1216 { 1217 xRange *= dDevicePixelRatio; 1218 yRange *= dDevicePixelRatio; 1219 } 1232 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1233 xRange *= dDevicePixelRatio; 1234 yRange *= dDevicePixelRatio; 1235 if (!frameBuffer()->useUnscaledHiDPIOutput()) 1236 { 1237 xRange /= dDevicePixelRatio; 1238 yRange /= dDevicePixelRatio; 1220 1239 } 1221 1240 … … 1234 1253 1235 1254 /* Take the device-pixel-ratio into account: */ 1236 if (frameBuffer()->useUnscaledHiDPIOutput()) 1237 { 1238 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1239 if (dDevicePixelRatio > 1.0) 1240 { 1241 iContentsX /= dDevicePixelRatio; 1242 iContentsY /= dDevicePixelRatio; 1243 } 1244 } 1255 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1256 if (!frameBuffer()->useUnscaledHiDPIOutput()) 1257 { 1258 iContentsX *= dDevicePixelRatio; 1259 iContentsY *= dDevicePixelRatio; 1260 } 1261 iContentsX /= dDevicePixelRatio; 1262 iContentsY /= dDevicePixelRatio; 1245 1263 1246 1264 /* Return point shifted according scroll-bars: */ … … 1300 1318 updateViewport(); 1301 1319 } 1302 1303 1320 1304 1321 #ifdef VBOX_WS_MAC … … 1635 1652 else if (!m_fIsDraggingFromGuest) 1636 1653 { 1637 / **@todo Add guest->guest DnD functionality here by getting1638 * the source of guest B (when copying from B to A). */1654 // @todo Add guest->guest DnD functionality here by getting 1655 // the source of guest B (when copying from B to A). 1639 1656 rc = m_pDnDHandler->dragCheckPending(screenId()); 1640 1657 if (RT_SUCCESS(rc)) … … 1662 1679 else 1663 1680 { 1664 / **@todo Add guest->guest DnD functionality here by getting1665 * the source of guest B (when copying from B to A). */1681 // @todo Add guest->guest DnD functionality here by getting 1682 // the source of guest B (when copying from B to A). 1666 1683 rc = m_pDnDHandler->dragStart(screenId()); 1667 1684 … … 1861 1878 1862 1879 /* Take the device-pixel-ratio into account: */ 1863 if (frameBuffer()->useUnscaledHiDPIOutput()) 1864 { 1865 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1866 if (dDevicePixelRatio > 1.0) 1867 size = QSize(size.width() / dDevicePixelRatio, size.height() / dDevicePixelRatio); 1868 } 1880 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1881 if (!frameBuffer()->useUnscaledHiDPIOutput()) 1882 size = QSize(size.width() * dDevicePixelRatio, size.height() * dDevicePixelRatio); 1883 size = QSize(size.width() / dDevicePixelRatio, size.height() / dDevicePixelRatio); 1869 1884 1870 1885 /* Return result: */ … … 1875 1890 { 1876 1891 /* Take the device-pixel-ratio into account: */ 1877 if (frameBuffer()->useUnscaledHiDPIOutput()) 1878 { 1879 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1880 if (dDevicePixelRatio > 1.0) 1881 size = QSize(size.width() * dDevicePixelRatio, size.height() * dDevicePixelRatio); 1882 } 1892 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 1893 size = QSize(size.width() * dDevicePixelRatio, size.height() * dDevicePixelRatio); 1894 if (!frameBuffer()->useUnscaledHiDPIOutput()) 1895 size = QSize(size.width() / dDevicePixelRatio, size.height() / dDevicePixelRatio); 1883 1896 1884 1897 /* Take the scale-factor into account: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp
r69957 r71073 1045 1045 1046 1046 /* Take the device-pixel-ratio into account: */ 1047 if (pFrameBuffer->useUnscaledHiDPIOutput()) 1047 const double dDevicePixelRatio = pFrameBuffer->devicePixelRatio(); 1048 cpnt.setX(cpnt.x() * dDevicePixelRatio); 1049 cpnt.setY(cpnt.y() * dDevicePixelRatio); 1050 if (!pFrameBuffer->useUnscaledHiDPIOutput()) 1048 1051 { 1049 const double dDevicePixelRatio = pFrameBuffer->devicePixelRatio(); 1050 if (dDevicePixelRatio > 1.0) 1051 { 1052 cpnt.setX((int)(cpnt.x() * dDevicePixelRatio)); 1053 cpnt.setY((int)(cpnt.y() * dDevicePixelRatio)); 1054 } 1052 cpnt.setX(cpnt.x() / dDevicePixelRatio); 1053 cpnt.setY(cpnt.y() / dDevicePixelRatio); 1055 1054 } 1056 1055 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp
r70996 r71073 66 66 const double dDevicePixelRatio = frameBuffer()->devicePixelRatio(); 67 67 const bool fUseUnscaledHiDPIOutput = frameBuffer()->useUnscaledHiDPIOutput(); 68 if (dDevicePixelRatio > 1.0 && fUseUnscaledHiDPIOutput) 69 scaledSize *= dDevicePixelRatio; 68 scaledSize *= dDevicePixelRatio; 69 if (!fUseUnscaledHiDPIOutput) 70 scaledSize /= dDevicePixelRatio; 70 71 frameBuffer()->setScaledSize(scaledSize); 71 72 frameBuffer()->performRescale(); … … 158 159 /* Propagate unscaled-hidpi-output feature to 3D service if necessary: */ 159 160 if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable()) 160 {161 161 display().NotifyHiDPIOutputPolicyChange(fUseUnscaledHiDPIOutput); 162 }163 162 164 163 /* Perform frame-buffer rescaling: */
Note:
See TracChangeset
for help on using the changeset viewer.

