VirtualBox

Ignore:
Timestamp:
Jan 22, 2018 4:41:57 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8694: Runtime UI: Make Unscaled HiDPI Output mode work with 3D support on Windows/X11 (well, generally).

File:
1 edited

Legend:

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

    r70627 r70680  
    255255    if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
    256256    {
     257        double dScaleFactorFor3D = dScaleFactor;
     258#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
     259        // WORKAROUND:
     260        // On Windows and Linux opposing to macOS it's only Qt which can auto scale up,
     261        // not 3D overlay itself, so for auto scale-up mode we have to take that into account.
     262        if (!fUseUnscaledHiDPIOutput)
     263            dScaleFactorFor3D *= frameBuffer()->devicePixelRatio();
     264#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
    257265        display().NotifyScaleFactorChange(m_uScreenId,
    258                                           (uint32_t)(dScaleFactor * VBOX_OGL_SCALE_FACTOR_MULTIPLIER),
    259                                           (uint32_t)(dScaleFactor * VBOX_OGL_SCALE_FACTOR_MULTIPLIER));
     266                                          (uint32_t)(dScaleFactorFor3D * VBOX_OGL_SCALE_FACTOR_MULTIPLIER),
     267                                          (uint32_t)(dScaleFactorFor3D * VBOX_OGL_SCALE_FACTOR_MULTIPLIER));
    260268        display().NotifyHiDPIOutputPolicyChange(fUseUnscaledHiDPIOutput);
    261269    }
     
    487495    /* Take the scale-factor into account: */
    488496    const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
     497    const bool fUseUnscaledHiDPIOutput = gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid());
    489498    frameBuffer()->setScaleFactor(dScaleFactor);
    490499    /* Propagate the scale-factor to 3D service if necessary: */
    491500    if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
    492501    {
     502        double dScaleFactorFor3D = dScaleFactor;
     503#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
     504        // WORKAROUND:
     505        // On Windows and Linux opposing to macOS it's only Qt which can auto scale up,
     506        // not 3D overlay itself, so for auto scale-up mode we have to take that into account.
     507        if (!fUseUnscaledHiDPIOutput)
     508            dScaleFactorFor3D *= frameBuffer()->devicePixelRatio();
     509#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
    493510        display().NotifyScaleFactorChange(m_uScreenId,
    494                                           (uint32_t)(dScaleFactor * VBOX_OGL_SCALE_FACTOR_MULTIPLIER),
    495                                           (uint32_t)(dScaleFactor * VBOX_OGL_SCALE_FACTOR_MULTIPLIER));
     511                                          (uint32_t)(dScaleFactorFor3D * VBOX_OGL_SCALE_FACTOR_MULTIPLIER),
     512                                          (uint32_t)(dScaleFactorFor3D * VBOX_OGL_SCALE_FACTOR_MULTIPLIER));
    496513    }
    497514
     
    705722        m_pFrameBuffer->setScalingOptimizationType(gEDataManager->scalingOptimizationType(vboxGlobal().managedVMUuid()));
    706723
    707         /* Take device-pixel-ratio into account: */
    708         m_pFrameBuffer->setDevicePixelRatio(gpDesktop->devicePixelRatio(machineWindow()));
    709 
    710724        /* Take the scale-factor related attributes into account: */
     725        const double dDevicePixelRatio = gpDesktop->devicePixelRatio(machineWindow());
    711726        const double dScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid());
    712727        const bool fUseUnscaledHiDPIOutput = gEDataManager->useUnscaledHiDPIOutput(vboxGlobal().managedVMUuid());
     728        m_pFrameBuffer->setDevicePixelRatio(dDevicePixelRatio);
    713729        m_pFrameBuffer->setScaleFactor(dScaleFactor);
    714730        m_pFrameBuffer->setUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput);
     
    716732        if (machine().GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable())
    717733        {
     734            double dScaleFactorFor3D = dScaleFactor;
     735#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
     736            // WORKAROUND:
     737            // On Windows and Linux opposing to macOS it's only Qt which can auto scale up,
     738            // not 3D overlay itself, so for auto scale-up mode we have to take that into account.
     739            if (!fUseUnscaledHiDPIOutput)
     740                dScaleFactorFor3D *= dDevicePixelRatio;
     741#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
    718742            display().NotifyScaleFactorChange(m_uScreenId,
    719                                               (uint32_t)(dScaleFactor * VBOX_OGL_SCALE_FACTOR_MULTIPLIER),
    720                                               (uint32_t)(dScaleFactor * VBOX_OGL_SCALE_FACTOR_MULTIPLIER));
     743                                              (uint32_t)(dScaleFactorFor3D * VBOX_OGL_SCALE_FACTOR_MULTIPLIER),
     744                                              (uint32_t)(dScaleFactorFor3D * VBOX_OGL_SCALE_FACTOR_MULTIPLIER));
    721745            display().NotifyHiDPIOutputPolicyChange(fUseUnscaledHiDPIOutput);
    722746        }
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