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 | #pragma once |
5 | |
6 | #include "qxcbeglwindow.h" |
7 | #include <QtGui/private/qeglplatformcontext_p.h> |
8 | #include <QtGui/private/qeglpbuffer_p.h> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | class QXcbEglContext : public QEGLPlatformContext |
13 | { |
14 | public: |
15 | using QEGLPlatformContext::QEGLPlatformContext; |
16 | QXcbEglContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share, EGLDisplay display) |
17 | : QEGLPlatformContext(glFormat, share, display, nullptr) |
18 | { |
19 | } |
20 | |
21 | void swapBuffers(QPlatformSurface *surface) override |
22 | { |
23 | QEGLPlatformContext::swapBuffers(surface); |
24 | if (surface->surface()->surfaceClass() == QSurface::Window) { |
25 | QXcbWindow *platformWindow = static_cast<QXcbWindow *>(surface); |
26 | // OpenGL context might be bound to a non-gui thread use QueuedConnection to sync |
27 | // the window from the platformWindow's thread as QXcbWindow is no QObject, an |
28 | // event is sent to QXcbConnection. (this is faster than a metacall) |
29 | if (platformWindow->needsSync()) |
30 | platformWindow->postSyncWindowRequest(); |
31 | } |
32 | } |
33 | |
34 | bool makeCurrent(QPlatformSurface *surface) override |
35 | { |
36 | return QEGLPlatformContext::makeCurrent(surface); |
37 | } |
38 | |
39 | void doneCurrent() override |
40 | { |
41 | QEGLPlatformContext::doneCurrent(); |
42 | } |
43 | |
44 | EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override |
45 | { |
46 | if (surface->surface()->surfaceClass() == QSurface::Window) |
47 | return static_cast<QXcbEglWindow *>(surface)->eglSurface(); |
48 | else |
49 | return static_cast<QEGLPbuffer *>(surface)->pbuffer(); |
50 | } |
51 | }; |
52 | |
53 | QT_END_NAMESPACE |
54 |