VirtualBox

Changeset 53520 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 12, 2014 10:47:13 AM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Mac OS X: 6278: Support for unscaled HiDPI (Retina) video-output: Seamless mode: Separate erase-method for HiDPI-aware screens.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
2 edited

Legend:

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

    r53518 r53520  
    865865void UIFrameBuffer::paintDefault(QPaintEvent *pEvent)
    866866{
    867     /* Prepare the 'paint' rectangle: */
    868     QRect paintRect = pEvent->rect();
    869 
    870     /* Take the backing-scale-factor into account: */
    871     if (useUnscaledHiDPIOutput() && backingScaleFactor() > 1.0)
    872     {
    873         paintRect.moveTo(paintRect.topLeft() * backingScaleFactor());
    874         paintRect.setSize(paintRect.size() * backingScaleFactor());
    875     }
    876 
    877867    /* Scaled image is NULL by default: */
    878868    QImage scaledImage;
     
    889879    const QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage;
    890880
     881    /* Prepare the 'paint' rectangle: */
     882    QRect paintRect = pEvent->rect();
     883
     884    /* Take the backing-scale-factor into account: */
     885    if (useUnscaledHiDPIOutput() && backingScaleFactor() > 1.0)
     886    {
     887        paintRect.moveTo(paintRect.topLeft() * backingScaleFactor());
     888        paintRect.setSize(paintRect.size() * backingScaleFactor());
     889    }
     890
    891891    /* Make sure paint-rectangle is within the image boundary: */
    892892    paintRect = paintRect.intersected(sourceImage.rect());
     
    905905void UIFrameBuffer::paintSeamless(QPaintEvent *pEvent)
    906906{
    907     /* Prepare the 'paint' rectangle: */
    908     QRect paintRect = pEvent->rect();
    909 
    910     /* Take the backing-scale-factor into account: */
    911     if (useUnscaledHiDPIOutput() && backingScaleFactor() > 1.0)
    912     {
    913         paintRect.moveTo(paintRect.topLeft() * backingScaleFactor());
    914         paintRect.setSize(paintRect.size() * backingScaleFactor());
    915     }
    916 
    917907    /* Scaled image is NULL by default: */
    918908    QImage scaledImage;
     
    929919    const QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage;
    930920
     921    /* Prepare the 'paint' rectangle: */
     922    QRect paintRect = pEvent->rect();
     923
     924    /* Take the backing-scale-factor into account: */
     925    if (useUnscaledHiDPIOutput() && backingScaleFactor() > 1.0)
     926    {
     927        paintRect.moveTo(paintRect.topLeft() * backingScaleFactor());
     928        paintRect.setSize(paintRect.size() * backingScaleFactor());
     929    }
     930
    931931    /* Make sure paint-rectangle is within the image boundary: */
    932932    paintRect = paintRect.intersected(sourceImage.rect());
     
    947947        /* Erase required region, slowly, rectangle-by-rectangle: */
    948948        foreach (const QRect &rect, regionToErase.rects())
    949             painter.eraseRect(rect);
     949            eraseImageRect(painter, rect,
     950                           useUnscaledHiDPIOutput(), hiDPIOptimizationType(), backingScaleFactor());
    950951        /* Restore composition-mode: */
    951952        painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
     
    981982
    982983/* static */
     984void UIFrameBuffer::eraseImageRect(QPainter &painter, const QRect &rect,
     985                                   bool fUseUnscaledHiDPIOutput,
     986                                   HiDPIOptimizationType hiDPIOptimizationType,
     987                                   double dBackingScaleFactor)
     988{
     989    /* Prepare sub-pixmap: */
     990    QPixmap subPixmap = QPixmap(rect.width(), rect.height());
     991
     992    /* If HiDPI 'backing scale factor' defined: */
     993    if (dBackingScaleFactor > 1.0)
     994    {
     995        /* Should we
     996         * perform logical HiDPI scaling and optimize it for performance? */
     997        if (!fUseUnscaledHiDPIOutput && hiDPIOptimizationType == HiDPIOptimizationType_Performance)
     998        {
     999            /* Adjust sub-pixmap: */
     1000            subPixmap = QPixmap(rect.width() * dBackingScaleFactor,
     1001                                rect.height() * dBackingScaleFactor);
     1002        }
     1003
     1004#ifdef Q_WS_MAC
     1005# ifdef VBOX_GUI_WITH_HIDPI
     1006        /* Should we
     1007         * do not perform logical HiDPI scaling or
     1008         * perform logical HiDPI scaling and optimize it for performance? */
     1009        if (fUseUnscaledHiDPIOutput || hiDPIOptimizationType == HiDPIOptimizationType_Performance)
     1010        {
     1011            /* Mark sub-pixmap as HiDPI: */
     1012            subPixmap.setDevicePixelRatio(dBackingScaleFactor);
     1013        }
     1014# endif /* VBOX_GUI_WITH_HIDPI */
     1015#endif /* Q_WS_MAC */
     1016    }
     1017
     1018    /* Which point we should draw corresponding sub-pixmap? */
     1019    QPointF paintPoint = rect.topLeft();
     1020
     1021    /* Take the backing-scale-factor into account: */
     1022    if (fUseUnscaledHiDPIOutput && dBackingScaleFactor > 1.0)
     1023        paintPoint /= dBackingScaleFactor;
     1024
     1025    /* Draw sub-pixmap: */
     1026    painter.drawPixmap(paintPoint, subPixmap);
     1027}
     1028
     1029/* static */
    9831030void UIFrameBuffer::drawImageRect(QPainter &painter, const QImage &image, const QRect &rect,
    9841031                                  int iContentsShiftX, int iContentsShiftY,
     
    10311078
    10321079    /* Which point we should draw corresponding sub-pixmap? */
    1033     QPoint paintPoint = rect.topLeft();
     1080    QPointF paintPoint = rect.topLeft();
    10341081
    10351082    /* Take the backing-scale-factor into account: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r53518 r53520  
    252252    void paintSeamless(QPaintEvent *pEvent);
    253253
     254    /** Erases corresponding @a rect with @a painter. */
     255    static void eraseImageRect(QPainter &painter, const QRect &rect,
     256                               bool fUseUnscaledHiDPIOutput,
     257                               HiDPIOptimizationType hiDPIOptimizationType,
     258                               double dBackingScaleFactor);
    254259    /** Draws corresponding @a rect of passed @a image with @a painter. */
    255260    static void drawImageRect(QPainter &painter, const QImage &image, const QRect &rect,
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