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 | #ifndef QOFFSCREENINTEGRATION_X11_H |
5 | #define QOFFSCREENINTEGRATION_X11_H |
6 | |
7 | #include "qoffscreenintegration.h" |
8 | #include "qoffscreencommon.h" |
9 | |
10 | #include <qglobal.h> |
11 | #include <qscopedpointer.h> |
12 | |
13 | #include <qpa/qplatformopenglcontext.h> |
14 | #include <QtGui/qguiapplication.h> |
15 | |
16 | QT_BEGIN_NAMESPACE |
17 | |
18 | class QOffscreenX11Connection; |
19 | class QOffscreenX11Info; |
20 | |
21 | class QOffscreenX11PlatformNativeInterface : public QOffscreenPlatformNativeInterface |
22 | #if QT_CONFIG(xcb) |
23 | , public QNativeInterface::QX11Application |
24 | #endif |
25 | { |
26 | public: |
27 | QOffscreenX11PlatformNativeInterface(QOffscreenIntegration *integration); |
28 | ~QOffscreenX11PlatformNativeInterface(); |
29 | |
30 | void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) override; |
31 | #if !defined(QT_NO_OPENGL) && QT_CONFIG(xcb_glx_plugin) |
32 | void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override; |
33 | #endif |
34 | #if QT_CONFIG(xcb) |
35 | Display *display() const override; |
36 | xcb_connection_t *connection() const override { return nullptr; }; |
37 | #endif |
38 | QScopedPointer<QOffscreenX11Connection> m_connection; |
39 | }; |
40 | |
41 | class QOffscreenX11Integration : public QOffscreenIntegration |
42 | { |
43 | public: |
44 | QOffscreenX11Integration(const QStringList& paramList); |
45 | ~QOffscreenX11Integration(); |
46 | bool hasCapability(QPlatformIntegration::Capability cap) const override; |
47 | |
48 | #if !defined(QT_NO_OPENGL) && QT_CONFIG(xcb_glx_plugin) |
49 | QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override; |
50 | #endif |
51 | QOffscreenX11PlatformNativeInterface *nativeInterface() const override; |
52 | }; |
53 | |
54 | class QOffscreenX11Connection { |
55 | public: |
56 | QOffscreenX11Connection(); |
57 | ~QOffscreenX11Connection(); |
58 | |
59 | QOffscreenX11Info *x11Info(); |
60 | |
61 | void *display() const { return m_display; } |
62 | int screenNumber() const { return m_screenNumber; } |
63 | |
64 | private: |
65 | void *m_display; |
66 | int m_screenNumber; |
67 | |
68 | QScopedPointer<QOffscreenX11Info> m_x11Info; |
69 | }; |
70 | |
71 | #if QT_CONFIG(xcb_glx_plugin) |
72 | class QOffscreenX11GLXContextData; |
73 | |
74 | class QOffscreenX11GLXContext : public QPlatformOpenGLContext |
75 | , public QNativeInterface::QGLXContext |
76 | { |
77 | public: |
78 | QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGLContext *context); |
79 | ~QOffscreenX11GLXContext(); |
80 | |
81 | bool makeCurrent(QPlatformSurface *surface) override; |
82 | void doneCurrent() override; |
83 | void swapBuffers(QPlatformSurface *surface) override; |
84 | QFunctionPointer getProcAddress(const char *procName) override; |
85 | |
86 | QSurfaceFormat format() const override; |
87 | bool isSharing() const override; |
88 | bool isValid() const override; |
89 | |
90 | GLXContext nativeContext() const override { return glxContext(); } |
91 | |
92 | void *glxConfig() const; |
93 | GLXContext glxContext() const; |
94 | |
95 | private: |
96 | QScopedPointer<QOffscreenX11GLXContextData> d; |
97 | }; |
98 | #endif // QT_CONFIG(xcb_glx_plugin) |
99 | |
100 | QT_END_NAMESPACE |
101 | |
102 | #endif |
103 |