Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwindowsdirect2dintegration.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtCore/qt_windows.h>
11
12#include "qwindowscontext.h"
13
14#include <qplatformdefs.h>
15#include <QtCore/qcoreapplication.h>
16#include <QtCore/qversionnumber.h>
17#include <QtGui/private/qpixmap_raster_p.h>
18#include <QtGui/qpa/qwindowsysteminterface.h>
19
20#include <QVarLengthArray>
21
23
30
32{
33 static const int bufSize = 512;
34 TCHAR filename[bufSize];
35
36 UINT i = GetSystemDirectory(filename, bufSize);
37 if (i > 0 && i < bufSize) {
38 if (_tcscat_s(filename, bufSize, __TEXT("\\d2d1.dll")) == 0) {
39 DWORD versionInfoSize = GetFileVersionInfoSize(filename, nullptr);
40 if (versionInfoSize) {
41 QVarLengthArray<BYTE> info(static_cast<int>(versionInfoSize));
42 if (GetFileVersionInfo(filename, 0, versionInfoSize, info.data())) {
43 UINT size;
44 DWORD *fi;
45
46 if (VerQueryValue(info.constData(), __TEXT("\\"),
47 reinterpret_cast<void **>(&fi), &size) && size) {
48 const auto *verInfo = reinterpret_cast<const VS_FIXEDFILEINFO *>(fi);
49 return QVersionNumber{HIWORD(verInfo->dwFileVersionMS), LOWORD(verInfo->dwFileVersionMS),
50 HIWORD(verInfo->dwFileVersionLS), LOWORD(verInfo->dwFileVersionLS)};
51 }
52 }
53 }
54 }
55 }
56 return QVersionNumber();
57}
58
60{
61 // 6.2.9200.16492 corresponds to Direct2D 1.1 on Windows 7 SP1 with Platform Update
62 enum : int {
63 D2DMinVersionPart1 = 6,
64 D2DMinVersionPart2 = 2,
65 D2DMinVersionPart3 = 9200,
66 D2DMinVersionPart4 = 16492
67 };
68
69 return QVersionNumber{D2DMinVersionPart1, D2DMinVersionPart2, D2DMinVersionPart3, D2DMinVersionPart4};
70}
71
73{
74 const QVersionNumber systemVersion = systemD2DVersion();
75 const QVersionNumber minimumVersion = minimumD2DVersion();
76 if (!systemVersion.isNull() && systemVersion < minimumVersion) {
77 QString msg = QCoreApplication::translate("QWindowsDirect2DIntegration",
78 "Qt cannot load the direct2d platform plugin because " \
79 "the Direct2D version on this system is too old. The " \
80 "minimum system requirement for this platform plugin " \
81 "is Windows 7 SP1 with Platform Update.\n\n" \
82 "The minimum Direct2D version required is %1. " \
83 "The Direct2D version on this system is %2.")
84 .arg(minimumVersion.toString(), systemVersion.toString());
85
86 QString caption = QCoreApplication::translate("QWindowsDirect2DIntegration",
87 "Cannot load direct2d platform plugin");
88
89 MessageBoxW(nullptr,
90 msg.toStdWString().c_str(),
91 caption.toStdWString().c_str(),
92 MB_OK | MB_ICONERROR);
93
94 return nullptr;
95 }
96
97 auto *integration = new QWindowsDirect2DIntegration(paramList);
98
99 if (!integration->init()) {
100 delete integration;
101 integration = nullptr;
102 }
103
104 return integration;
105}
106
111
116
117
122
127
129{
130 switch (type) {
132 return new QRasterPlatformPixmap(type);
133 break;
134 default:
136 break;
137 }
138}
139
144
149
150QWindowsDirect2DIntegration::QWindowsDirect2DIntegration(const QStringList &paramList)
151 : QWindowsIntegration(paramList)
153{
154}
155
156bool QWindowsDirect2DIntegration::init()
157{
158 return d->m_d2dContext.init();
159}
160
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
The QPlatformBackingStore class provides the drawing area for top-level windows.
The QPlatformNativeInterface class provides an abstraction for retrieving native resource handles.
The QPlatformPixmap class provides an abstraction for native pixmaps.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
std::wstring toStdWString() const
Returns a std::wstring object with the data contained in this QString.
Definition qstring.h:1450
\inmodule QtCore
\inmodule QtGui
Definition qwindow.h:63
QWindowsDirect2DNativeInterface m_nativeInterface
static QWindowsDirect2DIntegration * create(const QStringList &paramList)
QWindowsWindow * createPlatformWindowHelper(QWindow *window, const QWindowsWindowData &) const override
QPlatformNativeInterface * nativeInterface() const override
QWindowsDirect2DContext * direct2DContext() const
QPlatformPixmap * createPlatformPixmap(QPlatformPixmap::PixelType type) const override
Factory function for QPlatformPixmap.
QPlatformBackingStore * createPlatformBackingStore(QWindow *window) const override
Factory function for QPlatformBackingStore.
static QWindowsDirect2DIntegration * instance()
static QWindowsIntegration * instance()
Raster or OpenGL Window.
Combined button and popup list for selecting options.
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
GLsizei bufSize
static QVersionNumber minimumD2DVersion()
static QVersionNumber systemD2DVersion()
aWidget window() -> setWindowTitle("New Window Title")
[2]
QHostInfo info
[0]