Changeset 71057 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Feb 19, 2018 2:27:09 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120920
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r71056 r71057 294 294 /** Erases corresponding @a rect with @a painter. */ 295 295 static void eraseImageRect(QPainter &painter, const QRect &rect, 296 bool fUseUnscaledHiDPIOutput,297 296 double dDevicePixelRatio); 298 297 /** Draws corresponding @a rect of passed @a image with @a painter. */ 299 298 static void drawImageRect(QPainter &painter, const QImage &image, const QRect &rect, 300 299 int iContentsShiftX, int iContentsShiftY, 301 bool fUseUnscaledHiDPIOutput,302 300 double dDevicePixelRatio); 303 301 … … 1336 1334 QImage *pSourceImage = &m_image; 1337 1335 1338 /* But if scaled size is set: */ 1339 if (m_scaledSize.isValid()) 1340 { 1336 /* But if we should scale image by some reason: */ 1337 if ( scaledSize().isValid() 1338 || (!useUnscaledHiDPIOutput() && devicePixelRatio() != 1.0)) 1339 { 1340 /* Calculate final scaled size: */ 1341 QSize effectiveSize = !scaledSize().isValid() ? pSourceImage->size() : scaledSize(); 1342 /* Take the device-pixel-ratio into account: */ 1343 if (!useUnscaledHiDPIOutput() && devicePixelRatio() != 1.0) 1344 effectiveSize *= devicePixelRatio(); 1341 1345 /* We scale the image to requested size and retain it 1342 1346 * by making heap shallow copy of that temporary object: */ … … 1344 1348 { 1345 1349 case UIVisualStateType_Scale: 1346 pSourceImage = new QImage(pSourceImage->scaled( m_scaledSize, Qt::IgnoreAspectRatio,1350 pSourceImage = new QImage(pSourceImage->scaled(effectiveSize, Qt::IgnoreAspectRatio, 1347 1351 transformationMode(scalingOptimizationType()))); 1348 1352 break; 1349 1353 default: 1350 pSourceImage = new QImage(pSourceImage->scaled( m_scaledSize, Qt::IgnoreAspectRatio,1354 pSourceImage = new QImage(pSourceImage->scaled(effectiveSize, Qt::IgnoreAspectRatio, 1351 1355 transformationMode(scalingOptimizationType(), m_dScaleFactor))); 1352 1356 break; … … 1354 1358 } 1355 1359 1360 /* Take the device-pixel-ratio into account: */ 1361 pSourceImage->setDevicePixelRatio(devicePixelRatio()); 1362 1356 1363 /* Prepare the base and hidpi paint rectangles: */ 1357 1364 const QRect paintRect = pEvent->rect(); … … 1359 1366 1360 1367 /* Take the device-pixel-ratio into account: */ 1361 if (useUnscaledHiDPIOutput() && devicePixelRatio() > 1.0) 1362 { 1363 paintRectHiDPI.moveTo(paintRectHiDPI.topLeft() * devicePixelRatio()); 1364 paintRectHiDPI.setSize(paintRectHiDPI.size() * devicePixelRatio()); 1365 } 1368 paintRectHiDPI.moveTo(paintRectHiDPI.topLeft() * devicePixelRatio()); 1369 paintRectHiDPI.setSize(paintRectHiDPI.size() * devicePixelRatio()); 1366 1370 1367 1371 /* Make sure hidpi paint rectangle is within the image boundary: */ … … 1383 1387 drawImageRect(painter, *pSourceImage, paintRectHiDPI, 1384 1388 m_pMachineView->contentsX(), m_pMachineView->contentsY(), 1385 useUnscaledHiDPIOutput(),1386 1389 devicePixelRatio()); 1387 1390 1388 /* If scaled size is set: */ 1389 if (m_scaledSize.isValid()) 1391 /* If we had to scale image for some reason: */ 1392 if ( scaledSize().isValid() 1393 || (!useUnscaledHiDPIOutput() && devicePixelRatio() != 1.0)) 1390 1394 { 1391 1395 /* Wipe out copied image: */ … … 1404 1408 QImage *pSourceImage = &m_image; 1405 1409 1406 /* But if scaled size is set: */ 1407 if (m_scaledSize.isValid()) 1408 { 1410 /* But if we should scale image by some reason: */ 1411 if ( scaledSize().isValid() 1412 || (!useUnscaledHiDPIOutput() && devicePixelRatio() != 1.0)) 1413 { 1414 /* Calculate final scaled size: */ 1415 QSize effectiveSize = !scaledSize().isValid() ? pSourceImage->size() : scaledSize(); 1416 /* Take the device-pixel-ratio into account: */ 1417 if (!useUnscaledHiDPIOutput() && devicePixelRatio() != 1.0) 1418 effectiveSize *= devicePixelRatio(); 1409 1419 /* We scale the image to requested size and retain it 1410 1420 * by making heap shallow copy of that temporary object: */ … … 1412 1422 { 1413 1423 case UIVisualStateType_Scale: 1414 pSourceImage = new QImage(pSourceImage->scaled( m_scaledSize, Qt::IgnoreAspectRatio,1424 pSourceImage = new QImage(pSourceImage->scaled(effectiveSize, Qt::IgnoreAspectRatio, 1415 1425 transformationMode(scalingOptimizationType()))); 1416 1426 break; 1417 1427 default: 1418 pSourceImage = new QImage(pSourceImage->scaled( m_scaledSize, Qt::IgnoreAspectRatio,1428 pSourceImage = new QImage(pSourceImage->scaled(effectiveSize, Qt::IgnoreAspectRatio, 1419 1429 transformationMode(scalingOptimizationType(), m_dScaleFactor))); 1420 1430 break; … … 1422 1432 } 1423 1433 1434 /* Take the device-pixel-ratio into account: */ 1435 pSourceImage->setDevicePixelRatio(devicePixelRatio()); 1436 1424 1437 /* Prepare the base and hidpi paint rectangles: */ 1425 1438 const QRect paintRect = pEvent->rect(); … … 1427 1440 1428 1441 /* Take the device-pixel-ratio into account: */ 1429 if (useUnscaledHiDPIOutput() && devicePixelRatio() > 1.0) 1430 { 1431 paintRectHiDPI.moveTo(paintRectHiDPI.topLeft() * devicePixelRatio()); 1432 paintRectHiDPI.setSize(paintRectHiDPI.size() * devicePixelRatio()); 1433 } 1442 paintRectHiDPI.moveTo(paintRectHiDPI.topLeft() * devicePixelRatio()); 1443 paintRectHiDPI.setSize(paintRectHiDPI.size() * devicePixelRatio()); 1434 1444 1435 1445 /* Make sure hidpi paint rectangle is within the image boundary: */ … … 1449 1459 /* Erase hidpi rectangle: */ 1450 1460 eraseImageRect(painter, paintRectHiDPI, 1451 useUnscaledHiDPIOutput(),1452 1461 devicePixelRatio()); 1453 1462 … … 1468 1477 drawImageRect(painter, *pSourceImage, paintRectHiDPI, 1469 1478 m_pMachineView->contentsX(), m_pMachineView->contentsY(), 1470 useUnscaledHiDPIOutput(),1471 1479 devicePixelRatio()); 1472 1480 1473 /* If scaled size is set: */ 1474 if (m_scaledSize.isValid()) 1481 /* If we had to scale image for some reason: */ 1482 if ( scaledSize().isValid() 1483 || (!useUnscaledHiDPIOutput() && devicePixelRatio() != 1.0)) 1475 1484 { 1476 1485 /* Wipe out copied image: */ … … 1495 1504 /* static */ 1496 1505 void UIFrameBufferPrivate::eraseImageRect(QPainter &painter, const QRect &rect, 1497 bool fUseUnscaledHiDPIOutput,1498 1506 double dDevicePixelRatio) 1499 1507 { 1500 1508 /* Prepare sub-pixmap: */ 1501 1509 QPixmap subPixmap = QPixmap(rect.width(), rect.height()); 1502 1503 /* If HiDPI 'device-pixel-ratio' defined: */ 1504 if (dDevicePixelRatio > 1.0) 1505 { 1506 /* In auto-scale mode: */ 1507 if (!fUseUnscaledHiDPIOutput) 1508 { 1509 /* Adjust sub-pixmap: */ 1510 subPixmap = QPixmap((int)(rect.width() * dDevicePixelRatio), 1511 (int)(rect.height() * dDevicePixelRatio)); 1512 } 1513 1514 /* Mark sub-pixmap HiDPI: */ 1515 subPixmap.setDevicePixelRatio(dDevicePixelRatio); 1516 } 1510 /* Take the device-pixel-ratio into account: */ 1511 subPixmap.setDevicePixelRatio(dDevicePixelRatio); 1517 1512 1518 1513 /* Which point we should draw corresponding sub-pixmap? */ 1519 QPointF paintPoint = rect.topLeft(); 1520 1514 QPoint paintPoint = rect.topLeft(); 1521 1515 /* Take the device-pixel-ratio into account: */ 1522 if (fUseUnscaledHiDPIOutput && dDevicePixelRatio > 1.0) 1523 paintPoint /= dDevicePixelRatio; 1516 paintPoint /= dDevicePixelRatio; 1524 1517 1525 1518 /* Draw sub-pixmap: */ … … 1530 1523 void UIFrameBufferPrivate::drawImageRect(QPainter &painter, const QImage &image, const QRect &rect, 1531 1524 int iContentsShiftX, int iContentsShiftY, 1532 bool fUseUnscaledHiDPIOutput,1533 1525 double dDevicePixelRatio) 1534 1526 { … … 1548 1540 /* Create sub-pixmap on the basis of sub-image above (1st copy involved): */ 1549 1541 QPixmap subPixmap = QPixmap::fromImage(subImage); 1550 1551 /* If HiDPI 'device-pixel-ratio' defined: */ 1552 if (dDevicePixelRatio > 1.0) 1553 { 1554 /* In auto-scale mode: */ 1555 if (!fUseUnscaledHiDPIOutput) 1556 { 1557 /* Fast scale sub-pixmap (2nd copy involved): */ 1558 subPixmap = subPixmap.scaled(subPixmap.size() * dDevicePixelRatio, 1559 Qt::IgnoreAspectRatio, Qt::FastTransformation); 1560 } 1561 1562 /* Mark sub-pixmap HiDPI: */ 1563 subPixmap.setDevicePixelRatio(dDevicePixelRatio); 1564 } 1542 /* Take the device-pixel-ratio into account: */ 1543 subPixmap.setDevicePixelRatio(dDevicePixelRatio); 1565 1544 1566 1545 /* Which point we should draw corresponding sub-pixmap? */ 1567 QPointF paintPoint = rect.topLeft(); 1568 1546 QPoint paintPoint = rect.topLeft(); 1569 1547 /* Take the device-pixel-ratio into account: */ 1570 if (fUseUnscaledHiDPIOutput && dDevicePixelRatio > 1.0) 1571 paintPoint /= dDevicePixelRatio; 1548 paintPoint /= dDevicePixelRatio; 1572 1549 1573 1550 /* Draw sub-pixmap: */
Note:
See TracChangeset
for help on using the changeset viewer.