VirtualBox

Changeset 71033 in vbox for trunk


Ignore:
Timestamp:
Feb 15, 2018 4:59:45 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8694: Runtime UI: Framebuffer: Some rework for painting routines.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r71030 r71033  
    13731373    const QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage;
    13741374
    1375     /* Prepare the 'paint' rectangle: */
    1376     QRect paintRect = pEvent->rect();
     1375    /* Prepare the base and hidpi paint rectangles: */
     1376    const QRect paintRect = pEvent->rect();
     1377    QRect paintRectHiDPI = paintRect;
    13771378
    13781379    /* Take the device-pixel-ratio into account: */
    13791380    if (useUnscaledHiDPIOutput() && devicePixelRatio() > 1.0)
    13801381    {
    1381         paintRect.moveTo(paintRect.topLeft() * devicePixelRatio());
    1382         paintRect.setSize(paintRect.size() * devicePixelRatio());
    1383     }
    1384 
    1385     /* Make sure paint-rectangle is within the image boundary: */
    1386     paintRect = paintRect.intersected(sourceImage.rect());
    1387     if (paintRect.isEmpty())
     1382        paintRectHiDPI.moveTo(paintRectHiDPI.topLeft() * devicePixelRatio());
     1383        paintRectHiDPI.setSize(paintRectHiDPI.size() * devicePixelRatio());
     1384    }
     1385
     1386    /* Make sure hidpi paint rectangle is within the image boundary: */
     1387    paintRectHiDPI = paintRectHiDPI.intersected(sourceImage.rect());
     1388    if (paintRectHiDPI.isEmpty())
    13881389        return;
    13891390
     
    13941395    /* On OSX for Qt5 we need to fill the backing store first: */
    13951396    painter.setCompositionMode(QPainter::CompositionMode_Source);
    1396     painter.fillRect(pEvent->rect(), QColor(Qt::black));
     1397    painter.fillRect(paintRect, QColor(Qt::black));
    13971398    painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
    13981399#endif /* VBOX_WS_MAC */
    13991400
    1400     /* Draw image rectangle: */
    1401     drawImageRect(painter, sourceImage, paintRect,
     1401    /* Draw hidpi image rectangle: */
     1402    drawImageRect(painter, sourceImage, paintRectHiDPI,
    14021403                  m_pMachineView->contentsX(), m_pMachineView->contentsY(),
    14031404                  useUnscaledHiDPIOutput(),
     
    14341435    const QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage;
    14351436
    1436     /* Prepare the 'paint' rectangle: */
    1437     QRect paintRect = pEvent->rect();
    1438 
    1439     /* Prepare seamless regions to erase/paint: */
    1440     lock();
    1441     const QRegion eraseRegion = QRegion(paintRect) - m_syncVisibleRegion;
    1442     const QRegion paintRegion = QRegion(paintRect) & m_syncVisibleRegion;
    1443     unlock();
     1437    /* Prepare the base and hidpi paint rectangles: */
     1438    const QRect paintRect = pEvent->rect();
     1439    QRect paintRectHiDPI = paintRect;
    14441440
    14451441    /* Take the device-pixel-ratio into account: */
    14461442    if (useUnscaledHiDPIOutput() && devicePixelRatio() > 1.0)
    14471443    {
    1448         paintRect.moveTo(paintRect.topLeft() * devicePixelRatio());
    1449         paintRect.setSize(paintRect.size() * devicePixelRatio());
    1450     }
    1451 
    1452     /* Make sure paint-rectangle is within the image boundary: */
    1453     paintRect = paintRect.intersected(sourceImage.rect());
    1454     if (paintRect.isEmpty())
     1444        paintRectHiDPI.moveTo(paintRectHiDPI.topLeft() * devicePixelRatio());
     1445        paintRectHiDPI.setSize(paintRectHiDPI.size() * devicePixelRatio());
     1446    }
     1447
     1448    /* Make sure hidpi paint rectangle is within the image boundary: */
     1449    paintRectHiDPI = paintRectHiDPI.intersected(sourceImage.rect());
     1450    if (paintRectHiDPI.isEmpty())
    14551451        return;
    14561452
     
    14581454    QPainter painter(m_pMachineView->viewport());
    14591455
    1460     /* Apply painter clipping for erasing: */
    1461     painter.setClipRegion(eraseRegion);
    1462     /* Set composition-mode to erase: */
     1456    /* Adjust painter for erasing: */
     1457    lock();
     1458    painter.setClipRegion(QRegion(paintRect) - m_syncVisibleRegion);
    14631459    painter.setCompositionMode(QPainter::CompositionMode_Clear);
    1464     /* Erase rectangle: */
    1465     eraseImageRect(painter, paintRect,
     1460    unlock();
     1461
     1462    /* Erase hidpi rectangle: */
     1463    eraseImageRect(painter, paintRectHiDPI,
    14661464                   useUnscaledHiDPIOutput(),
    14671465#ifdef VBOX_WS_MAC
     
    14701468                   devicePixelRatio());
    14711469
    1472     /* Apply painter clipping for painting: */
    1473     painter.setClipRegion(paintRegion);
    1474     /* Set composition-mode to paint: */
     1470    /* Adjust painter for painting: */
     1471    lock();
     1472    painter.setClipRegion(QRegion(paintRect) & m_syncVisibleRegion);
    14751473    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
     1474    unlock();
    14761475
    14771476#ifdef VBOX_WITH_TRANSLUCENT_SEAMLESS
    14781477    /* In case of translucent seamless for Qt5 we need to fill the backing store first: */
    14791478    painter.setCompositionMode(QPainter::CompositionMode_Source);
    1480     painter.fillRect(pEvent->rect(), QColor(Qt::black));
     1479    painter.fillRect(paintRect, QColor(Qt::black));
    14811480    painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
    14821481#endif /* VBOX_WITH_TRANSLUCENT_SEAMLESS */
    14831482
    1484     /* Draw image rectangle: */
    1485     drawImageRect(painter, sourceImage, paintRect,
     1483    /* Draw hidpi image rectangle: */
     1484    drawImageRect(painter, sourceImage, paintRectHiDPI,
    14861485                  m_pMachineView->contentsX(), m_pMachineView->contentsY(),
    14871486                  useUnscaledHiDPIOutput(),
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette