VirtualBox

Changeset 71034 in vbox for trunk


Ignore:
Timestamp:
Feb 15, 2018 5:26:40 PM (7 years ago)
Author:
vboxsync
Message:

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

File:
1 edited

Legend:

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

    r71033 r71034  
    13491349void UIFrameBufferPrivate::paintDefault(QPaintEvent *pEvent)
    13501350{
    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: */
    13601363        switch (m_pMachineView->visualStateType())
    13611364        {
    13621365            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())));
    13651368                break;
    13661369            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)));
    13691372                break;
    13701373        }
    13711374    }
    1372     /* Finally we are choosing image to paint from: */
    1373     const QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage;
    13741375
    13751376    /* Prepare the base and hidpi paint rectangles: */
     
    13851386
    13861387    /* Make sure hidpi paint rectangle is within the image boundary: */
    1387     paintRectHiDPI = paintRectHiDPI.intersected(sourceImage.rect());
     1388    paintRectHiDPI = paintRectHiDPI.intersected(pSourceImage->rect());
    13881389    if (paintRectHiDPI.isEmpty())
    13891390        return;
     
    14001401
    14011402    /* Draw hidpi image rectangle: */
    1402     drawImageRect(painter, sourceImage, paintRectHiDPI,
     1403    drawImageRect(painter, *pSourceImage, paintRectHiDPI,
    14031404                  m_pMachineView->contentsX(), m_pMachineView->contentsY(),
    14041405                  useUnscaledHiDPIOutput(),
     
    14071408#endif
    14081409                  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    }
    14091418}
    14101419
    14111420void UIFrameBufferPrivate::paintSeamless(QPaintEvent *pEvent)
    14121421{
    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: */
    14221434        switch (m_pMachineView->visualStateType())
    14231435        {
    14241436            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())));
    14271439                break;
    14281440            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)));
    14311443                break;
    14321444        }
    14331445    }
    1434     /* Finally we are choosing image to paint from: */
    1435     const QImage &sourceImage = scaledImage.isNull() ? m_image : scaledImage;
    14361446
    14371447    /* Prepare the base and hidpi paint rectangles: */
     
    14471457
    14481458    /* Make sure hidpi paint rectangle is within the image boundary: */
    1449     paintRectHiDPI = paintRectHiDPI.intersected(sourceImage.rect());
     1459    paintRectHiDPI = paintRectHiDPI.intersected(pSourceImage->rect());
    14501460    if (paintRectHiDPI.isEmpty())
    14511461        return;
     
    14821492
    14831493    /* Draw hidpi image rectangle: */
    1484     drawImageRect(painter, sourceImage, paintRectHiDPI,
     1494    drawImageRect(painter, *pSourceImage, paintRectHiDPI,
    14851495                  m_pMachineView->contentsX(), m_pMachineView->contentsY(),
    14861496                  useUnscaledHiDPIOutput(),
     
    14891499#endif
    14901500                  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    }
    14911509}
    14921510
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