Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-03-15 17:29:00 +08:00
parent fde00ab7ea
commit 942fd02b66
2 changed files with 6 additions and 4 deletions

View File

@ -45,11 +45,13 @@ int main(int argc, char *argv[])
QGuiApplication application(argc, argv); QGuiApplication application(argc, argv);
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
if (!qEnvironmentVariableIsSet("QSG_RHI_BACKEND")) {
# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) # if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QQuickWindow::setGraphicsApi(QSGRendererInterface::Direct3D11); QQuickWindow::setGraphicsApi(QSGRendererInterface::Software);
# elif (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) # elif (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Direct3D11Rhi); QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
# endif # endif
}
#endif #endif
QScopedPointer<FramelessQuickHelper> framelessHelper(new FramelessQuickHelper); QScopedPointer<FramelessQuickHelper> framelessHelper(new FramelessQuickHelper);

View File

@ -40,7 +40,7 @@
#include "qwinregistry_p.h" #include "qwinregistry_p.h"
#include "framelesshelper_windows.h" #include "framelesshelper_windows.h"
#include <atlbase.h> #include <atlbase.h>
#include <d2d1.h> #include <d2d1_1.h>
Q_DECLARE_METATYPE(QMargins) Q_DECLARE_METATYPE(QMargins)
@ -611,7 +611,7 @@ quint32 Utilities::getPrimaryScreenDpi(const bool horizontal)
reinterpret_cast<HRESULT(WINAPI *)(D2D1_FACTORY_TYPE, REFIID, void **)>( reinterpret_cast<HRESULT(WINAPI *)(D2D1_FACTORY_TYPE, REFIID, void **)>(
QSystemLibrary::resolve(QStringLiteral("d2d1"), "D2D1CreateFactory")); QSystemLibrary::resolve(QStringLiteral("d2d1"), "D2D1CreateFactory"));
if (pD2D1CreateFactory) { if (pD2D1CreateFactory) {
CComPtr<ID2D1Factory> d2dFactory = nullptr; CComPtr<ID2D1Factory1> d2dFactory = nullptr;
if (SUCCEEDED(pD2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, IID_PPV_ARGS(&d2dFactory)))) { if (SUCCEEDED(pD2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, IID_PPV_ARGS(&d2dFactory)))) {
if (SUCCEEDED(d2dFactory->ReloadSystemMetrics())) { if (SUCCEEDED(d2dFactory->ReloadSystemMetrics())) {
FLOAT dpiX = 0.0, dpiY = 0.0; FLOAT dpiX = 0.0, dpiY = 0.0;