- Timestamp:
- Feb 15, 2018 5:26:40 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
r71033 r71034 1349 1349 void UIFrameBufferPrivate::paintDefault(QPaintEvent *pEvent) 1350 1350 { 1351 /* Scaled image is NULL by default: */ 1352 QImage scaledImage; 1353 /* But if scale-factor is set and current image is NOT null: */ 1354 if (m_scaledSize.isValid() && !m_image.isNull()) 1355 { 1356 /* We are doing a deep copy of the image to make sure it will not be 1357 * detached during scale process, otherwise we can get a frozen frame-buffer. */ 1358 scaledImage = m_image.copy(); 1359 /* And scaling the image to predefined scale-factor: */ 1351 /* Make sure cached image is valid: */ 1352 if (m_image.isNull()) 1353 return; 1354 1355 /* First we take the cached image as the source: */ 1356 QImage *pSourceImage = &m_image; 1357 1358 /* But if scaled size is set: */ 1359 if (m_scaledSize.isValid()) 1360 { 1361 /* We scale the image to requested size and retain it 1362 * by making heap shallow copy of that temporary object: */ 1360 1363 switch (m_pMachineView->visualStateType()) 1361 1364 { 1362 1365 case UIVisualStateType_Scale: 1363 scaledImage = scaledImage.scaled(m_scaledSize, Qt::IgnoreAspectRatio,1364 transformationMode(scalingOptimizationType()));1366 pSourceImage = new QImage(pSourceImage->scaled(m_scaledSize, Qt::IgnoreAspectRatio, 1367 transformationMode(scalingOptimizationType()))); 1365 1368 break; 1366 1369 default: 1367 scaledImage = scaledImage.scaled(m_scaledSize, Qt::IgnoreAspectRatio,1368 transformationMode(scalingOptimizationType(), m_dScaleFactor));1370 pSourceImage = new QImage(pSourceImage->scaled(m_scaledSize, Qt::IgnoreAspectRatio, 1371 transformationMode(scalingOptimizationType(), m_dScaleFactor))); 1369 1372 break; 1370 1373 } 1371 1374 } 1372 /* Finally we are choosing image to paint from: */1373 const QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage;1374 1375 1375 1376 /* Prepare the base and hidpi paint rectangles: */ … … 1385 1386 1386 1387 /* Make sure hidpi paint rectangle is within the image boundary: */ 1387 paintRectHiDPI = paintRectHiDPI.intersected( sourceImage.rect());1388 paintRectHiDPI = paintRectHiDPI.intersected(pSourceImage->rect()); 1388 1389 if (paintRectHiDPI.isEmpty()) 1389 1390 return; … … 1400 1401 1401 1402 /* Draw hidpi image rectangle: */ 1402 drawImageRect(painter, sourceImage, paintRectHiDPI,1403 drawImageRect(painter, *pSourceImage, paintRectHiDPI, 1403 1404 m_pMachineView->contentsX(), m_pMachineView->contentsY(), 1404 1405 useUnscaledHiDPIOutput(), … … 1407 1408 #endif 1408 1409 devicePixelRatio()); 1410 1411 /* If scaled size is set: */ 1412 if (m_scaledSize.isValid()) 1413 { 1414 /* Wipe out copied image: */ 1415 delete pSourceImage; 1416 pSourceImage = 0; 1417 } 1409 1418 } 1410 1419 1411 1420 void UIFrameBufferPrivate::paintSeamless(QPaintEvent *pEvent) 1412 1421 { 1413 /* Scaled image is NULL by default: */ 1414 QImage scaledImage; 1415 /* But if scale-factor is set and current image is NOT null: */ 1416 if (m_scaledSize.isValid() && !m_image.isNull()) 1417 { 1418 /* We are doing a deep copy of the image to make sure it will not be 1419 * detached during scale process, otherwise we can get a frozen frame-buffer. */ 1420 scaledImage = m_image.copy(); 1421 /* And scaling the image to predefined scale-factor: */ 1422 /* Make sure cached image is valid: */ 1423 if (m_image.isNull()) 1424 return; 1425 1426 /* First we take the cached image as the source: */ 1427 QImage *pSourceImage = &m_image; 1428 1429 /* But if scaled size is set: */ 1430 if (m_scaledSize.isValid()) 1431 { 1432 /* We scale the image to requested size and retain it 1433 * by making heap shallow copy of that temporary object: */ 1422 1434 switch (m_pMachineView->visualStateType()) 1423 1435 { 1424 1436 case UIVisualStateType_Scale: 1425 scaledImage = scaledImage.scaled(m_scaledSize, Qt::IgnoreAspectRatio,1426 transformationMode(scalingOptimizationType()));1437 pSourceImage = new QImage(pSourceImage->scaled(m_scaledSize, Qt::IgnoreAspectRatio, 1438 transformationMode(scalingOptimizationType()))); 1427 1439 break; 1428 1440 default: 1429 scaledImage = scaledImage.scaled(m_scaledSize, Qt::IgnoreAspectRatio,1430 transformationMode(scalingOptimizationType(), m_dScaleFactor));1441 pSourceImage = new QImage(pSourceImage->scaled(m_scaledSize, Qt::IgnoreAspectRatio, 1442 transformationMode(scalingOptimizationType(), m_dScaleFactor))); 1431 1443 break; 1432 1444 } 1433 1445 } 1434 /* Finally we are choosing image to paint from: */1435 const QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage;1436 1446 1437 1447 /* Prepare the base and hidpi paint rectangles: */ … … 1447 1457 1448 1458 /* Make sure hidpi paint rectangle is within the image boundary: */ 1449 paintRectHiDPI = paintRectHiDPI.intersected( sourceImage.rect());1459 paintRectHiDPI = paintRectHiDPI.intersected(pSourceImage->rect()); 1450 1460 if (paintRectHiDPI.isEmpty()) 1451 1461 return; … … 1482 1492 1483 1493 /* Draw hidpi image rectangle: */ 1484 drawImageRect(painter, sourceImage, paintRectHiDPI,1494 drawImageRect(painter, *pSourceImage, paintRectHiDPI, 1485 1495 m_pMachineView->contentsX(), m_pMachineView->contentsY(), 1486 1496 useUnscaledHiDPIOutput(), … … 1489 1499 #endif 1490 1500 devicePixelRatio()); 1501 1502 /* If scaled size is set: */ 1503 if (m_scaledSize.isValid()) 1504 { 1505 /* Wipe out copied image: */ 1506 delete pSourceImage; 1507 pSourceImage = 0; 1508 } 1491 1509 } 1492 1510
Note:
See TracChangeset
for help on using the changeset viewer.