VirtualBox

Changeset 53521 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Dec 12, 2014 11:00:58 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97262
Message:

FE/Qt: Runtime UI: Seamless mode: Use painter-clipping instead of partial painting technique.

File:
1 edited

Legend:

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

    r53520 r53521  
    922922    QRect paintRect = pEvent->rect();
    923923
     924    /* Prepare seamless regions to erase/paint: */
     925    lock();
     926    const QRegion eraseRegion = QRegion(paintRect) - m_syncVisibleRegion;
     927    const QRegion paintRegion = QRegion(paintRect) & m_syncVisibleRegion;
     928    unlock();
     929
    924930    /* Take the backing-scale-factor into account: */
    925931    if (useUnscaledHiDPIOutput() && backingScaleFactor() > 1.0)
     
    937943    QPainter painter(m_pMachineView->viewport());
    938944
    939     /* Determine the region to erase: */
    940     lock();
    941     QRegion regionToErase = (QRegion)paintRect - m_syncVisibleRegion;
    942     unlock();
    943     if (!regionToErase.isEmpty())
    944     {
    945         /* Optimize composition-mode: */
    946         painter.setCompositionMode(QPainter::CompositionMode_Clear);
    947         /* Erase required region, slowly, rectangle-by-rectangle: */
    948         foreach (const QRect &rect, regionToErase.rects())
    949             eraseImageRect(painter, rect,
    950                            useUnscaledHiDPIOutput(), hiDPIOptimizationType(), backingScaleFactor());
    951         /* Restore composition-mode: */
    952         painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    953     }
    954 
    955     /* Determine the region to paint: */
    956     lock();
    957     QRegion regionToPaint = (QRegion)paintRect & m_syncVisibleRegion;
    958     unlock();
    959     if (!regionToPaint.isEmpty())
    960     {
    961         /* Paint required region, slowly, rectangle-by-rectangle: */
    962         foreach (const QRect &rect, regionToPaint.rects())
    963         {
     945    /* Apply painter clipping for erasing: */
     946    painter.setClipRegion(eraseRegion);
     947    /* Set composition-mode to erase: */
     948    painter.setCompositionMode(QPainter::CompositionMode_Clear);
     949    /* Erase rectangle: */
     950    eraseImageRect(painter, paintRect,
     951                   useUnscaledHiDPIOutput(), hiDPIOptimizationType(), backingScaleFactor());
     952
     953    /* Apply painter clipping for painting: */
     954    painter.setClipRegion(paintRegion);
     955    /* Set composition-mode to paint: */
     956    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    964957#if defined(VBOX_WITH_TRANSLUCENT_SEAMLESS)
    965958# if defined(Q_WS_WIN) || defined(Q_WS_X11)
    966             /* Replace translucent background with black one,
    967              * that is necessary for window with Qt::WA_TranslucentBackground
    968              * and no native backing store support like Mac OS X has: */
    969             painter.setCompositionMode(QPainter::CompositionMode_Source);
    970             painter.fillRect(rect, QColor(Qt::black));
    971             painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
     959    /* Replace translucent background with black one,
     960     * that is necessary for window with Qt::WA_TranslucentBackground
     961     * and no native backing store support like Mac OS X has: */
     962    painter.setCompositionMode(QPainter::CompositionMode_Source);
     963    painter.fillRect(paintRect, QColor(Qt::black));
     964    painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
    972965# endif /* Q_WS_WIN || Q_WS_X11 */
    973966#endif /* VBOX_WITH_TRANSLUCENT_SEAMLESS */
    974 
    975             /* Draw image rectangle: */
    976             drawImageRect(painter, sourceImage, rect,
    977                           m_pMachineView->contentsX(), m_pMachineView->contentsY(),
    978                           useUnscaledHiDPIOutput(), hiDPIOptimizationType(), backingScaleFactor());
    979         }
    980     }
     967    /* Paint rectangle: */
     968    drawImageRect(painter, sourceImage, paintRect,
     969                  m_pMachineView->contentsX(), m_pMachineView->contentsY(),
     970                  useUnscaledHiDPIOutput(), hiDPIOptimizationType(), backingScaleFactor());
    981971}
    982972
Note: See TracChangeset for help on using the changeset viewer.

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